[FIX] rma: default team and responsible

Having a default responsible value as it was defined doesn't behave
right when the user it's a portal one or the petition comes from a
sudo().

Also, by design it was expected to have a default team if it wasn't
defined, but as it was implemented that wasn't possible.

TT32056
This commit is contained in:
david
2021-09-23 16:32:21 +02:00
committed by Víctor Martínez
parent 000e4af9b3
commit dc839392e9

View File

@@ -50,7 +50,6 @@ class Rma(models.Model):
comodel_name="res.users",
string="Responsible",
index=True,
default=lambda self: self.env.user,
tracking=True,
states={"locked": [("readonly", True)], "cancelled": [("readonly", True)]},
)
@@ -509,7 +508,7 @@ class Rma(models.Model):
ir_sequence = ir_sequence.with_company(vals["company_id"])
vals["name"] = ir_sequence.next_by_code("rma")
# Assign a default team_id which will be the first in the sequence
if "team_id" not in vals:
if not vals.get("team_id"):
vals["team_id"] = self.env["rma.team"].search([], limit=1).id
rmas = super().create(vals_list)
# Send acknowledge when the RMA is created from the portal and the