diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2024-01-22 13:22:10 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2024-01-22 13:22:10 +0700 |
| commit | 931955161ec87ef152f9c76bee9f6c0abd81a2b5 (patch) | |
| tree | 0c19da5c4fc2620e51f097240d123e75166344aa | |
| parent | b972e53c1a1b184123327b18ef89517e3c075ad6 (diff) | |
Update get valid purchase price di sale order line
| -rw-r--r-- | indoteknik_custom/models/sale_order_line.py | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 78944876..62f4a6b4 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -1,5 +1,6 @@ from odoo import fields, models, api, _ from odoo.exceptions import UserError +from datetime import datetime class SaleOrderLine(models.Model): @@ -93,18 +94,16 @@ class SaleOrderLine(models.Model): self.purchase_tax_id = 22 def _get_valid_purchase_price(self, purchase_price): - price = purchase_price.system_price or purchase_price.product_price or 0 - - if purchase_price.system_price > 0 and purchase_price.product_price > 0: - if not purchase_price.human_last_update or not purchase_price.system_last_update: - return price - - if purchase_price.system_last_update > purchase_price.human_last_update: - price = purchase_price.system_price - else: - price = purchase_price.product_price + price = 0 + human_last_update = purchase_price.human_last_update or datetime.min + system_last_update = purchase_price.system_last_update or datetime.min + + if system_last_update > human_last_update: + price = purchase_price.system_price + else: + price = purchase_price.product_price - return price + return price or 0 @api.onchange('product_id') def product_id_change(self): |
