mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
[IMP] rma: optionally group returns to customer
TT34806
This commit is contained in:
committed by
Nikolaus Weingartmair
parent
2f15018b66
commit
b3f901c949
@@ -25,6 +25,10 @@ class Company(models.Model):
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
rma_return_grouping = fields.Boolean(
|
||||
string="Group RMA returns by customer address and warehouse",
|
||||
default=True,
|
||||
)
|
||||
send_rma_confirmation = fields.Boolean(
|
||||
string="Send RMA Confirmation",
|
||||
help="When the delivery is confirmed, send a confirmation email "
|
||||
|
||||
@@ -11,6 +11,10 @@ class ResConfigSettings(models.TransientModel):
|
||||
help="Allow to finish an RMA without returning back a product or refunding",
|
||||
implied_group="rma.group_rma_manual_finalization",
|
||||
)
|
||||
rma_return_grouping = fields.Boolean(
|
||||
related="company_id.rma_return_grouping",
|
||||
readonly=False,
|
||||
)
|
||||
send_rma_confirmation = fields.Boolean(
|
||||
related="company_id.send_rma_confirmation",
|
||||
readonly=False,
|
||||
|
||||
@@ -1088,6 +1088,9 @@ class Rma(models.Model):
|
||||
# Returning business methods
|
||||
def create_return(self, scheduled_date, qty=None, uom=None):
|
||||
"""Intended to be invoked by the delivery wizard"""
|
||||
group_returns = self.env.company.rma_return_grouping
|
||||
if "rma_return_grouping" in self.env.context:
|
||||
group_returns = self.env.context.get("rma_return_grouping")
|
||||
self._ensure_can_be_returned()
|
||||
self._ensure_qty_to_return(qty, uom)
|
||||
group_dict = {}
|
||||
@@ -1100,7 +1103,11 @@ class Rma(models.Model):
|
||||
)
|
||||
group_dict.setdefault(key, self.env["rma"])
|
||||
group_dict[key] |= record
|
||||
for rmas in group_dict.values():
|
||||
if group_returns:
|
||||
grouped_rmas = group_dict.values()
|
||||
else:
|
||||
grouped_rmas = rmas_to_return
|
||||
for rmas in grouped_rmas:
|
||||
origin = ", ".join(rmas.mapped("name"))
|
||||
rma_out_type = rmas[0].warehouse_id.rma_out_type_id
|
||||
picking_form = Form(
|
||||
|
||||
Reference in New Issue
Block a user