From b463ae62d26b0beea437a08d374bf273c491c635 Mon Sep 17 00:00:00 2001 From: "Tiffany Chang (tic)" Date: Wed, 11 May 2022 16:04:22 +0000 Subject: [PATCH] [FIX] mrp_subcontracting: correct UX behavior Fixes a few incorrect subcontracting UX behaviors: - When subcontract BOM is flexible, the record burger should always show so user can more easily record varying quantities - When `show_operations=True` then `action_assign_serial` button in Operations tab should only show if subcontract BOM is NOT strict AND has no tracked components (instead of always showing regardless of BoM consumption and its components) - When a subcontract receipt is backordered, the Done moves should no longer return `_action_record_components`. - When 'show_operations=True' for receipts, we shouldn't display the subcontracting component lines in the Detailed Operations tab Task: 2777571 X-original-commit: e9b9fe541df984bba33c4f44d48e57820ea4968f Part-of: odoo/odoo#97383 --- addons/mrp_subcontracting/models/stock_move.py | 16 ++++++++++++++-- .../mrp_subcontracting/models/stock_picking.py | 7 +++++++ 2 files changed, 21 insertions(+), 2 deletions(-) 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')