[FIX] mrp: confirm MO with deleted WO
If there are some dependencies between BoM's operations, a traceback will appear when the user removes one WO. Steps to produce: - From Manufacturing > Configuration: Enable Work Orders. - Open any Bills of Material. - In 'Miscellaneous' tab tick the 'Operation Dependencies' boolean. - Set 3 or more operations in the 'Operations' tab. - After saving the BOM add 'Blocked By' in the operations. - Now Create Manufacturing Order for that BOM. - Delete the one or more workorder(s) from mrp order. - Now click on the 'Confirm' button, and the error will be raised. The loop is incorrect because we iterate on the BoM's operations but the keys of the dict `workorder_per_operation` are based on the MO's work orders. Therefore, if we remove one WO, the dict will not have any key for the related operation, hence the traceback. sentry-4146643254 closes odoo/odoo#125990 X-original-commit: 15366af1774a571548a9c35e7dd8acbdc16ba71f Related: odoo/enterprise#42957 Signed-off-by: Adrien Widart (awt) <awt@odoo.com> Signed-off-by: Parth Solanki (paso) <paso@odoo.com>
This commit is contained in:
@@ -1353,7 +1353,10 @@ class MrpProduction(models.Model):
|
||||
self.allow_workorder_dependencies = self.bom_id.allow_operation_dependencies
|
||||
if self.allow_workorder_dependencies:
|
||||
for workorder in self.workorder_ids:
|
||||
workorder.blocked_by_workorder_ids = [Command.link(workorder_per_operation[operation_id].id) for operation_id in workorder.operation_id.blocked_by_operation_ids]
|
||||
workorder.blocked_by_workorder_ids = [Command.link(workorder_per_operation[operation_id].id)
|
||||
for operation_id in
|
||||
workorder.operation_id.blocked_by_operation_ids
|
||||
if operation_id in workorder_per_operation]
|
||||
if not workorder.needed_by_workorder_ids:
|
||||
last_workorder_per_bom[workorder.operation_id.bom_id] = workorder
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user