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

[IMP] cooperator: Refactor cooperative.membership preparation code #101

Merged
merged 3 commits into from
Feb 1, 2024

Conversation

carmenbianca
Copy link
Member

There were two places where there was broadly the same workflow; set expected values on a partner's cooperative.membership after giving them a membership.

That code is now in one place, and does the following as per the docstring:

  • member is set to True and old_member is set to False.
  • A cooperator register number is assigned if one did not yet exist.
  • A user is created if one did not yet exist.

This desperately needs tests.

I also wrote an optional convenience functionality into res.partner's get_cooperative_membership: create one if it doesn't yet exist.


Internal task: https://gestion.coopiteasy.be/web#view_type=form&model=project.task&id=9652&active_id=9652&menu_id=

Copy link
Member

@huguesdk huguesdk left a comment

Choose a reason for hiding this comment

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

great refactoring! thanks @carmenbianca! as this is critical code, it’s important to cover all the cases with tests and run them first without the changes, to ensure that the current (valid) behaviors still work as expected.

@carmenbianca carmenbianca force-pushed the 16.0-refactor-partner-creation branch 2 times, most recently from efd4a26 to e820f17 Compare December 14, 2023 13:26
@@ -154,9 +89,6 @@ def set_cooperator_effective(self, effective_date):

self._send_certificate_mail(certificate_email_template, sub_reg_line)
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm a bit confused by this. Does this assume that the for-loop has one item?

@carmenbianca carmenbianca marked this pull request as ready for review December 14, 2023 15:53
Copy link
Member

@huguesdk huguesdk left a comment

Choose a reason for hiding this comment

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

wow, impressive changes! thanks a lot for these, carmen! lgtm, just one comment, up to you to decide.

sorry for the late review.

There were two places where there was broadly the same workflow; set
expected values on a partner's cooperative.membership after giving them
a membership.

That code is now in one place, and does the following as per the
docstring:

- ``member`` is set to True and ``old_member`` is set to False.
- A cooperator register number is assigned if one did not yet exist.
- A user is created if one did not yet exist.

I also wrote a convenience method get_create_cooperative_membership in
res.partner.

Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
…dress

Using the old method, it was possible (but unlikely) that a different
partner's user was affected by changes on the partner. So instead of
matching on the login address, match on the partner_id field.

As a result of this, the code had to be adjusted to handle multiple user
records.

Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
@carmenbianca carmenbianca force-pushed the 16.0-refactor-partner-creation branch from e820f17 to acd1472 Compare February 1, 2024 09:29
@carmenbianca
Copy link
Member Author

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 16.0-ocabot-merge-pr-101-by-carmenbianca-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 6eef0d9 into OCA:16.0 Feb 1, 2024
6 of 7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 36cbd02. Thanks a lot for contributing to OCA. ❤️

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