OCA / product-pack

Odoo modules related to product packs
GNU Affero General Public License v3.0
48 stars 127 forks source link

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

Open augusto-weiss opened 2 months ago

augusto-weiss commented 2 months ago

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 commented 2 months ago

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

augusto-weiss commented 2 months ago

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

pedrobaeza commented 2 months ago

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

augusto-weiss commented 2 months ago

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 commented 1 month ago

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

augusto-weiss commented 1 month ago

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 commented 1 month ago
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 commented 1 month ago

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 commented 1 month ago

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