[FIX] mrp: respect picking type option
The `use_create_components_lots` option of manufacturing picking type was never read as the context to get the active production order was not always specified. Also, this field was not taken into account to display or not the 'generate serial' and import 'lot buttons' closes odoo/odoo#162581 Related: odoo/enterprise#61137 Signed-off-by: Quentin Wolfs (quwo) <quwo@odoo.com>
This commit is contained in:
@@ -245,6 +245,16 @@ class StockMove(models.Model):
|
||||
super()._compute_show_info()
|
||||
self.filtered(lambda m: m.byproduct_id or m in self.production_id.move_finished_ids).show_quant = False
|
||||
|
||||
@api.depends('picking_type_id.use_create_components_lots')
|
||||
def _compute_display_assign_serial(self):
|
||||
super()._compute_display_assign_serial()
|
||||
for move in self:
|
||||
if move.display_import_lot \
|
||||
and move.raw_material_production_id \
|
||||
and not move.raw_material_production_id.picking_type_id.use_create_components_lots:
|
||||
move.display_import_lot = False
|
||||
move.display_assign_serial = False
|
||||
|
||||
@api.onchange('product_uom_qty')
|
||||
def _onchange_product_uom_qty(self):
|
||||
if self.raw_material_production_id and self.has_tracking == 'none':
|
||||
|
||||
@@ -363,7 +363,7 @@
|
||||
<page string="Components" name="components">
|
||||
<field name="move_raw_ids"
|
||||
widget="mrp_production_components_x2many"
|
||||
context="{'default_date': date_start, 'default_date_deadline': date_start, 'default_location_id': location_src_id, 'default_location_dest_id': production_location_id, 'default_warehouse_id': warehouse_id, 'default_state': 'draft', 'default_raw_material_production_id': id, 'default_picking_type_id': picking_type_id, 'default_company_id': company_id, 'form_view_ref': 'stock.view_stock_move_operations'}"
|
||||
context="{'default_date': date_start, 'default_date_deadline': date_start, 'default_location_id': location_src_id, 'default_location_dest_id': production_location_id, 'default_warehouse_id': warehouse_id, 'default_state': 'draft', 'default_raw_material_production_id': id, 'default_picking_type_id': picking_type_id, 'default_company_id': company_id, 'form_view_ref': 'stock.view_stock_move_operations', 'active_mo_id': id}"
|
||||
readonly="state == 'cancel' or (state == 'done' and is_locked)" options="{'delete': [('state', '=', 'draft')]}">
|
||||
<tree default_order="is_done, manual_consumption desc, sequence" editable="bottom">
|
||||
<field name="product_id" force_save="1" context="{'default_detailed_type': 'product'}" required="1" readonly="move_lines_count > 0 or state == 'cancel' or (state != 'draft' and not additional)" domain="['&', ('type', 'in', ['product', 'consu']), ('id', '!=', parent.product_id)]"/>
|
||||
|
||||
Reference in New Issue
Block a user