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 diff --git a/rma_sale/wizard/stock_picking_return.py b/rma_sale/wizard/stock_picking_return.py index f9bc5823a..a92965e19 100644 --- a/rma_sale/wizard/stock_picking_return.py +++ b/rma_sale/wizard/stock_picking_return.py @@ -17,8 +17,8 @@ def _prepare_rma_partner_values(self): sale_order.partner_shipping_id, ) - def _prepare_rma_values(self): - vals = super()._prepare_rma_values() + def _prepare_rma_vals(self): + vals = super()._prepare_rma_vals() sale_order = self.picking_id.sale_id if sale_order: vals.update(