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

[16.0][FIX] website_sale_product_pack: compute pack quantities #184

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from

Conversation

augusto-weiss
Copy link

Compute quantities for packs:

The error:
Could not finish a checkout process on website due to stock restriction
image

Reproduce error:
Create a pack.
Set pack as storable product, and set out of stock continue selling in FALSE
image
Make sure you have stock of pack lines.
Go to website and buy the pack
Try to finish the checkout process and you have the error

Also with this PR we ensure not to over-sell packs discriminating outgoing quantity in available quantity (line 37)

@OCA-git-bot
Copy link
Contributor

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

@augusto-weiss
Copy link
Author

Hello @pedrobaeza @victoralmau
Could you check this issue, and let me know what do you think about the solution ?

@pedrobaeza pedrobaeza added this to the 16.0 milestone Sep 16, 2024
@pedrobaeza
Copy link
Member

This must be handled in website_sale_product_pack, not here. You have also missed the pack setup, products configurations, etc.

@augusto-weiss
Copy link
Author

ok i understand, but I don't know if the problem has its origin on the website.

following the method _compute_quantities_dict the pack components return 0, and do not compute quantities correctly

About the pack I use non detailed (2nd img)

@augusto-weiss augusto-weiss changed the title [FIX] stock_product_pack: compute pack quantities [FIX] website_sale_product_pack: compute pack quantities Oct 3, 2024
@augusto-weiss
Copy link
Author

augusto-weiss commented Oct 3, 2024

Hi @pedrobaeza i moved code to website_sale_product_pack.
Let me know your opinion ? Thanks

@pedrobaeza pedrobaeza changed the title [FIX] website_sale_product_pack: compute pack quantities [16.0][FIX] website_sale_product_pack: compute pack quantities Oct 4, 2024
Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

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

Thanks for the changes, and sorry for not being very clear. I was expecting that you avoid the _compute_quantities_dict override, as that one is very general, but to focus on the website_sale checkout process itself, and bypass the stock checking just there on the met conditions. If the availability problem happens in other places, then it would be correct to put it on the main stock module, but then you should rephrase your rationale in the commit/PR message about how to reproduce it in a generic way (and maybe making reference that this happens also on e-commerce).

@augusto-weiss
Copy link
Author

Hi @pedrobaeza I was analyzing the issue in depth and following the call stack, I noticed that the compute_dict_qty method is called on the following line (link), so i should inherit the _get_cart_and_free_qty method.
But.. to do that I should add the dependency to website_sale_stock.

Let me know your opinion!

@augusto-weiss
Copy link
Author

def _get_cart_and_free_qty(self, line=None, product=None, **kwargs):
        if (line and line.product_id.pack_ok) or (product and product.pack_ok):
            return 0, 0
        return super()._get_cart_and_free_qty(line=line, product=product, **kwargs)

@pedrobaeza
Copy link
Member

Then it seems we need a website_sale_stock_product_pack glue module for keeping modularity. It's true that you can sell packs (of services, for example), without the need of having stocks. Anyway, why isn't this a problem on backend?

@augusto-weiss
Copy link
Author

augusto-weiss commented Oct 9, 2024

Hi @pedrobaeza Also happens in the backend... but by default is not blocking the possibility of confirming a sale order
image

Including the first approach (in stock_product_pack):
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants