diff options
| -rw-r--r-- | indoteknik_custom/__manifest__.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/sale_monitoring.py | 50 | ||||
| -rw-r--r-- | indoteknik_custom/security/ir.model.access.csv | 3 | ||||
| -rw-r--r-- | indoteknik_custom/views/sale_monitoring.xml | 51 |
5 files changed, 105 insertions, 1 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 8de5bebc..d18f1582 100644 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -16,6 +16,7 @@ 'views/product_template.xml', 'views/purchase_order.xml', 'views/purchase_pricelist.xml', + 'views/sale_monitoring.xml', 'views/user_activity_log.xml', 'views/vit_kelurahan.xml', 'views/vit_kecamatan.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 30914b52..03b01fc4 100644 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -14,3 +14,4 @@ from . import user_activity_log from . import purchase_order from . import purchase_pricelist from . import purchase_order_line +from . import sale_monitoring diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py new file mode 100644 index 00000000..6a558669 --- /dev/null +++ b/indoteknik_custom/models/sale_monitoring.py @@ -0,0 +1,50 @@ +from odoo import fields, models, api, tools + + +class SaleMonitoring(models.Model): + _name = 'sale.monitoring' + _auto = False + + id = fields.Integer() + name = fields.Char(string="Name") + product_name = fields.Char(string="Product Name") + default_code = fields.Char(string="Default Code") + qty_so = fields.Integer(string="Qty SO") + qty_so_delivered = fields.Integer(string="Qty SO Delivered") + qty_so_invoiced = fields.Integer(string="Qty SO Invoiced") + qty_po = fields.Integer(string="Qty PO") + qty_po_received = fields.Integer(string="Qty PO Received") + + 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, + so.name AS name, + p.default_code AS default_code, + pt.name as product_name, + sol.product_uom_qty AS qty_so, + sol.qty_delivered AS qty_so_delivered, + sol.qty_invoiced AS qty_so_invoiced, + ( + SELECT SUM(product_uom_qty) + FROM purchase_order_line pol + JOIN purchase_order poo ON poo.id = pol.order_id + WHERE poo.sale_order_id = so.id AND pol.product_id = sol.product_id + ) AS qty_po, + ( + SELECT SUM(qty_received) + FROM purchase_order_line pol + JOIN purchase_order poo ON poo.id = pol.order_id + WHERE poo.sale_order_id = so.id AND pol.product_id = sol.product_id + ) AS qty_po_received + FROM sale_order so + JOIN sale_order_line sol ON sol.order_id = so.id + JOIN product_product p ON p.id = sol.product_id + JOIN product_template pt ON pt.id = p.product_tmpl_id + WHERE pt.type IN ('consu','product') + AND so.state IN ('sale') + AND so.create_date >= '2022-08-10' + ) + """ % self._table) diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index dc18fd33..60667274 100644 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -7,4 +7,5 @@ access_x_partner_purchase_order,access.x.partner.purchase.order,model_x_partner_ access_x_product_tags,access.x.product.tags,model_x_product_tags,,1,1,1,1 access_stock_vendor,access.stock.vendor,model_stock_vendor,,1,1,1,1 access_user_activity_log,access.user.activity.log,model_user_activity_log,,1,1,1,1 -access_purchase_pricelist,access.purchase.pricelist,model_purchase_pricelist,,1,1,1,1
\ No newline at end of file +access_purchase_pricelist,access.purchase.pricelist,model_purchase_pricelist,,1,1,1,1 +access_sale_monitoring,access.sale.monitoring,model_sale_monitoring,,1,1,1,1
\ No newline at end of file diff --git a/indoteknik_custom/views/sale_monitoring.xml b/indoteknik_custom/views/sale_monitoring.xml new file mode 100644 index 00000000..3c160e19 --- /dev/null +++ b/indoteknik_custom/views/sale_monitoring.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="utf-8" ?> +<odoo> + <record id="sale_monitoring_tree" model="ir.ui.view"> + <field name="name">sale.monitoring.tree</field> + <field name="model">sale.monitoring</field> + <field name="arch" type="xml"> + <tree> + <field name="name"/> + <field name="product_name"/> + <field name="default_code"/> + <field name="qty_so"/> + <field name="qty_po"/> + <field name="qty_po_received"/> + <field name="qty_so_delivered"/> + <field name="qty_so_invoiced"/> + </tree> + </field> + </record> + + <record id="sale_monitoring_action" model="ir.actions.act_window"> + <field name="name">Sale Monitoring</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">sale.monitoring</field> + <field name="view_mode">tree</field> + </record> + +<!-- <menuitem--> +<!-- id="menu_sale_monitoring"--> +<!-- name="Sale Monitoring"--> +<!-- parent="purchase.menu_purchase_root"--> +<!-- sequence="100"--> +<!-- action="sale_monitoring_action"--> +<!-- />--> + + <menuitem + id="menu_sale_monitoring" + name="Sale Monitoring" + parent="sale.sale_menu_root" + sequence="100" + action="sale_monitoring_action" + /> + +<!-- <menuitem--> +<!-- id="menu_sale_monitoring"--> +<!-- name="Sale Monitoring"--> +<!-- parent="stock.menu_stock_root"--> +<!-- sequence="5"--> +<!-- action="sale_monitoring_action"--> +<!-- />--> + +</odoo>
\ No newline at end of file |
