[FIX] mrp: hide m2m serials column in draft or if components are not

tracked

On production order view, dot not show the Serial Numbers column
when in draft or when no component tracked by serial number

closes odoo/odoo#56889

X-original-commit: 4fc8374ee4470a05b27216999e341418e72f28ea
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
JF Aubert
2020-09-01 12:50:22 +00:00
committed by Arnold Moyaux
parent 41c0f7c7dd
commit 9d77062ddb
2 changed files with 8 additions and 1 deletions
+6
View File
@@ -255,6 +255,7 @@ class MrpProduction(models.Model):
('available', 'Available'),
('expected', 'Expected'),
('late', 'Late')], compute='_compute_components_availability')
show_lot_ids = fields.Boolean('Display the serial number shortcut on the moves', compute='_compute_show_lot_ids')
@api.depends('product_id', 'bom_id', 'company_id')
def _compute_allowed_product_ids(self):
@@ -518,6 +519,11 @@ class MrpProduction(models.Model):
for order in self:
order.show_lock = self.env.user.has_group('mrp.group_locked_by_default') and order.id is not False and order.state not in {'cancel', 'draft'}
@api.depends('state','move_raw_ids')
def _compute_show_lot_ids(self):
for order in self:
order.show_lot_ids = order.state != 'draft' and any(m.product_id.tracking == 'serial' for m in order.move_raw_ids)
_sql_constraints = [
('name_uniq', 'unique(name, company_id)', 'Reference must be unique per Company!'),
('qty_positive', 'check (product_qty > 0)', 'The quantity to produce must be positive!'),
+2 -1
View File
@@ -142,6 +142,7 @@
<group>
<field name="id" invisible="1"/>
<field name="use_create_components_lots" invisible="1"/>
<field name="show_lot_ids" invisible="1"/>
<field name="allowed_product_ids" invisible="1"/>
<field name="product_tracking" invisible="1"/>
<field name="product_id" context="{'default_type': 'product'}" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
@@ -271,7 +272,7 @@
<field name="show_details_visible" invisible="1"/>
<field name="lot_ids" widget="many2many_tags"
groups="stock.group_production_lot"
attrs="{'invisible': ['|', '|', ('show_details_visible', '=', False), ('has_tracking', '!=', 'serial'), ('parent.state', '=', 'draft')]}"
attrs="{'invisible': ['|', '|', ('show_details_visible', '=', False), ('has_tracking', '!=', 'serial'), ('parent.state', '=', 'draft')], 'column_invisible': [('parent.show_lot_ids', '=', False)]}"
options="{'create': [('parent.use_create_components_lots', '!=', False)]}"
context="{'default_company_id': company_id, 'default_product_id': product_id}"
domain="[('product_id','=',product_id)]"