-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
[FIX] product: variant sale price is wrong #87248
Conversation
5853016
to
b01d367
Compare
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.
Considering how lst_price
is computed (= list_price + extra_prices
) + the fact that lst_price
is the one used on the tree view of product.product
:
odoo/addons/product/views/product_views.xml
Line 336 in d3ec94f
<field name="lst_price" optional="show" string="Sales Price"/> |
Your changes in the XML file seem legit
However, I don't understand why there is an issue with the computation of tax_string
? Note that the addition of non-stored fields should be avoided as much as possible. Also, the implementation of product_product._compute_tax_string
is strange. product.product
is a child of product.template
, so the method overrides the original one while its body calls the original one
Also, could you be more precise in the steps-to-reproduce ? I'm not sure it is that clear that the user has to set an extra-price on a specific variant attribute (I have had to read the ticket again 😇)
the inheritance between thus the method override wouldn't work okay to the second point |
My bad for the inheritance
but maybe I'm missing something ? @agr-odoo Could you check this ? |
|
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.
I'm ok with the idea. This needs to be fixed as price and tax string of the variant product shows the template product data
On the actual implementation it would be better to have also the opinion of @Feyensv
I also don't understand the need of the tax_string code and I don't see any mention of it in the source ticket. For the |
Okay, makes sense now, but there really should be some explanation about it in the PR/commit, which isn't the case currently ... |
e8d78f6
to
f141a15
Compare
c136cb0
to
a167afd
Compare
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.
Please mark the PR as ready so that I can approve it when you are finished with the last changes :)
addons/account/models/product.py
Outdated
|
||
def _compute_tax_string(self): | ||
for record in self: | ||
record.tax_string = record.product_tmpl_id._construct_tax_string(record, record.lst_price) |
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.
This tracebacks, and it is missing dependencies
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.
Please mark the PR as ready so that I can approve it when you are finished with the last changes :)
well, my fear is that because now _construct_tax_string
is an instance method and the inheritance is delegation (so polymorphism won't work), it will be very confusing later when extending this. for now it is not an issue because the only attribute used to calculate the tax string is the price but imagine wanting to add other variables that might differ between product.product and product.template.
tl;dr
self
in _construct_tax_string
is always product_tmpl_id
regardless of where it was called from
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.
also why the style check fails with C0305, I added one line at the end
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.
also why the style check fails with C0305, I added one line at the end
You have 2 end of line char instead of one, leading in one blank/useless line
self
in_construct_tax_string
is alwaysproduct_tmpl_id
regardless of where it was called from
How is that answering any of my remarks?
And why is that an issue?
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.
I did fix the errors, I don't know what dependencies it misses.
this was another point.
the issue is that the intuitive behavior when someone sees this implementation will be that this is a normal case of polymorphism and can thus be extended further which is not the case
a167afd
to
b1dbb41
Compare
If applied, this commit will fix the following bug by using the price with the additional cost added instead of only the price Steps to reproduce: 1- install sales 2- create a product p with variant pv 3- set an extra value for pv 4- go to Products>Product Variants 5- open the pv in form view 6- the Sales Price is the price of p not pv (which should be p + extra value) 7- also the tax string is calculated on p not pv Bug: ```list_price``` is being used Fix: replace ```list_price``` with ```lst_price``` OPW-2774199
b1dbb41
to
0503be2
Compare
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.
@robodoo r+
If applied, this commit will fix the following bug by using the price
with the additional cost added instead of only the price
Steps to reproduce:
1- install sales
2- create a product p with variant pv
3- set an extra value for pv
4- go to Products>Product Variants
5- open the pv in form view
6- the Sales Price is the price of p not pv
(which should be p + extra value)
7- also the tax string is calculated on p not pv
Bug:
list_price
is being usedFix:
replace
list_price
withlst_price
OPW-2774199