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

[14.0] [IMP] sale_order_product_assortment: Use original product_id field keeping domain. Use cache to performance #3135

Conversation

renda-dev
Copy link
Contributor

@renda-dev renda-dev commented May 14, 2024

Back port of #2538

Depends on:

Edit: I've also added a commit that changes the AND in the _compute_product_assortment_ids into an OR since, in my opinion, it's more likely what an user would expect by combining more assortments

@OCA-git-bot
Copy link
Contributor

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

@renda-dev renda-dev force-pushed the 14.0-IMP-sale_order_product_assortment-only_product_id_field branch 5 times, most recently from 1af62da to 6af2ed5 Compare May 15, 2024 12:48
@renda-dev renda-dev marked this pull request as draft May 15, 2024 13:18
@renda-dev renda-dev force-pushed the 14.0-IMP-sale_order_product_assortment-only_product_id_field branch 4 times, most recently from 02bc6d2 to 6af2ed5 Compare May 15, 2024 14:56
@renda-dev renda-dev marked this pull request as ready for review May 16, 2024 13:07
Copy link
Contributor

@francesco-ooops francesco-ooops left a comment

Choose a reason for hiding this comment

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

Functional ok, good for merge once depending PR is merged

@renda-dev renda-dev force-pushed the 14.0-IMP-sale_order_product_assortment-only_product_id_field branch from 6af2ed5 to 4a4e019 Compare May 17, 2024 09:26
@francesco-ooops
Copy link
Contributor

@CarlosRoca13 what do you think?

We had to apply the latest commit as the behavior was inconsistent, eg:

Create assortment "Chair", product allowed: "Office Chair", partner: Azure Interior
Create assortment "Screen", product allowed: "Acoustic bloc screens", partner: Azure Interior
SO for Azure Interior: 2 products can be selected

Create assortment "Chair", allowed product domain: "Name contains Office Chair", partner: Azure Interior
Create assortment "Screen", allowed product domain: "Name contains Acoustic bloc screens", partner: Azure Interior
SO for Azure Interior: no products can be selected

We'll fw-port this commit

Copy link

@aleuffre aleuffre left a comment

Choose a reason for hiding this comment

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

Code review, LGTM.

I think it makes more sense and is more intuitive for the user to have different assortments linked with OR than with AND. Otherwise the effect is that, as you add more assortments to the customer, you actually shrink the selection they have available.

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@CarlosRoca13
Copy link
Contributor

Makes sense. Can you please add in the commit a brief explanation and the steps to reproduce the problem?

Copy link
Contributor

@CarlosRoca13 CarlosRoca13 left a comment

Choose a reason for hiding this comment

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

On second thought... Let's imagine that we have 2 assortments for the same customer, in these two assortments, what is done, is to ban the purchase of chairs in the first one and tables in the second one. With this change, the customer will be able to see all the products, both chairs and tables.

@francesco-ooops
Copy link
Contributor

@CarlosRoca13 yours is a valid point, but it seems like this is a short blanket situation, as some assortments will be used to exclude products and others to include them and some to do both - there is no right or wrong.

We will look into a solution for the matter, do you have any idea how this could be solved?

@CarlosRoca13
Copy link
Contributor

Right now, I don't know how this could be faced... But I know that we have customers who are using the assortments excluding products and we cannot assume this change...

@pedrobaeza @carlosdauden @sergio-teruel can you give your point of view about this?

@pedrobaeza
Copy link
Member

There shouldn't be any feature regression. It's OK to optimize, but not losing features.

@francesco-ooops
Copy link
Contributor

There shouldn't be any feature regression. It's OK to optimize, but not losing features.

We're on the same page on that (we've always been), but we need to address the inconsistency in the example I posted above:

Create assortment "Chair", product allowed: "Office Chair", partner: Azure Interior
Create assortment "Screen", product allowed: "Acoustic bloc screens", partner: Azure Interior
SO for Azure Interior: 2 products can be selected

Create assortment "Chair", allowed product domain: "Name contains Office Chair", partner: Azure Interior
Create assortment "Screen", allowed product domain: "Name contains Acoustic bloc screens", partner: Azure Interior
SO for Azure Interior: no products can be selected

Also note that website assortment module works with OR as per OCA/e-commerce#838

@pedrobaeza
Copy link
Member

Are you telling that previously it was not correct? I agree then to cover the case correctly with the optimization.

@CarlosRoca13
Copy link
Contributor

The real problem of this is that we are taking all assortment domain at this point:
7e8b7a4#diff-d857107550de88517b0f4cb32ae7770a25a630dc254b97191e7f71f262183089R36
Since we don't know what type of assortment is involved

I think the right solution would be to take 2 product domains out of the assortment. One for excluded products and one for included products. In this way we could combine them in the way that suits us.

Note: The excluded products can't fit with the included with OR in the domain

@francesco-ooops
Copy link
Contributor

francesco-ooops commented May 23, 2024

Sounds like something we could think about!

Note: The excluded products can't fit with the included with OR in the domain

@CarlosRoca13 Can you expand on this?

@CarlosRoca13
Copy link
Contributor

4 sure, what I mean is that the excluded domain needs to be set with AND because it is restrictive, an excluded product discards any posible included product

@pedrobaeza
Copy link
Member

At the end, both should combine to get a unique domain for the product selection, but include part should be treated on one part, joining all the inclusions together, and exclusions should be also joined, and excluded from the remaining result.

@renda-dev renda-dev force-pushed the 14.0-IMP-sale_order_product_assortment-only_product_id_field branch 2 times, most recently from a38f294 to a325ee0 Compare May 27, 2024 08:52
Copy link

@aleuffre aleuffre left a comment

Choose a reason for hiding this comment

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

Code review seems ok, I definitely prefer this solution (add all whitelisted products, remove all blacklisted products) but I think we should add a couple of tests here to make sure.

Also, outside of this PR, the logic should be unified and moved to the base module so that there are no differences with the e-commerce module.

@renda-dev renda-dev force-pushed the 14.0-IMP-sale_order_product_assortment-only_product_id_field branch 3 times, most recently from 3f06469 to 6042550 Compare May 29, 2024 13:37
Copy link

@aleuffre aleuffre left a comment

Choose a reason for hiding this comment

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

Code review, LGTM

@renda-dev renda-dev force-pushed the 14.0-IMP-sale_order_product_assortment-only_product_id_field branch from 6042550 to a305663 Compare May 29, 2024 13:40
@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Copy link
Contributor

@CarlosRoca13 CarlosRoca13 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Please fw-port changes to 15.0 but note that a domain has been introduced for excluded products.

https://github.com/OCA/product-attribute/blob/50e3e48b2fcf5f504a857b367dd90e7ed7812fd0/product_assortment/models/ir_filters.py#L75

@renda-dev renda-dev force-pushed the 14.0-IMP-sale_order_product_assortment-only_product_id_field branch from 9751a63 to e5621a2 Compare June 3, 2024 07:12
@pedrobaeza
Copy link
Member

/ocabot merge major

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 14.0-ocabot-merge-pr-3135-by-pedrobaeza-bump-major, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 51d3419 into OCA:14.0 Jun 3, 2024
11 checks passed
@OCA-git-bot
Copy link
Contributor

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

7 participants