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

[16.0][IMP] cooperator: Don't send attachment if no remaining shares #3

Merged

Conversation

carmenbianca
Copy link
Member

@carmenbianca carmenbianca commented Oct 30, 2023

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.

the code seems correct, with some nice refactoring. thanks for this!

currently, all computation of share quantities are done directly on the partner. please note that res.partner.share_ids lists all share.line records linked to the partner, across all companies, which makes this code not multi-company-compatible. this would be a good chance to fix this. instead of using res.partner, use the explicit cooperative.membership linked to the company_id of the operation.request (using res.partner.get_cooperative_membership()).

cooperator/data/mail_template_data.xml Outdated Show resolved Hide resolved
cooperator/models/res_partner.py Outdated Show resolved Hide resolved
cooperator/models/res_partner.py Outdated Show resolved Hide resolved
@@ -283,3 +285,21 @@ def create_cooperative_membership(self, company_id):
}
)
return result

def get_share_quantities(self):
Copy link
Member

Choose a reason for hiding this comment

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

i think that this should better be defined on cooperative.membership, as this is different per company.

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 did this, but I couldn't really get around keeping a wrapper method in res.partner. This method was/is called from operation.request, which has a partner_id and a company_id, but not a cooperative_membership_id.

I could do something like self.partner_id.with_company(self.company_id).cooperative_membership_id.get_share_quantities(), but that seemed utterly absurd to me. Instead I do self.partner_id.get_share_quantities(self.company_id), which quietly does the latter for me.

cooperator/tests/test_mail_templates.py Show resolved Hide resolved
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.

one extra test needed, otherwise lgtm!

Comment on lines 320 to 345
def test_mail_template_share_transfer_all_shares(self):
"""Test that executing a share transfer wherein all shares are
transferred sends a message with no certificate in attachment.
"""
self._test_mail_template_share_transfer_all_shares(
self.create_dummy_cooperator(), self.get_dummy_subscription_requests_vals()
)

Copy link
Member

Choose a reason for hiding this comment

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

could you please add a test for a company cooperator?

@huguesdk huguesdk force-pushed the 16.0-cooperator-no-shares-no-certificate branch from 0a4e1b5 to 4391d32 Compare November 28, 2023 08:47
@huguesdk huguesdk force-pushed the 16.0-cooperator-no-shares-no-certificate branch from 4391d32 to a01a374 Compare November 28, 2023 12:28
@huguesdk huguesdk force-pushed the 16.0-cooperator-no-shares-no-certificate branch from a01a374 to fd98a75 Compare November 29, 2023 13:44
@huguesdk huguesdk merged commit fd98a75 into 16.0-mig-cooperator Nov 29, 2023
3 of 4 checks passed
@huguesdk huguesdk deleted the 16.0-cooperator-no-shares-no-certificate branch November 29, 2023 13:44
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