summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/sale_order.py
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models/sale_order.py')
-rwxr-xr-xindoteknik_custom/models/sale_order.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index b88d9ad0..7d7eb86c 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -355,8 +355,11 @@ class SaleOrderLine(models.Model):
purchase_price = purchase_price * line.product_uom_qty
margin_per_item = sales_price - purchase_price
line.item_margin = margin_per_item
- # if sales_price > 0:
- line.item_percent_margin = round((margin_per_item / sales_price), 2) * 100
+
+ if sales_price > 0:
+ line.item_percent_margin = round((margin_per_item / sales_price), 2) * 100
+ else:
+ line.item_percent_margin = 0
@api.onchange('vendor_id')
def onchange_vendor_id(self):
@@ -379,13 +382,19 @@ class SaleOrderLine(models.Model):
def compute_delivery_amt_line(self):
for line in self:
- contribution = round((line.price_total / line.order_id.amount_total), 2)
+ try:
+ contribution = round((line.price_total / line.order_id.amount_total), 2)
+ except:
+ contribution = 0
delivery_amt = line.order_id.delivery_amt
line.delivery_amt_line = delivery_amt * contribution
def compute_fee_third_party_line(self):
for line in self:
- contribution = round((line.price_total / line.order_id.amount_total), 2)
+ try:
+ contribution = round((line.price_total / line.order_id.amount_total), 2)
+ except:
+ contribution = 0
fee = line.order_id.fee_third_party
line.fee_third_party_line = fee * contribution