summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-02-02 08:58:09 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-02-02 08:58:09 +0700
commitd6c7fad834f954f892cea0eb9e082db822bc8f2b (patch)
treece32978af6b8664103c64aa456a2ce2966de2a26
parent6f0b80656e318914d56d085f9b9e08ccd9838450 (diff)
fix error purchase pricelist
-rwxr-xr-xindoteknik_custom/models/purchase_pricelist.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py
index 805ebc89..67b22e4c 100755
--- a/indoteknik_custom/models/purchase_pricelist.py
+++ b/indoteknik_custom/models/purchase_pricelist.py
@@ -39,8 +39,7 @@ class PurchasePricelist(models.Model):
if price_unit == 0:
self.include_price = 0
return
- # taxes = self.taxes_system_id or self.taxes_product_id
- # price_unit = self.system_price or self.product_price
+
tax_include = taxes.price_include
if taxes:
if tax_include:
@@ -53,18 +52,20 @@ class PurchasePricelist(models.Model):
self.include_price = price_unit
def _get_valid_price(self):
- p_price = 0
- taxes = False
+ purchase_price = self
+ price = 0
+ taxes = None
+ human_last_update = purchase_price.human_last_update or datetime.min
+ system_last_update = purchase_price.system_last_update or datetime.min
- if self.system_price > 0:
- if self.product_price > 0 and self.human_last_update > self.system_last_update:
- p_price, taxes = self.product_price, self.taxes_product_id
- else:
- p_price, taxes = self.system_price, self.taxes_system_id
- elif self.product_price > 0:
- p_price, taxes = self.product_price, self.taxes_product_id
-
- return p_price, taxes
+ if system_last_update > human_last_update:
+ price = purchase_price.system_price
+ taxes = purchase_price.taxes_system_id
+ else:
+ price = purchase_price.product_price
+ taxes = purchase_price.taxes_product_id
+
+ return price, taxes
@api.constrains('vendor_id', 'product_id')
def _check_duplicate_purchase_pricelist(self):