diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2024-08-03 09:04:51 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2024-08-03 09:04:51 +0700 |
| commit | 3cf53a4a6bc09a41bfd39f243a951e21b060c8ca (patch) | |
| tree | b052aaf59dd4059c3c5aeaf29b81e263676a5e57 | |
| parent | 7229d06c4d4557fd1e92e3afbda789620f5a2d0c (diff) | |
fix empty data
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index a4c3d079..c5689a79 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -866,10 +866,14 @@ class SaleOrder(models.Model): else: selling_price = selling_price discount = 0 - else: + elif last_so: selling_price = last_so.price_unit tax_id = last_so.tax_id discount = last_so.discount + else: + selling_price = order_line.price_unit + tax_id = order_line.tax_id + discount = order_line.discount elif rec_vendor_id == order_line.vendor_id.id and rec_purchase_price != last_so.purchase_price: rec_taxes = self.env['account.tax'].search([('id', '=', rec_taxes_id)], limit=1) if rec_taxes.price_include: @@ -878,10 +882,14 @@ class SaleOrder(models.Model): selling_price = rec_purchase_price / (1 - (last_so.item_percent_margin / 100)) tax_id = last_so.tax_id discount = 0 - else: + elif last_so: selling_price = last_so.price_unit tax_id = last_so.tax_id discount = last_so.discount + else: + selling_price = order_line.price_unit + tax_id = order_line.tax_id + discount = order_line.discount order_line.price_unit = selling_price order_line.tax_id = tax_id order_line.discount = discount |
