summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2024-02-26 14:40:23 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2024-02-26 14:40:23 +0700
commit11309b5a62dfa0e75ca7a4bd0266816140465ba6 (patch)
treec852cd3b0b68ff53ec00775d3d7377c632c74826 /indoteknik_custom/models
parentabcaa0fc701901cf6864c2872ffb2e469d808628 (diff)
Add price and manufacture on promotion monitoring
Diffstat (limited to 'indoteknik_custom/models')
-rw-r--r--indoteknik_custom/models/promotion/promotion_monitoring.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/indoteknik_custom/models/promotion/promotion_monitoring.py b/indoteknik_custom/models/promotion/promotion_monitoring.py
index 3197b9ba..d8a6dd43 100644
--- a/indoteknik_custom/models/promotion/promotion_monitoring.py
+++ b/indoteknik_custom/models/promotion/promotion_monitoring.py
@@ -7,6 +7,8 @@ class PromotionMonitoring(models.Model):
_rec_name = "product_id"
product_id = fields.Many2one(comodel_name="product.product", string="Product")
+ manufacture_id = fields.Many2one(comodel_name="x_manufactures", string="Manufacture", related="product_id.x_manufacture")
+ price = fields.Float(string="Price", help="Computed Price di Product Pricelist (Tier 1 New)")
has_promo = fields.Boolean(string="Has Promo")
count_active = fields.Integer(string="Count Active")
count_inactive = fields.Integer(string="Count Inactive")
@@ -20,16 +22,19 @@ class PromotionMonitoring(models.Model):
SELECT
p.id as id,
p.id as product_id,
+ ppi.computed_price as price,
({count_active_sql} > 0) as has_promo,
{count_active_sql} as count_active,
{count_inactive_sql} as count_inactive
FROM product_product p
LEFT JOIN product_template pt ON pt.id = p.product_tmpl_id
- LEFT JOIN promotion_product pp ON p.id = pp.product_id
+ LEFT JOIN promotion_product pp ON pp.product_id = p.id
LEFT JOIN promotion_program_line ppl ON ppl.id = pp.program_line_id
+ LEFT JOIN product_pricelist_item ppi ON ppi.product_id = p.id
WHERE p.active = True
AND pt.sale_ok = True
- GROUP BY p.id
+ AND ppi.pricelist_id = 17023
+ GROUP BY p.id, ppi.id
)
""".format(
table=self._table,