diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-01-23 10:03:42 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-01-23 10:03:42 +0700 |
| commit | f7fe2253a8c79ff5172cf74c1f1aa341c9bf4f07 (patch) | |
| tree | 9c3b7f9cd9b5fd1296d9670ec7337e715c60dc8e /indoteknik_custom/models/purchase_pricelist.py | |
| parent | e5dbcd62560f4083d413d474b123ed971926a2a0 (diff) | |
fix bug purchase pricelist, bug automatic purchase, bug log saleorder eta date
Diffstat (limited to 'indoteknik_custom/models/purchase_pricelist.py')
| -rwxr-xr-x | indoteknik_custom/models/purchase_pricelist.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py index 9c149ea9..af33abbf 100755 --- a/indoteknik_custom/models/purchase_pricelist.py +++ b/indoteknik_custom/models/purchase_pricelist.py @@ -32,11 +32,12 @@ class PurchasePricelist(models.Model): else: self.human_last_update = current_time - @api.constrains('system_last_update','system_price') + @api.constrains('system_last_update','system_price','product_price','human_last_update') def _contrains_include_price(self): - taxes = self.taxes_system_id or self.taxes_product_id + price_unit, taxes = self._get_valid_price() + # taxes = self.taxes_system_id or self.taxes_product_id + # price_unit = self.system_price or self.product_price tax_include = taxes.price_include - price_unit = self.system_price or self.product_price if taxes: if tax_include: price_unit = price_unit @@ -47,6 +48,20 @@ class PurchasePricelist(models.Model): self.include_price = price_unit + def _get_valid_price(self): + p_price = 0 + taxes = False + + 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 + @api.constrains('vendor_id', 'product_id') def _check_duplicate_purchase_pricelist(self): for price in self: |
