diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-10-17 11:19:23 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-10-17 11:19:23 +0700 |
| commit | 464e80d0cb180335dada9878272c62f5db9b9e73 (patch) | |
| tree | fbdca740cfcdded0fcb90048f6d61b8461885320 | |
| parent | eefe129e31b112d80038fc3aecf2aee4c4e10108 (diff) | |
product monitoring
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 3 | ||||
| -rw-r--r-- | indoteknik_custom/models/product_monitoring.py | 35 | ||||
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 4 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 3 | ||||
| -rw-r--r-- | indoteknik_custom/views/product_monitoring.xml | 55 |
6 files changed, 99 insertions, 2 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 6ae60345..23abc084 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -98,6 +98,7 @@ 'views/sale_orders_multi_update.xml', 'views/quotation_so_multi_update.xml', 'views/stock_move_line.xml', + 'views/product_monitoring.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 95defed6..1133c3e7 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -88,4 +88,5 @@ from . import account_move_line from . import stock_scheduler_compute from . import promotion from . import sale_orders_multi_update -from . import quotation_so_multi_update
\ No newline at end of file +from . import quotation_so_multi_update +from . import product_monitoring
\ No newline at end of file diff --git a/indoteknik_custom/models/product_monitoring.py b/indoteknik_custom/models/product_monitoring.py new file mode 100644 index 00000000..df9701ab --- /dev/null +++ b/indoteknik_custom/models/product_monitoring.py @@ -0,0 +1,35 @@ +from odoo import models, fields, tools, api + +class ProductMonitoring(models.Model): + _name = 'product.monitoring' + _auto = False + _rec_name = 'product_id' + + id = fields.Integer() + product_id = fields.Many2one('product.product', string='Product') + outgoing_qty = fields.Float(string="Outgoing", related='product_id.outgoing_qty') + incoming_qty = fields.Float(string="Incoming", related='product_id.incoming_qty') + qty_available = fields.Float(string="On Hand", related='product_id.qty_available') + qty_upcoming = fields.Float(string="Upcoming", related='product_id.qty_upcoming') + status_stock = fields.Selection([ + ('outgoing_gt_stock', 'Outgoing > Stock'), + ('outgoing_lt_stock', 'Outgoing < Stock'), + ], string="Status Stock", compute='_compute_status_stock') + + def _compute_status_stock(self): + for product in self: + product.status_stock = 'outgoing_lt_stock' if product.outgoing_qty <= product.qty_upcoming else 'outgoing_gt_stock' + + def init(self): + tools.drop_view_if_exists(self.env.cr, self._table) + self.env.cr.execute(""" + CREATE OR REPLACE VIEW %s AS ( + SELECT + sm.product_id AS id, + sm.product_id AS product_id + FROM stock_move sm + LEFT JOIN stock_picking sp ON sm.picking_id = sp.id + WHERE sp.state NOT IN ('cancel', 'done') AND sm.product_id IS NOT null + GROUP BY sm.product_id + ) + """ % self._table)
\ No newline at end of file diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index fb8561e7..e69d6044 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -329,8 +329,12 @@ class ProductProduct(models.Model): material = fields.Char(string='Material') qty_onhand_bandengan = fields.Float(string='Qty Incoming Bandengan', compute='_get_qty_onhand_bandengan') qty_incoming_bandengan = fields.Float(string='Qty Incoming Bandengan', compute='_get_qty_incoming_bandengan') + qty_upcoming = fields.Float(string='Qty Upcoming', compute='_get_qty_upcoming') sla_version = fields.Integer(string="SLA Version", default=0) is_edited = fields.Boolean(string='Is Edited') + def _get_qty_upcoming(self): + for product in self: + product.qty_upcoming = product.incoming_qty + product.qty_available def day_product_to_edit(self): day_products = [] diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index e362e546..7a074c71 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -77,4 +77,5 @@ access_cost_centre,access.cost.centre,model_cost_centre,,1,1,1,1 access_stock_scheduler_compute,access.stock.scheduler.compute,model_stock_scheduler_compute,,1,1,1,1 access_sale_order_promotion,access.sale.order.promotion,model_sale_order_promotion,,1,1,1,1 access_sale_orders_multi_update,access.sale.orders.multi_update,model_sale_orders_multi_update,,1,1,1,1 -access_quotation_so_multi_update,access.quotation.so.multi_update,model_quotation_so_multi_update,,1,1,1,1
\ No newline at end of file +access_quotation_so_multi_update,access.quotation.so.multi_update,model_quotation_so_multi_update,,1,1,1,1 +access_product_monitoring,access.product.monitoring,model_product_monitoring,,1,1,1,1
\ No newline at end of file diff --git a/indoteknik_custom/views/product_monitoring.xml b/indoteknik_custom/views/product_monitoring.xml new file mode 100644 index 00000000..779a7dd7 --- /dev/null +++ b/indoteknik_custom/views/product_monitoring.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="utf-8" ?> +<odoo> + <record id="product_monitoring_tree" model="ir.ui.view"> + <field name="name">product.monitoring.tree</field> + <field name="model">product.monitoring</field> + <field name="arch" type="xml"> + <tree create="false" multi_edit="1"> + <field name="product_id"/> + <field name="outgoing_qty"/> + <field name="incoming_qty"/> + <field name="qty_available"/> + <field name="qty_upcoming"/> + <field name="status_stock" + widget="badge" + decoration-danger="status_stock == 'outgoing_gt_stock'" + decoration-success="status_stock == 'outgoing_lt_stock'" + /> + </tree> + </field> + </record> + + <record id="product_monitoring_form" model="ir.ui.view"> + <field name="name">product.monitoring.form</field> + <field name="model">product.monitoring</field> + <field name="arch" type="xml"> + <form create="false" edit="false"> + <sheet> + <group> + <group> + <field name="product_id"/> + <field name="outgoing_qty"/> + <field name="incoming_qty"/> + <field name="qty_available"/> + </group> + </group> + </sheet> + </form> + </field> + </record> + + <record id="product_monitoring_action" model="ir.actions.act_window"> + <field name="name">Product Monitoring</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">product.monitoring</field> + <field name="view_mode">tree,form</field> + </record> + + <menuitem + id="menu_product_monitoring_in_purchase" + name="Product Monitoring" + parent="menu_monitoring_in_purchase" + sequence="1" + action="product_monitoring_action" + /> +</odoo>
\ No newline at end of file |
