From e0059ad5958ec7703fe3fabce9e55defd950e235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Voet=20=28ryv=29?= Date: Tue, 16 Jun 2020 12:37:06 +0000 Subject: [PATCH] [FIX] mrp: singleton issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix singleton error when trying to backorder several MO task-2278147 closes odoo/odoo#53078 X-original-commit: 3a317ccd3fe407f732607343ca5ce351602b56e7 Signed-off-by: Arnold Moyaux Signed-off-by: Rémy Voet --- addons/mrp/models/mrp_production.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 9af4de81d68..6b60b81ec23 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -1318,17 +1318,18 @@ class MrpProduction(models.Model): return name[:-SIZE_BACK_ORDER_NUMERING-1] + seq_back return name + seq_back - def _get_backorder_mo_vals(self, mo_source): - next_seq = max(mo_source.procurement_group_id.mrp_production_ids.mapped("backorder_sequence")) + def _get_backorder_mo_vals(self): + self.ensure_one() + next_seq = max(self.procurement_group_id.mrp_production_ids.mapped("backorder_sequence")) return { - 'name': self._get_name_backorder(mo_source.name, next_seq + 1), + 'name': self._get_name_backorder(self.name, next_seq + 1), 'backorder_sequence': next_seq + 1, - 'procurement_group_id': mo_source.procurement_group_id.id, + 'procurement_group_id': self.procurement_group_id.id, 'move_raw_ids': None, 'move_finished_ids': None, 'product_qty': self._get_quantity_to_backorder(), 'lot_producing_id': False, - 'origin': mo_source.origin + 'origin': self.origin } def _generate_backorder_productions(self, close_mo=True): @@ -1336,7 +1337,7 @@ class MrpProduction(models.Model): for production in self: if production.backorder_sequence == 0: # Activate backorder naming production.backorder_sequence = 1 - backorder_mo = production.copy(default=self._get_backorder_mo_vals(production)) + backorder_mo = production.copy(default=production._get_backorder_mo_vals()) if close_mo: production.move_raw_ids.filtered(lambda m: m.state not in ('done', 'cancel')).write({ 'raw_material_production_id': backorder_mo.id,