From 5f73bf6b5e962a30502b3d802c91142b56aae0f9 Mon Sep 17 00:00:00 2001 From: claudio-mano Date: Tue, 20 Aug 2024 09:28:41 +0200 Subject: [PATCH] [FIX] rma_sale: sale_id not assigned to procurement_group when creating from stock.picking return wizard --- rma/wizard/stock_picking_return.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/rma/wizard/stock_picking_return.py b/rma/wizard/stock_picking_return.py index 7c7ca3649..761931397 100644 --- a/rma/wizard/stock_picking_return.py +++ b/rma/wizard/stock_picking_return.py @@ -80,10 +80,6 @@ def _prepare_rma_partner_values(self): def _prepare_rma_vals(self): partner, partner_invoice, partner_shipping = self._prepare_rma_partner_values() origin = self.picking_id.name - vals = self.env["rma"]._prepare_procurement_group_vals() - vals["partner_id"] = partner_shipping.id - vals["name"] = origin - group = self.env["procurement.group"].create(vals) return { "user_id": self.env.user.id, "partner_id": partner.id, @@ -92,7 +88,6 @@ def _prepare_rma_vals(self): "origin": origin, "picking_id": self.picking_id.id, "company_id": self.company_id.id, - "procurement_group_id": group.id, } def _prepare_rma_vals_list(self): @@ -129,6 +124,10 @@ def create_returns(self): ) vals_list = self._prepare_rma_vals_list() rmas = self.env["rma"].create(vals_list) + proc_group_vals = rmas[:1]._prepare_procurement_group_vals() + proc_group_vals["name"] = self.picking_id.name + proc_group = self.env["procurement.group"].create(proc_group_vals) + rmas.write({"procurement_group_id": proc_group.id}) rmas.action_confirm() picking = rmas.reception_move_id.picking_id picking = picking and picking[0] or picking