product-attribute icon indicating copy to clipboard operation
product-attribute copied to clipboard

[16.0][ADD] product_merge

Open sbejaoui opened this issue 1 year ago • 6 comments

This module allows users to efficiently merge multiple product templates into one. This merge process ensures that attributes and variants from all selected products are consolidated into the primary product template, without creating any new variants. This approach is particularly important for maintaining data integrity and avoiding unnecessary database load.

By not creating new variants during the merge, the module helps to prevent heavy updates on existing tables, making it ideal for large-scale databases.

sbejaoui avatar Jan 02 '25 15:01 sbejaoui

Possible duplicate of https://github.com/OCA/stock-logistics-warehouse/tree/16.0/base_product_merge?

StefanRijnhart avatar Jan 19 '25 17:01 StefanRijnhart

This module emits error logs during the tests. Can you mute the logger when testing the exception?

2025-01-07T23:29:23.6985267Z 2025-01-07 23:29:23,697 500 [1;32m[1;49mINFO[0m odoo odoo.addons.product_merge.tests.test_product_merge: Starting TestProductMerge.test_action_merge_products_same_attribute_value ... 
2025-01-07T23:29:23.7717242Z 2025-01-07 23:29:23,770 500 [1;31m[1;49mERROR[0m odoo odoo.sql_db: bad query: UPDATE "product_product" SET "combination_indices" = '20', "write_date" = '2025-01-07T23:29:23.397594'::timestamp, "write_uid" = 1 WHERE id IN (78)
2025-01-07T23:29:23.7718580Z ERROR: duplicate key value violates unique constraint "product_product_combination_unique"
2025-01-07T23:29:23.7719177Z DETAIL:  Key (product_tmpl_id, combination_indices)=(63, 20) already exists.
2025-01-07T23:29:23.7719532Z  

StefanRijnhart avatar Jan 19 '25 17:01 StefanRijnhart

Possible duplicate of https://github.com/OCA/stock-logistics-warehouse/tree/16.0/base_product_merge?

The goal is not the same. This PR propose to merge 2 product templates into one product with 2 variants.

lmignon avatar Jan 22 '25 13:01 lmignon

From what I can see, base_product_merge will not merge product variants if there are product attributes at play, in which case the result is also one product with the combined set of variants. Can you be more precise about the difference in outcome?

StefanRijnhart avatar Jan 22 '25 13:01 StefanRijnhart

From what I can see, base_product_merge will not merge product variants if there are product attributes at play, in which case the result is also one product with the combined set of variants. Can you be more precise about the difference in outcome?

I didn't know that the base_product_merge module existed so I didn't really test it. A typical use case is, for example, when you have two TShirt products in DB, one for TShirt M and one for TShirt L, which are not variants of each other. The wizard will allow you to group the products together under the same template while completing the attribute values possible at template level. I don't get the impression from reading the code of the base_product_merge module that this is the use case supported. Moreover we avoid modifying the variant identifiers. We're trying to minimize the impact on the DB as much as possible by keeping the current variant identifiers and only replacing the values of the template that has been orphaned by its variant. The merge must be possible on a running instance with a lot of sales and logistics activities.

lmignon avatar Jan 22 '25 14:01 lmignon

Sounds like there is a strong case to try and improve base_product_merge for this scenario, also given that it already uses OpenUpgradelib's merge_records.

StefanRijnhart avatar Jan 22 '25 14:01 StefanRijnhart

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

github-actions[bot] avatar Aug 03 '25 12:08 github-actions[bot]

@sbejaoui Any chance that you could create another PR for V18?

PieterPaulussen avatar Aug 12 '25 13:08 PieterPaulussen