diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2024-08-21 09:03:10 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2024-08-21 09:03:10 +0700 |
| commit | ec125ff34a2b39368fdfdd441601dbf9ab2600c4 (patch) | |
| tree | 9a09781aaf10cbb05ac7ee29617ba411746a6fca | |
| parent | c00c2a993186346d81393b4fb4c852e247bbbae5 (diff) | |
fix bug calculate selling price
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 0b0a679f..7ce3c2b7 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -878,7 +878,7 @@ class SaleOrder(models.Model): ('order_id.date_order', '>=', delta_time) ], limit=1, order='create_date desc') - if rec_vendor_id != last_so.vendor_id.id: + if last_so and rec_vendor_id != last_so.vendor_id.id: last_so = self.env['sale.order.line'].search([ # ('order_id.partner_id.id', '=', order_line.order_id.partner_id.id), ('order_id.partner_id', 'in', partners), @@ -889,7 +889,7 @@ class SaleOrder(models.Model): ('order_id.date_order', '>=', delta_time) ], limit=1, order='create_date desc') - if rec_purchase_price != last_so.purchase_price: + if last_so 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: selling_price = (rec_purchase_price / 1.11) / (1 - (last_so.item_percent_margin_without_deduction / 100)) @@ -911,7 +911,7 @@ class SaleOrder(models.Model): 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: + elif last_so and 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: selling_price = (rec_purchase_price / 1.11) / (1 - (last_so.item_percent_margin_without_deduction / 100)) |
