diff options
| author | HafidBuroiroh <hafidburoiroh09@gmail.com> | 2026-03-14 13:23:26 +0700 |
|---|---|---|
| committer | HafidBuroiroh <hafidburoiroh09@gmail.com> | 2026-03-14 13:23:26 +0700 |
| commit | a699dd3899c9235b3dcc4de6ad277b687940e2b5 (patch) | |
| tree | 91c48aa83fc88d0e29d9800e09cbc529866f56a1 | |
| parent | 9a039103f64661ebf27d89889e1e3c3a67c017a5 (diff) | |
<hafid> fix error purchase price
| -rw-r--r-- | indoteknik_custom/models/sourcing_job_order.py | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/indoteknik_custom/models/sourcing_job_order.py b/indoteknik_custom/models/sourcing_job_order.py index 9729fc45..d5446c83 100644 --- a/indoteknik_custom/models/sourcing_job_order.py +++ b/indoteknik_custom/models/sourcing_job_order.py @@ -1050,7 +1050,7 @@ class SourcingJobOrderLine(models.Model): self.tax_id = False self.now_price = 0 self.last_updated_price = False - elif self.product_id.x_manufacture.override_vendor_id: + else: price, taxes, vendor_id, last_updated = self._get_purchase_price_by_vendor(self.product_id, self.vendor_id) self.price = price self.now_price = price @@ -1067,36 +1067,34 @@ class SourcingJobOrderLine(models.Model): return self._get_valid_purchase_price(purchase_price) def _get_valid_purchase_price(self, purchase_price): + if not purchase_price: + return 0, False, False, False + current_time = datetime.now() delta_time = current_time - timedelta(days=365) - default_timestamp = datetime(1970, 1, 1, 0, 0, 0) - # delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S') - price = 0 - taxes = 24 - vendor_id = False human_last_update = purchase_price.human_last_update or False system_last_update = purchase_price.system_last_update or False - # if purchase_price.taxes_product_id.type_tax_use == 'purchase': price = purchase_price.product_price - taxes = purchase_price.taxes_product_id.id or 24 + taxes = purchase_price.taxes_product_id.id or False vendor_id = purchase_price.vendor_id.id last_updated = human_last_update - if delta_time > human_last_update: + + if human_last_update and delta_time > human_last_update: price = 0 - taxes = 24 + taxes = False vendor_id = False - if system_last_update > human_last_update: - # if purchase_price.taxes_system_id.type_tax_use == 'purchase': + if system_last_update and human_last_update and system_last_update > human_last_update: price = purchase_price.system_price - taxes = purchase_price.taxes_system_id.id or 24 + taxes = purchase_price.taxes_system_id.id or False vendor_id = purchase_price.vendor_id.id last_updated = system_last_update - if delta_time > system_last_update: + + if system_last_update and delta_time > system_last_update: price = 0 - taxes = 24 + taxes = False vendor_id = False return price, taxes, vendor_id, last_updated |
