[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
This commit is contained in:
@@ -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()):
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user