diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2024-02-02 14:07:43 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2024-02-02 14:07:43 +0700 |
| commit | c26ea43e1d8c3c5bfffb94bc1432589a9f2815c9 (patch) | |
| tree | 86b02e1b4d362617b168f4cb0a5777be483d07fb /indoteknik_custom/models/purchase_pricelist.py | |
| parent | 8bc43445f1d0b70d54d0a45830e04d0fcc406fbe (diff) | |
| parent | f5edc62d22c9a3973261ad289a11e189f0866f52 (diff) | |
Merge branch 'production' of bitbucket.org:altafixco/indoteknik-addons into production
Diffstat (limited to 'indoteknik_custom/models/purchase_pricelist.py')
| -rwxr-xr-x | indoteknik_custom/models/purchase_pricelist.py | 27 |
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): |
