From c38703f4e49bca4f7609049c25a744d2dd80dfbb Mon Sep 17 00:00:00 2001 From: Hetal Dhanak Date: Fri, 24 May 2019 07:09:37 +0000 Subject: [PATCH 1/6] [IMP] stock: remove colors from Traceability Report Task-1943397 --- .../static/src/xml/stock_traceability_report_line.xml | 8 ++------ addons/stock/views/report_stock_traceability.xml | 5 ----- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/addons/stock/static/src/xml/stock_traceability_report_line.xml b/addons/stock/static/src/xml/stock_traceability_report_line.xml index 8db2d344084..fa39b9c3087 100644 --- a/addons/stock/static/src/xml/stock_traceability_report_line.xml +++ b/addons/stock/static/src/xml/stock_traceability_report_line.xml @@ -20,10 +20,6 @@ - - - - @@ -47,9 +43,9 @@ - + - + diff --git a/addons/stock/views/report_stock_traceability.xml b/addons/stock/views/report_stock_traceability.xml index 2863b3ac2ca..20936403bf0 100644 --- a/addons/stock/views/report_stock_traceability.xml +++ b/addons/stock/views/report_stock_traceability.xml @@ -13,9 +13,6 @@ - - - @@ -41,9 +38,7 @@ - - From 03abe6b4ae011c7d45458539760d3bcdc3c63db7 Mon Sep 17 00:00:00 2001 From: Hetal Dhanak Date: Fri, 24 May 2019 07:17:54 +0000 Subject: [PATCH 2/6] [IMP] mrp: update demo data Removed "Assembly station 1" from everywhere and replaced it with "Assemmbly Line 1". Renamed "Assembly station 2" to "Assembly Line 2". Task-1943397 --- addons/mrp/data/mrp_demo.xml | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/addons/mrp/data/mrp_demo.xml b/addons/mrp/data/mrp_demo.xml index 5c9311f332e..d488281865a 100644 --- a/addons/mrp/data/mrp_demo.xml +++ b/addons/mrp/data/mrp_demo.xml @@ -13,15 +13,6 @@ - - Assembly Station 1 - - 5 - 10 - 8 - 87 - - Assembly Line 1 @@ -33,7 +24,7 @@ - Assemble Station 2 + Assembly Line 2 @@ -62,7 +53,7 @@ - + Manual Assembly 60 5 @@ -71,7 +62,7 @@ - + Long time assembly 180 15 @@ -80,7 +71,7 @@ - + Testing 60 10 @@ -644,21 +635,21 @@ - + - + - + From b13dfb502ef3acc7a1a6b611755b2067d394795d Mon Sep 17 00:00:00 2001 From: Hetal Dhanak Date: Mon, 27 May 2019 07:20:16 +0000 Subject: [PATCH 3/6] [IMP] mrp: hide "operations" upon inactive advanced routes Task-1943397 --- addons/mrp/views/mrp_bom_views.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mrp/views/mrp_bom_views.xml b/addons/mrp/views/mrp_bom_views.xml index 7ffb50dde88..cb16d89224a 100644 --- a/addons/mrp/views/mrp_bom_views.xml +++ b/addons/mrp/views/mrp_bom_views.xml @@ -105,7 +105,7 @@ - + From ef977fe634f44f6599f13f514dbd16f7c8c33dec Mon Sep 17 00:00:00 2001 From: Hetal Dhanak Date: Mon, 27 May 2019 07:26:11 +0000 Subject: [PATCH 4/6] [IMP] mrp: hide "manufacturing readiness" upon inactive WO Task-1943397 --- addons/mrp/views/mrp_bom_views.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mrp/views/mrp_bom_views.xml b/addons/mrp/views/mrp_bom_views.xml index cb16d89224a..179e8a3d14c 100644 --- a/addons/mrp/views/mrp_bom_views.xml +++ b/addons/mrp/views/mrp_bom_views.xml @@ -101,10 +101,10 @@ + - From 71308383160c1d3f4be15880271d9cb1210740c3 Mon Sep 17 00:00:00 2001 From: Hetal Dhanak Date: Mon, 27 May 2019 07:28:48 +0000 Subject: [PATCH 5/6] [IMP] mrp: hide sequence field Task-1943397 --- addons/mrp/views/mrp_bom_views.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/mrp/views/mrp_bom_views.xml b/addons/mrp/views/mrp_bom_views.xml index 179e8a3d14c..c64dbee0ab9 100644 --- a/addons/mrp/views/mrp_bom_views.xml +++ b/addons/mrp/views/mrp_bom_views.xml @@ -100,7 +100,6 @@ - From 2f2ac551423ba5c746b7fedf0971a4ea25a04ab3 Mon Sep 17 00:00:00 2001 From: Hetal Dhanak Date: Fri, 24 May 2019 08:48:23 +0000 Subject: [PATCH 6/6] [IMP] stock: filter data for field 'product_id' in form view of 'stock.production.lot' previously in the selection field 'product_id' of 'stock.production.lot', all the products were always visible no matter from where this view was getting opened from. which is not ideal because if a user is creating a new lot for a specific product, i.e. let's say if he opens this view from 'product.template', he must not be able to select a product variant other than of the product itself. after this commit, if a user opens form view of 'stock.production.lot' by clicking on the menu action, all the products will be visible. if he opens it from product.template, only variants of the given products will be visible. if he opens it from product.product, only that particular variant will be visible and it will be readonly because there are no other valid values. Task-1943397 --- addons/stock/models/product.py | 8 ++++---- addons/stock/models/stock_production_lot.py | 9 ++++++++- addons/stock/views/stock_production_lot_views.xml | 4 +--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index cd838f35c93..0a0c6faf05a 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -471,7 +471,7 @@ class Product(models.Model): self.ensure_one() action = self.env.ref('stock.action_production_lot_form').read()[0] action['domain'] = [('product_id', '=', self.id)] - action['context'] = {'default_product_id': self.id} + action['context'] = {'default_product_id': self.id, 'set_product_readonly': True} return action # Be aware that the exact same function exists in product.template @@ -769,11 +769,11 @@ class ProductTemplate(models.Model): self.ensure_one() action = self.env.ref('stock.action_production_lot_form').read()[0] action['domain'] = [('product_id.product_tmpl_id', '=', self.id)] + action['context'] = {'default_product_tmpl_id': self.id} if self.product_variant_count == 1: - action['context'] = { + action['context'].update({ 'default_product_id': self.product_variant_id.id, - } - + }) return action def action_product_tmpl_forecast_report(self): diff --git a/addons/stock/models/stock_production_lot.py b/addons/stock/models/stock_production_lot.py index 82c50565c39..17f0275c84e 100644 --- a/addons/stock/models/stock_production_lot.py +++ b/addons/stock/models/stock_production_lot.py @@ -3,6 +3,7 @@ from odoo import api, fields, models, _ from odoo.exceptions import UserError +from odoo.osv import expression class ProductionLot(models.Model): @@ -16,7 +17,7 @@ class ProductionLot(models.Model): ref = fields.Char('Internal Reference', help="Internal reference number in case it differs from the manufacturer's lot/serial number") product_id = fields.Many2one( 'product.product', 'Product', - domain=[('type', '=', 'product')], required=True) + domain=lambda self: self._domain_product_id(), required=True) product_uom_id = fields.Many2one( 'uom.uom', 'Unit of Measure', related='product_id.uom_id', store=True, readonly=False) @@ -29,6 +30,12 @@ class ProductionLot(models.Model): ('name_ref_uniq', 'unique (name, product_id)', 'The combination of serial number and product must be unique !'), ] + def _domain_product_id(self): + domain = [('type', '=', 'product')] + if self.env.context.get('default_product_tmpl_id'): + domain = expression.AND([domain, [('product_tmpl_id', '=', self.env.context['default_product_tmpl_id'])]]) + return domain + def _check_create(self): active_picking_id = self.env.context.get('active_picking_id', False) if active_picking_id: diff --git a/addons/stock/views/stock_production_lot_views.xml b/addons/stock/views/stock_production_lot_views.xml index 7caf76f7dde..937cdde3dcf 100644 --- a/addons/stock/views/stock_production_lot_views.xml +++ b/addons/stock/views/stock_production_lot_views.xml @@ -21,9 +21,7 @@ - +