diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2024-02-26 09:16:16 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2024-02-26 09:16:16 +0700 |
| commit | 7c96326cc85efe6fd9d2cbd8c0284663282f1abc (patch) | |
| tree | 6aeeb25e681951c2b9ff285d4d1ec5265dbf2790 | |
| parent | fc460ec7349d557654316c0628d76d49c12fd575 (diff) | |
Add promotion monitoring
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/promotion/__init__.py | 3 | ||||
| -rw-r--r-- | indoteknik_custom/models/promotion/promotion_monitoring.py | 29 | ||||
| -rw-r--r-- | indoteknik_custom/views/promotion/promotion_monitoring.xml | 46 |
4 files changed, 78 insertions, 1 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 6d1ca7b0..27617099 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -78,6 +78,7 @@ 'views/promotion/promotion_program.xml', 'views/promotion/promotion_program_line.xml', 'views/promotion/promotion_product.xml', + 'views/promotion/promotion_monitoring.xml', 'views/requisition.xml', 'views/landedcost.xml', 'views/product_sla.xml', diff --git a/indoteknik_custom/models/promotion/__init__.py b/indoteknik_custom/models/promotion/__init__.py index 1e15d714..82628d31 100644 --- a/indoteknik_custom/models/promotion/__init__.py +++ b/indoteknik_custom/models/promotion/__init__.py @@ -5,4 +5,5 @@ from . import promotion_free_product from . import sale_order_promotion from . import sale_order_line from . import sale_order -from . import promotion_keyword
\ No newline at end of file +from . import promotion_keyword +from . import promotion_monitoring
\ No newline at end of file diff --git a/indoteknik_custom/models/promotion/promotion_monitoring.py b/indoteknik_custom/models/promotion/promotion_monitoring.py new file mode 100644 index 00000000..e5598e40 --- /dev/null +++ b/indoteknik_custom/models/promotion/promotion_monitoring.py @@ -0,0 +1,29 @@ +from odoo import fields, models, tools + + +class PromotionMonitoring(models.Model): + _name = "promotion.monitoring" + _auto = False + _rec_name = "product_id" + + product_id = fields.Many2one(comodel_name="product.product", string="Product") + has_promo = fields.Boolean(string="Has Promo") + count_promo = fields.Integer(string="Count Promo") + + def init(self): + tools.drop_view_if_exists(self.env.cr, self._table) + self.env.cr.execute(""" + CREATE OR REPLACE VIEW %s AS ( + SELECT + p.id as id, + p.id as product_id, + (COUNT(pp.id) > 0) as has_promo, + COUNT(pp.id) as count_promo + 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 + WHERE p.active = True + AND pt.sale_ok = True + GROUP BY p.id + ) + """ % self._table)
\ No newline at end of file diff --git a/indoteknik_custom/views/promotion/promotion_monitoring.xml b/indoteknik_custom/views/promotion/promotion_monitoring.xml new file mode 100644 index 00000000..b1f80276 --- /dev/null +++ b/indoteknik_custom/views/promotion/promotion_monitoring.xml @@ -0,0 +1,46 @@ +<odoo> + <record id="promotion_monitoring_tree" model="ir.ui.view"> + <field name="name">Promotion Monitoring Tree</field> + <field name="model">promotion.monitoring</field> + <field name="arch" type="xml"> + <tree> + <field name="product_id" /> + <field name="has_promo" /> + <field name="count_promo" /> + </tree> + </field> + </record> + + <record id="promotion_monitoring_form" model="ir.ui.view"> + <field name="name">Promotion Monitoring Form</field> + <field name="model">promotion.monitoring</field> + <field name="arch" type="xml"> + <form> + <sheet> + <group> + <group> + <field name="product_id" /> + <field name="has_promo" /> + <field name="count_promo" /> + </group> + </group> + </sheet> + </form> + </field> + </record> + + <record id="promotion_monitoring_action" model="ir.actions.act_window"> + <field name="name">Promotion Monitoring</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">promotion.monitoring</field> + <field name="view_mode">tree,form</field> + </record> + + <menuitem + id="menu_promotion_monitoring" + name="Monitoring" + parent="indoteknik_custom.menu_promotion_program_parent" + sequence="3" + action="promotion_monitoring_action" + /> +</odoo>
\ No newline at end of file |
