-
-
Notifications
You must be signed in to change notification settings - Fork 980
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][FIX] sale_invoice_policy: re-structure module so that there is no need to change the original invoice_policy field #2763
Conversation
@ACheung-FactorLibre The fix should not be as this simple as the code depends on the context which is not suitable for stored values. |
Yes @rousseldenis, you're right. |
Hi @rousseldenis, I think modifying the fields on the model Here is a suggestion for
PD: Are you working on the FIX? If you are not, I'll commit my changes on this PR, otherwise, this is just a suggestion and I'll let you FIX it. |
Nope, not so much time for that. Wanted to fix the main branch as priority. You can go on with your proposal |
76ad6cd
to
de989ad
Compare
de989ad
to
db94285
Compare
c047218
to
66ebadd
Compare
5f0a8fe
to
66ebadd
Compare
Hello @rousseldenis @pedrobaeza, Could you review this? Thank you |
If the product is type = 'service', we don't have to apply the invoice | ||
policy given by the context. | ||
:return: | ||
""" | ||
invoice_policy = self.env.context.get("invoice_policy") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't remove the depends_context
if still used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Pedro,
depends_context
is used to return a decorator that specifies the context dependencies of a non-stored "compute" method. Since the field is stored on the database, it will not run the method even if invoice_policy
is changed by context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but you are still using a context value, so both are incompatible. You can't depend on a context if it's stored.
|
||
@api.depends("detailed_type", "default_invoice_policy") | ||
@api.depends_context("invoice_policy") | ||
@api.depends("detailed_type") | ||
def _compute_invoice_policy(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why still this method if the field is not computed? And IMO, this should be adjusted on the sales order fields, not here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Pedro,
Yes, the field is computed, here is Odoo's declaration of the field:
invoice_policy = fields.Selection(
[('order', 'Ordered quantities'),
('delivery', 'Delivered quantities')], string='Invoicing Policy',
compute='_compute_invoice_policy', store=True, readonly=False, precompute=True,
help='Ordered Quantity: Invoice quantities ordered by the customer.\n'
'Delivered Quantity: Invoice quantities delivered to the customer.')
Hello @ACheung-FactorLibre , thank you for this PR and this effors. Just to have the situation: In your opinion, which is the state of this PR and what would you like to happend with it? I kindly ask just to figure out how to help 😄 ❤️ Thanks in advance |
Hi @pedrobaeza, Changes have been applied, could you please review them? Thank you for your time |
There are still some red tests. |
c3b4e9f
to
9050c2d
Compare
Hello @pedrobaeza, corrected. Thank you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a merge commit that shouldn't be there. You should rebase. And the technique used writing on the product is a very weak one. What you should do is to intercept the to invoice quantity compute methods to take into account the invoice policy.
b3a867b
to
ab21927
Compare
…ed to change the original invoice_policy field
ab21927
to
95e5c83
Compare
Hi @pedrobaeza,
Thank you |
Override the compute method for the quantity to invoice and put that quantity according the invoice policy set in the order. |
Supersede by #3102 |
FIX for: #2725