diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-09-28 10:56:08 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-09-28 10:56:08 +0700 |
| commit | 4e5da6ed950e2129cb50087469c2b56894bafe93 (patch) | |
| tree | 6e1509ddc8bfa78c54004196284851d4e7a6049f /indoteknik_custom/models/promotion/promotion_program_line.py | |
| parent | 7909b937bf9484b38f16be1f4be955094e0c25ab (diff) | |
| parent | 0d1bf664d93ff02a42b1962fcf034690b105b8a9 (diff) | |
Merge branch 'production' into iman/switch-account
Diffstat (limited to 'indoteknik_custom/models/promotion/promotion_program_line.py')
| -rw-r--r-- | indoteknik_custom/models/promotion/promotion_program_line.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/indoteknik_custom/models/promotion/promotion_program_line.py b/indoteknik_custom/models/promotion/promotion_program_line.py index a57f1f2c..7a15ad11 100644 --- a/indoteknik_custom/models/promotion/promotion_program_line.py +++ b/indoteknik_custom/models/promotion/promotion_program_line.py @@ -34,6 +34,29 @@ class PromotionProgramLine(models.Model): active = fields.Boolean(string="Active", default=True) solr_flag = fields.Integer(string="Solr Flag", default=1) description = fields.Char('Description') + price_tier_1 = fields.Float('Price Tier 1') + price_tier_2 = fields.Float('Price Tier 2') + price_tier_3 = fields.Float('Price Tier 3') + price_tier_4 = fields.Float('Price Tier 4') + price_tier_5 = fields.Float('Price Tier 5') + + def get_price_tier(self, product_id, qty): + product = self.env['product.product'].browse(product_id.id) + + tiers = ['1_v2', '2_v2', '3_v2', '4_v2', '5_v2'] + + for index, tier in enumerate(tiers, start=1): + + price_tier_data = product._get_pricelist_tier(tier) + + price_field = f'price_tier_{index}' + + if price_field in self._fields: + price = price_tier_data.get(f'price_tier{tier}', 0) * qty + self[price_field] = price + + if index == 1: + self.price = price def get_active_promotions(self, product_id): current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') |
