Skip to content

Commit

Permalink
[FIX] eater: Improve English, fix check
Browse files Browse the repository at this point in the history
The check wasn't quite right (it compared the recordset to an id).

The English was also really bad. Patched that up.

Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
  • Loading branch information
carmenbianca committed Oct 9, 2023
1 parent f6ce325 commit 5b1dfaf
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions eater/models/partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,21 @@ def _check_parent_is_worker(self):
def write(self, values):
if values.get("parent_eater_id"):
for partner in self:
if partner.parent_eater_id and partner.parent_eater_id != values.get(
"parent_eater_id"
if (
partner.parent_eater_id
and partner.parent_eater_id.id != values.get("parent_eater_id")
):
raise ValidationError(
_(
"You try to assign a eater to a partner but this eater "
"is already assign to %s please remove it before "
"You are trying to assign %(eater)s as an eater to"
" a new partner, but this eater is already"
" assigned to %(old_partner)s. Please remove the link"
" before creating a new one."
)
% partner.parent_eater_id.name
% {
"eater": partner.name,
"old_partner": partner.parent_eater_id.name,
}
)
return super().write(values)

Expand Down

0 comments on commit 5b1dfaf

Please sign in to comment.