-
Notifications
You must be signed in to change notification settings - Fork 104
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][ADD] shopinvader_search_engine_product_multi_price #1498
[16.0][ADD] shopinvader_search_engine_product_multi_price #1498
Conversation
b3e26de
to
12a4226
Compare
@qgroulard the 1st commit can be dropped now, no? |
index_id = self.env.context.get("index_id", False) | ||
index = self.env["se.index"].browse(index_id) | ||
for product in self: | ||
prices = {"default": product._get_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.
wouldn't make more consistent to have the ID of the default pricelist 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.
I went for the simplest solution possible. Here we have no such thing as "default pricelist", the default price is the price without pricelist.
Maybe it would make even more sense to remove this "default" key (I can still add it at my project level).
For now we have no reliable solution for prices on the main branch, I think it would be great to have at lease one simple option available. Then we can build up on that or add other modules for other ways of computing and exposing prices.
I'm glad to finally see someone care about prices 😁
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 testing this now and if the pricelist is already on the backend or the index we'll have a duplicated price info
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.
As for the default: either we add a specific field to configure which pricelist is the default one or we drop this "default" key and we assume that the client must know which pricelist to use.
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.
Another option: add a key _default
pointing to the default id but it will still index duplicated info across all records
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.
So you are testing with both shopinvader_search_engine_product_multi_price
and shopinvader_search_engine_product_price
(#1441) installed ?
I actually think we don't need a "default" key in prices
of shopinvader_search_engine_product_multi_price
, if people want a default price they can install shopinvader_search_engine_product_price
, choose the (default) pricelist on the backend, and consider the key price
as the default price.
We can also rename the key prices
into prices_by_pricelist
or pricelist_prices
to clarify things.
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.
No, I'm not testing w/ both modules. The default key comes because of this module. You are not replacing the dict you are updating it. price_by_pricelist
is probably more explicit.
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.
Sorry, I've been busy for the past two weeks.
I have removed the key "default" and I have renamed the key prices
to price_by_pricelist
.
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.
In theory yes, the keys But I think |
I meant that you already removed it when creating the helper module, no? |
It seems not, in fact 😅 |
@qgroulard can we fast track #1507 while fixing this one? |
for product in self: | ||
prices = {"default": product._get_price()} | ||
if index_id: | ||
for pricelist in index._get_pricelists(): |
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.
isn't this returning the default pricelist as well?
If so, I would've put {"default": default_list.id}
.
Otherwise you compute the price twice.
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.
Resolved with the last change, the "default" key has been removed.
if index_id: | ||
for pricelist in index._get_pricelists(): | ||
price = product._get_price(pricelist=pricelist) | ||
prices.update({f"{pricelist.id}": 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.
why not {str(pricelist_id): price}
?
I don't think we need to format strings 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.
Done
c1cb7f7
to
45eb5e3
Compare
@qgroulard ping :) |
45eb5e3
to
2c1c43f
Compare
|
||
|
||
class ProductProduct(BaseProduct, extends=True): | ||
price_by_pricelist: dict[str, ProductPriceInfo] = {} |
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.
price_by_pricelist: dict[str, ProductPriceInfo] = {} | |
price_by_pricelist: dict[int, ProductPriceInfo] = {} |
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.
Done
shopinvader_search_engine_product_multi_price/tests/test_product_binding.py
Show resolved
Hide resolved
shopinvader_search_engine_product_multi_price/models/product_product.py
Outdated
Show resolved
Hide resolved
shopinvader_search_engine_product_multi_price/tests/test_product_binding.py
Show resolved
Hide resolved
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.
@qgroulard The key should be an integer.... It's confusing to have to convert an identifier from the user's profile for example to a string to get the right price. The type of a value should not vary depending where it's used...
2c1c43f
to
18ef55b
Compare
18ef55b
to
005e5ff
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.
LGTM (code review)
/ocabot merge nobump |
What a great day to merge this nice PR. Let's do it! |
Congratulations, your PR was merged at d544edf. Thanks a lot for contributing to shopinvader. ❤️ |
See #1441 and #1467 for PRs on related matter.
Remove
price
from the schema inshopinvader_product
as there are a lot of different ways to expose product prices and they should be handled in dedicated modules.'_get_price()' method has already been extracted to OCA/product-attribute module 'product_get_price_helper'.
Add a module to export prices for a list of pricelists set on the index or backend.