summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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):