Skip to content

Commit 7e6a597

Browse files
committed
[16.0][ADD] product_merge
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.
1 parent 11f910b commit 7e6a597

File tree

21 files changed

+1077
-0
lines changed

21 files changed

+1077
-0
lines changed

product_merge/README.rst

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
=============
2+
Product Merge
3+
=============
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:f61a26838528b39a7681c2417bec10f1a57716112590f61aab0608f392d26c04
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github
20+
:target: https://github.com/OCA/product-attribute/tree/16.0/product_merge
21+
:alt: OCA/product-attribute
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_merge
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/product-attribute&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module allows users to efficiently merge multiple product templates
32+
into one. This merge process ensures that attributes and variants from
33+
all selected products are consolidated into the primary product
34+
template, without creating any new variants. This approach is
35+
particularly important for maintaining data integrity and avoiding
36+
unnecessary database load.
37+
38+
By not creating new variants during the merge, the module helps to
39+
prevent heavy updates on existing tables, making it ideal for
40+
large-scale databases.
41+
42+
**Table of contents**
43+
44+
.. contents::
45+
:local:
46+
47+
Usage
48+
=====
49+
50+
- In the product template tree view, select multiple products.
51+
- Chose "Merge products" action
52+
- At least two products must be selected, and each should have at most
53+
one variant.
54+
55+
Bug Tracker
56+
===========
57+
58+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/issues>`_.
59+
In case of trouble, please check there if your issue has already been reported.
60+
If you spotted it first, help us to smash it by providing a detailed and welcomed
61+
`feedback <https://github.com/OCA/product-attribute/issues/new?body=module:%20product_merge%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
62+
63+
Do not contact contributors directly about support or help with technical issues.
64+
65+
Credits
66+
=======
67+
68+
Authors
69+
-------
70+
71+
* ACSONE SA/NV
72+
73+
Contributors
74+
------------
75+
76+
- Souheil Bejaoui [email protected]
77+
78+
Maintainers
79+
-----------
80+
81+
This module is maintained by the OCA.
82+
83+
.. image:: https://odoo-community.org/logo.png
84+
:alt: Odoo Community Association
85+
:target: https://odoo-community.org
86+
87+
OCA, or the Odoo Community Association, is a nonprofit organization whose
88+
mission is to support the collaborative development of Odoo features and
89+
promote its widespread use.
90+
91+
This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/16.0/product_merge>`_ project on GitHub.
92+
93+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

product_merge/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import wizards
2+
from . import models

product_merge/__manifest__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2024 ACSONE SA/NV
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Product Merge",
6+
"version": "16.0.1.0.0",
7+
"license": "AGPL-3",
8+
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
9+
"website": "https://github.com/OCA/product-attribute",
10+
"depends": ["product"],
11+
"data": [
12+
"security/groups.xml",
13+
"security/ir.model.access.csv",
14+
"wizards/product_merge_wizard.xml",
15+
],
16+
"demo": [],
17+
}

product_merge/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import product_template
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2024 ACSONE SA/NV
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import models
5+
6+
7+
class ProductTemplate(models.Model):
8+
9+
_inherit = "product.template"
10+
11+
def _create_variant_ids(self):
12+
"""prevent variant creation at product merge process"""
13+
if self.env.context.get("product_merge"):
14+
return
15+
return super()._create_variant_ids()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Souheil Bejaoui <[email protected]>
2+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
This module allows users to efficiently merge multiple product templates into one.
2+
This merge process ensures that attributes and variants from all selected products
3+
are consolidated into the primary product template, without creating any new variants.
4+
This approach is particularly important for maintaining data integrity and
5+
avoiding unnecessary database load.
6+
7+
By not creating new variants during the merge, the module helps to prevent
8+
heavy updates on existing tables, making it ideal for large-scale databases.

product_merge/readme/USAGE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- In the product template tree view, select multiple products.
2+
- Chose "Merge products" action
3+
- At least two products must be selected, and each should have at most one variant.

product_merge/security/groups.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<!-- Copyright 2021 ACSONE SA/NV
3+
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
4+
<odoo noupdate="1">
5+
<record model="res.groups" id="group_can_merge_products">
6+
<field name="name">Can merge products</field>
7+
<field name="implied_ids" eval="[(4, ref('base.group_user'))]" />
8+
<field
9+
name="users"
10+
eval="[Command.link(ref('base.user_root')), Command.link(ref('base.user_admin'))]"
11+
/>
12+
</record>
13+
14+
</odoo>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2+
access_product_merge_wizard,access_product_merge_wizard,model_product_merge_wizard,group_can_merge_products,1,1,1,1
3+
access_product_merge_wizard_line,access_product_merge_wizard_line,model_product_merge_wizard_line,group_can_merge_products,1,1,1,1

0 commit comments

Comments
 (0)