diff --git a/addons/mrp_subcontracting/models/stock_move.py b/addons/mrp_subcontracting/models/stock_move.py index c8e1ff04535..2b39d23f677 100644 --- a/addons/mrp_subcontracting/models/stock_move.py +++ b/addons/mrp_subcontracting/models/stock_move.py @@ -16,6 +16,17 @@ class StockMove(models.Model): compute='_compute_show_subcontracting_details_visible' ) + def _compute_display_assign_serial(self): + super(StockMove, self)._compute_display_assign_serial() + for move in self: + if not move.is_subcontract: + continue + productions = move._get_subcontract_production() + if not productions or move.has_tracking != 'serial': + continue + if productions._has_tracked_component() or productions[:1].consumption != 'strict': + move.display_assign_serial = False + def _compute_show_subcontracting_details_visible(self): """ Compute if the action button in order to see moves raw is visible """ self.show_subcontracting_details_visible = False @@ -40,7 +51,8 @@ class StockMove(models.Model): if self.env.user.has_group('base.group_portal'): move.show_details_visible = any(not p._has_been_recorded() for p in move._get_subcontract_production()) continue - if not move._get_subcontract_production()._has_tracked_component(): + productions = move._get_subcontract_production() + if not productions._has_tracked_component() and productions[:1].consumption == 'strict': continue move.show_details_visible = True return res @@ -83,7 +95,7 @@ class StockMove(models.Model): subcontracted product. Otherwise use standard behavior. """ self.ensure_one() - if self._subcontrating_should_be_record() or self._subcontrating_can_be_record(): + if self.state != 'done' and (self._subcontrating_should_be_record() or self._subcontrating_can_be_record()): return self._action_record_components() action = super(StockMove, self).action_show_details() if self.is_subcontract and all(p._has_been_recorded() for p in self._get_subcontract_production()): diff --git a/addons/mrp_subcontracting/models/stock_picking.py b/addons/mrp_subcontracting/models/stock_picking.py index 66001062a44..9f04ce685a0 100644 --- a/addons/mrp_subcontracting/models/stock_picking.py +++ b/addons/mrp_subcontracting/models/stock_picking.py @@ -13,6 +13,13 @@ class StockPicking(models.Model): _name = 'stock.picking' _inherit = 'stock.picking' + # override existing field domains to prevent suboncontracting production lines from showing in Detailed Operations tab + move_line_nosuggest_ids = fields.One2many( + domain=['&', '|', ('location_dest_id.usage', '!=', 'production'), ('move_id.picking_code', '!=', 'outgoing'), + '|', ('reserved_qty', '=', 0.0), '&', ('reserved_qty', '!=', 0.0), ('qty_done', '!=', 0.0)]) + move_line_ids_without_package = fields.One2many( + domain=['&', '|', ('location_dest_id.usage', '!=', 'production'), ('move_id.picking_code', '!=', 'outgoing'), + '|', ('package_level_id', '=', False), ('picking_type_entire_packs', '=', False)]) display_action_record_components = fields.Selection( [('hide', 'Hide'), ('facultative', 'Facultative'), ('mandatory', 'Mandatory')], compute='_compute_display_action_record_components')