diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-02-01 11:25:16 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-02-01 11:25:16 +0700 |
| commit | 211abaad9849cefbf93326742a4b295a94d3b4a2 (patch) | |
| tree | ca712add01070388a2dfd45174d5bc76b8f8e503 | |
| parent | 3fb9daa949bff644aedb6f0a70c57e89623475ed (diff) | |
add condition while compute margin
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index b88d9ad0..75981275 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): |
