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] sale_product_pack: Respect the order of the lines to be added #186

Closed victoralmau closed 1 month ago

victoralmau commented 1 month ago

Respect the order of the lines to be added

Before antes

After despues

Please @pedrobaeza and @chienandalu can you review it?

@Tecnativa TT51380

OCA-git-bot commented 1 month ago

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

victoralmau commented 1 month ago

We are losing here a lot of performance, as this applies to all sales order lines, no matter if with pack or not.

Aren't there any other option for this?

Changed so that it only applies when any line that is created is a pack.

pedrobaeza commented 1 month ago

But it still has the problem with large orders containing packs. You have to find another alternative. How it was done in previous versions? What is the difference now?

victoralmau commented 1 month ago

v15 code: https://github.com/OCA/product-pack/blob/15.0/sale_product_pack/models/sale_order_line.py#L79 After creating each of the lines, the extra lines of the pack were auto-created (if applicable).

victoralmau commented 1 month ago

Ping @pedrobaeza

pedrobaeza commented 1 month ago

Why don't you try to incorporate the pack lines to the dictionary vals list after each record, and call super with all of them, and then only returning those recordsets that are not pack lines? Do you understand me?

victoralmau commented 1 month ago

Why don't you try to incorporate the pack lines to the dictionary vals list after each record, and call super with all of them, and then only returning those recordsets that are not pack lines? Do you understand me?

Yes, I understand what you are saying but “it is not possible”. It would be to add to the dictionary the “extra lines” that are set in https://github.com/OCA/product-pack/blob/16.0/sale_product_pack/models/sale_order_line.py#L56 but those values are obtained precisely by taking as reference the “parent” line (sale.order.line) already existing https://github.com/OCA/product-pack/blob/16.0/sale_product_pack/models/product_pack_line.py#L14.

OCA-git-bot commented 1 month ago

What a great day to merge this nice PR. Let's do it! Prepared branch 16.0-ocabot-merge-pr-186-by-pedrobaeza-bump-patch, awaiting test results.

OCA-git-bot commented 1 month ago

Congratulations, your PR was merged at 11d3fe3b764424d2b18dfeace081a424350c289a. Thanks a lot for contributing to OCA. ❤️