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 @@
-
+
-
+
-
+
diff --git a/addons/mrp/views/mrp_bom_views.xml b/addons/mrp/views/mrp_bom_views.xml
index 7ffb50dde88..c64dbee0ab9 100644
--- a/addons/mrp/views/mrp_bom_views.xml
+++ b/addons/mrp/views/mrp_bom_views.xml
@@ -100,12 +100,11 @@
-
+
-
-
+
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/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 @@
-
-
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 @@
-
+