diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-02-22 14:49:25 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-02-22 14:49:25 +0700 |
| commit | da0a75bc6b7166e297bcaf175c15089e95dbbf2e (patch) | |
| tree | 156cfb319848cd2b2964f83b3cb185e8f920f7b2 /indoteknik_custom/models/promotion/promotion_program_line.py | |
| parent | 6850fd6f86a0fbba3156e59f9ac5836052f019ce (diff) | |
| parent | 0face879a802bf1a15d1065d59db64f723b4e8d3 (diff) | |
Merge branch 'production' of bitbucket.org:altafixco/indoteknik-addons into production
Diffstat (limited to 'indoteknik_custom/models/promotion/promotion_program_line.py')
| -rw-r--r-- | indoteknik_custom/models/promotion/promotion_program_line.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/indoteknik_custom/models/promotion/promotion_program_line.py b/indoteknik_custom/models/promotion/promotion_program_line.py index 18a7e184..ce46d2e7 100644 --- a/indoteknik_custom/models/promotion/promotion_program_line.py +++ b/indoteknik_custom/models/promotion/promotion_program_line.py @@ -30,6 +30,7 @@ class PromotionProgramLine(models.Model): discount_amount = fields.Float('Discount Amount') order_promotion_ids = fields.One2many('sale.order.promotion', 'program_line_id', 'Promotions') + active = fields.Boolean(default=True) def get_active_promotions(self, product_id): current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') @@ -74,6 +75,9 @@ class PromotionProgramLine(models.Model): } def _get_remaining_time(self): + if not self.program_id.end_time: + return 0 + calculate_time = self.program_id.end_time - datetime.now() return round(calculate_time.total_seconds()) @@ -93,9 +97,7 @@ class PromotionProgramLine(models.Model): free_products = self.free_product_ids.formats(purchase_qty=qty) merged_products = products + free_products - weight = 0 - if not any(x['package_weight'] == 0 for x in merged_products): - weight = sum(x['package_weight'] for x in merged_products) + weight = sum(x['package_weight'] for x in merged_products) # Sum of products and free products in 1 package quantity products_total = sum(x['price']['price_discount'] * x['qty'] / qty for x in products) |
