Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] rma_sale: Fix problems with link between RMA-sale.order and procurement.group-sale.order when creating from stock.picking.return wizard #415

Open
wants to merge 2 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions rma/wizard/stock_picking_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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):
Expand Down Expand Up @@ -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})
Comment on lines +127 to +130
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @TheClaud99 ,

IMO, the issue is due to the non-unified of procurement groups creation.

When the picking return wizard is used, one procurement group is created for all RMAs. However, this is not the case when the sales order return wizard is used or when RMAs are created manually.

#423 addresses this issue by unifying the procurement group creation at RMA confirmation, regardless of the RMA origin.

I propose you revert these changes and keep the fix of the method name in rma_sale,

what do you think?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sbejaoui, I think it should be ok in your way as well (with also the advantage of having procurement.group creation unified), I can completely revert my commit 5f73bf6 and wait for your pr to be merged

rmas.action_confirm()
picking = rmas.reception_move_id.picking_id
picking = picking and picking[0] or picking
Expand Down
4 changes: 2 additions & 2 deletions rma_sale/wizard/stock_picking_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
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()

Check warning on line 21 in rma_sale/wizard/stock_picking_return.py

View check run for this annotation

Codecov / codecov/patch

rma_sale/wizard/stock_picking_return.py#L21

Added line #L21 was not covered by tests
sale_order = self.picking_id.sale_id
if sale_order:
vals.update(
Expand Down
Loading