[FIX] mrp : prevent traceback while operation use in bom
When Operation is 'Archive' and it is still in use as 'Consumed in Operation' in bom while creating Manufacturing Order and confirming it, KeyError will be generated. Steps to Produce:- 1) Create a new product, create bom for that product, add components, and create or add at least 2 operations to the BoM. 2) In the components of 'Consumed in Operation' add the newly created operation. 3) Now, Archive one operation. 4) Create new Manufacturing Order with a newly created BOM 5) Try to confirm it. KeyError will be generated. By applying this commit, if there are no operations left after archiving one linked to the component then the server error won't occur sentry - 4042593205 closes odoo/odoo#119098 X-original-commit: ba2364f9188ff44c68a1b86d5029884815a33216 Signed-off-by: Tiffany Chang <tic@odoo.com>
This commit is contained in:
@@ -105,6 +105,12 @@ class MrpRoutingWorkcenter(models.Model):
|
||||
if not self._check_m2m_recursion('blocked_by_operation_ids'):
|
||||
raise ValidationError(_("You cannot create cyclic dependency."))
|
||||
|
||||
def action_archive(self):
|
||||
res = super().action_archive()
|
||||
bom_lines = self.env['mrp.bom.line'].search([('operation_id', 'in', self.ids)])
|
||||
bom_lines.write({'operation_id': False})
|
||||
return res
|
||||
|
||||
def copy_to_bom(self):
|
||||
if 'bom_id' in self.env.context:
|
||||
bom_id = self.env.context.get('bom_id')
|
||||
|
||||
Reference in New Issue
Block a user