From dbc3b0b5d56e75605cb993d3c5622cab01cf16d7 Mon Sep 17 00:00:00 2001 From: uso-odoo Date: Fri, 17 Mar 2023 08:57:01 +0000 Subject: [PATCH] [FIX] mrp : prevent error when creating new record of mrp.workorder in tree view while we are creating a new record of the mrp.workorder from the editable list view (mrp_production_workorder_tree_editable_view), we are getting the singleton error, as it is not taking any production record. by applying this commit, it will resolve that singleton error sentry - 3982694755 closes odoo/odoo#115862 X-original-commit: 91e7d36a48d58aea1d63999dd150b543983aeba1 Signed-off-by: Tiffany Chang --- addons/mrp/models/mrp_workorder.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index 3b380d41921..edbf3ac0674 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -433,9 +433,10 @@ class MrpWorkorder(models.Model): @api.onchange('finished_lot_id') def _onchange_finished_lot_id(self): - res = self.production_id._can_produce_serial_number(sn=self.finished_lot_id) - if res is not True: - return res + if self.production_id: + res = self.production_id._can_produce_serial_number(sn=self.finished_lot_id) + if res is not True: + return res def write(self, values): if 'production_id' in values and any(values['production_id'] != w.production_id.id for w in self):