diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2024-01-29 14:26:39 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2024-01-29 14:26:39 +0700 |
| commit | 3877bf37dae2db272b869f829ed52ef77689cc5d (patch) | |
| tree | 46523b9c4306b5457924420f53e832da1c296224 /indoteknik_custom/models/purchase_order_line.py | |
| parent | 4a35b0d5432ed38395fa8f8cb6ebcfb5e0887f28 (diff) | |
| parent | d62a28e8760c86e2c0a6cb7469f626d9447272be (diff) | |
Merge branch 'production' of https://bitbucket.org/altafixco/indoteknik-addons into production
Diffstat (limited to 'indoteknik_custom/models/purchase_order_line.py')
| -rwxr-xr-x | indoteknik_custom/models/purchase_order_line.py | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index c7da0e24..465944d5 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -2,6 +2,7 @@ from odoo import fields, models, api, _ from odoo.exceptions import AccessError, UserError, ValidationError from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT import logging +from datetime import datetime _logger = logging.getLogger(__name__) @@ -103,24 +104,19 @@ class PurchaseOrderLine(models.Model): return res def _get_valid_purchase_price(self, purchase_price): - p_price = 0 - taxes = False - - if purchase_price.system_price > 0 and purchase_price.product_price > 0: - if purchase_price.human_last_update > purchase_price.system_last_update: - p_price = purchase_price.product_price - taxes = purchase_price.taxes_product_id - else: - p_price = purchase_price.system_price - taxes = purchase_price.taxes_system_id - elif purchase_price.system_price > 0 and purchase_price.product_price == 0: - p_price = purchase_price.system_price - taxes = purchase_price.taxes_system_id - elif purchase_price.system_price == 0 and purchase_price.product_price > 0: - p_price = purchase_price.product_price - taxes = purchase_price.taxes_product_id - - return p_price, taxes + 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 system_last_update > human_last_update: + price = purchase_price.system_price + taxes = [purchase.taxes_system_id.id for purchase in purchase_price ] + else: + price = purchase_price.product_price + taxes = [purchase.taxes_product_id.id for purchase in purchase_price ] + + return price, taxes def compute_item_margin(self): sum_so_margin = sum_sales_price = sum_margin = 0 |
