Skip to content

[16.0[IMP]account_commission: add payment date limit on settle commissions#588

Merged
OCA-git-bot merged 1 commit into
OCA:16.0from
odooNextev:16.0-imp-account_commission
Jun 27, 2025
Merged

[16.0[IMP]account_commission: add payment date limit on settle commissions#588
OCA-git-bot merged 1 commit into
OCA:16.0from
odooNextev:16.0-imp-account_commission

Conversation

@matteotognini

@matteotognini matteotognini commented Dec 20, 2024

Copy link
Copy Markdown

Porting #441

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @pedrobaeza,
some modules you are maintaining are being modified, check this out!

@matteotognini matteotognini force-pushed the 16.0-imp-account_commission branch from ba276da to 50f6a32 Compare December 20, 2024 10:21
@matteotognini matteotognini changed the title [IMP]account_commission: possibility to add payment date limit on set… [16.0[IMP]account_commission: add payment date limit on settle commissions Dec 20, 2024

@PicchiSeba PicchiSeba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code review

"""
self.ensure_one()
payment_based_commission = (
True if self.commission_id.invoice_state == "paid" else False

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick: this expression could be simplified

Suggested change
True if self.commission_id.invoice_state == "paid" else False
self.commission_id.invoice_state == "paid"

@matteotognini matteotognini force-pushed the 16.0-imp-account_commission branch from 50f6a32 to 8a9338b Compare December 20, 2024 10:56

@odooNextev odooNextev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

Comment on lines +57 to +59
context_date_payment = self.env.context.copy()
context_date_payment["date_payment_to"] = self.date_payment_to
self.env.context = context_date_payment

@PicchiSeba PicchiSeba Feb 28, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

question: aren't these operations equivalent to

self.env.context["date_payment_to"] = self.date_payment_to

?

Or am I missing something?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi @PicchiSeba, self.env.context is a frozendict, which is an immutable dictionary. Because of this, I couldn't add self.date_payment_to directly as you suggested.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please use with_context decorator instead of a hard replacement of this type, as it's not guaranteed that the internal implementation will work with this kind of operations.

@PicchiSeba PicchiSeba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code review: LGTM

@matteotognini

Copy link
Copy Markdown
Author

@pedrobaeza What do you think? is it possible to merge?

@pedrobaeza pedrobaeza added this to the 16.0 milestone Mar 3, 2025
Comment on lines +57 to +59
context_date_payment = self.env.context.copy()
context_date_payment["date_payment_to"] = self.date_payment_to
self.env.context = context_date_payment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please use with_context decorator instead of a hard replacement of this type, as it's not guaranteed that the internal implementation will work with this kind of operations.

@matteotognini matteotognini force-pushed the 16.0-imp-account_commission branch from 4ad98ba to d5c0a62 Compare March 3, 2025 08:28
@PicchiSeba

Copy link
Copy Markdown
Contributor

Please use with_context decorator instead of a hard replacement of this type, as it's not guaranteed that the internal implementation will work with this kind of operations.

@pedrobaeza

Shouldn't we prefer this approach instead of with_context? The old context would be discarded entirely

@pedrobaeza

Copy link
Copy Markdown
Member

No, with_context can have an entire dict as argument or just a context key. Depending on which you select, you will have a replacement or just a new/edited key.


def action_settle(self):
self = self.with_context(date_payment_to=self.date_payment_to)
return super().action_settle()

@TheMule71 TheMule71 Apr 10, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this covered by a test?
My doubt is that self gets reassigned locally. I'm not sure that super() w/o arguments uses local self. So I'm not sure it works.

I'd suggest the explicit syntax:

return super(CommissionMakeSettle, self).action_settle()

to make sure that it's the modified self that gets used.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi @TheMule71, thanks for your review. I've just added a coverage test and it seems to work properly as it is now. Do you think it's better to make the syntax more explicit, as you mentioned? Thanks!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No, it's not necessary.

@matteotognini matteotognini force-pushed the 16.0-imp-account_commission branch from d5c0a62 to 3a9c534 Compare April 10, 2025 09:22
@matteotognini

Copy link
Copy Markdown
Author

@pedrobaeza merge?

@pedrobaeza

Copy link
Copy Markdown
Member

This is adding a bit of complication on the module for a specific case, but it's not too much overhead and it's tested, so let's continue.

/ocabot merge minor

@OCA-git-bot

Copy link
Copy Markdown
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 16.0-ocabot-merge-pr-588-by-pedrobaeza-bump-minor, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 6d215fa into OCA:16.0 Jun 27, 2025
2 of 3 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at de7708e. 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.

6 participants