summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/promotion
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-02-22 14:49:25 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-02-22 14:49:25 +0700
commitda0a75bc6b7166e297bcaf175c15089e95dbbf2e (patch)
tree156cfb319848cd2b2964f83b3cb185e8f920f7b2 /indoteknik_custom/models/promotion
parent6850fd6f86a0fbba3156e59f9ac5836052f019ce (diff)
parent0face879a802bf1a15d1065d59db64f723b4e8d3 (diff)
Merge branch 'production' of bitbucket.org:altafixco/indoteknik-addons into production
Diffstat (limited to 'indoteknik_custom/models/promotion')
-rw-r--r--indoteknik_custom/models/promotion/promotion_free_product.py4
-rw-r--r--indoteknik_custom/models/promotion/promotion_product.py4
-rw-r--r--indoteknik_custom/models/promotion/promotion_program_line.py8
3 files changed, 13 insertions, 3 deletions
diff --git a/indoteknik_custom/models/promotion/promotion_free_product.py b/indoteknik_custom/models/promotion/promotion_free_product.py
index c5055562..e91d5137 100644
--- a/indoteknik_custom/models/promotion/promotion_free_product.py
+++ b/indoteknik_custom/models/promotion/promotion_free_product.py
@@ -17,6 +17,10 @@ class PromotionFreeProduct(models.Model):
weight = rec.product_id.weight or 0
result.append({
'id': rec.product_id.id,
+ 'parent': {
+ 'id': rec.product_id.product_tmpl_id.id,
+ 'name': rec.product_id.product_tmpl_id.name,
+ },
'image': ir_attachment.api_image('product.template', 'image_256', rec.product_id.product_tmpl_id.id),
'display_name': rec.product_id.display_name,
'name': rec.product_id.name,
diff --git a/indoteknik_custom/models/promotion/promotion_product.py b/indoteknik_custom/models/promotion/promotion_product.py
index 2fad0f0d..ae26e888 100644
--- a/indoteknik_custom/models/promotion/promotion_product.py
+++ b/indoteknik_custom/models/promotion/promotion_product.py
@@ -17,6 +17,10 @@ class PromotionProduct(models.Model):
weight = rec.product_id.weight or 0
result.append({
'id': rec.product_id.id,
+ 'parent': {
+ 'id': rec.product_id.product_tmpl_id.id,
+ 'name': rec.product_id.product_tmpl_id.name,
+ },
'image': ir_attachment.api_image('product.template', 'image_256', rec.product_id.product_tmpl_id.id),
'display_name': rec.product_id.display_name,
'name': rec.product_id.name,
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)