Skip to content

[12.0][FIX] cooperator_eater: don't send mail if validation isn't succesfull#571

Merged
github-grap-bot merged 1 commit into12.0from
12.0-fix-no_mail_subscription_worker_with_parent
Feb 9, 2026
Merged

[12.0][FIX] cooperator_eater: don't send mail if validation isn't succesfull#571
github-grap-bot merged 1 commit into12.0from
12.0-fix-no_mail_subscription_worker_with_parent

Conversation

@mihien
Copy link
Copy Markdown
Contributor

@mihien mihien commented Dec 23, 2025

@mihien mihien changed the title [FIX] cooperator_eater: don't send mail if validation isn't succesfull [12.0][FIX] cooperator_eater: don't send mail if validation isn't succesfull Dec 23, 2025
@mihien mihien force-pushed the 12.0-fix-no_mail_subscription_worker_with_parent branch from 42a7e09 to f921a34 Compare January 7, 2026 16:01
Copy link
Copy Markdown
Collaborator

@remytms remytms left a comment

Choose a reason for hiding this comment

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

Change needed.

# the subscription and writing the partner as worker in db
partner = self.partner_id
if partner:
setattr(partner, "eater", "worker_eater")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why not using partner.eater = "worker_eater" ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If I understood/remember everything correctly, the problem was that partner.eater = "worker_eater" makes the changes directly in the db (and maybe trigger onchange behaviours, but I'm not sure anymore if that's not the case with setattr as well), which we don't want to happen before validating the subscription request. Using setattr willonly change the value in the current object and will raise an error if the new value is impossible, without doing any actual change in db

setattr(partner, "eater", "worker_eater")

invoice = super().validate_subscription_request()[0]
partner = invoice.partner_id
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Don’t remove this line. If self.partner_id is None then the invoice partner is another one (a found one or a newly created one).

Look here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops yes that's my bad, I don't think that one was intended

Comment on lines 23 to 32
# ensure partner can be changed to be a worker before both validating
# the subscription and writing the partner as worker in db
partner = self.partner_id
if partner:
setattr(partner, "eater", "worker_eater")

invoice = super().validate_subscription_request()[0]
partner = invoice.partner_id

vals = self.get_eater_vals(partner, self.share_product_id)
partner.write(vals)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think that this is not correct. We should look more deeply into the parent method.

self.partner_id is used only if not None.

As far as I know, the issue depends on the share product and the partner. The issue happen only if self.partner_id is not null and if the return of the method get_eater_vals() is "worker_eater" and self.partner_id.parent_eater_id is not null.

I would suggest something like that:

Suggested change
# ensure partner can be changed to be a worker before both validating
# the subscription and writing the partner as worker in db
partner = self.partner_id
if partner:
setattr(partner, "eater", "worker_eater")
invoice = super().validate_subscription_request()[0]
partner = invoice.partner_id
vals = self.get_eater_vals(partner, self.share_product_id)
partner.write(vals)
# if existing partner, ensure eater settings can be changed
# before validating the subscription request.
if self.partner_id:
vals = self.get_eater_vals(partner, self.share_product_id)
self.partner_id.write(vals)
invoice = super().validate_subscription_request()[0]
partner = invoice.partner_id
if partner != self.partner_id:
vals = self.get_eater_vals(partner, self.share_product_id)
partner.write(vals)

@mihien mihien force-pushed the 12.0-fix-no_mail_subscription_worker_with_parent branch from f921a34 to f1db7db Compare January 27, 2026 15:54
@mihien mihien requested a review from remytms January 27, 2026 16:22
Copy link
Copy Markdown
Collaborator

@remytms remytms left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the changes.

@remytms
Copy link
Copy Markdown
Collaborator

remytms commented Feb 9, 2026

/ocabot merge patch

@github-grap-bot
Copy link
Copy Markdown
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 12.0-ocabot-merge-pr-571-by-remytms-bump-patch, awaiting test results.

@github-grap-bot github-grap-bot merged commit c932580 into 12.0 Feb 9, 2026
4 checks passed
@github-grap-bot
Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 6f40b71. Thanks a lot for contributing to beescoop. ❤️

@github-grap-bot github-grap-bot deleted the 12.0-fix-no_mail_subscription_worker_with_parent branch February 9, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants