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][ADD] product_merge #1830

Open
wants to merge 2 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions product_merge/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
=============
Product Merge
=============

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f61a26838528b39a7681c2417bec10f1a57716112590f61aab0608f392d26c04
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github
:target: https://github.com/OCA/product-attribute/tree/16.0/product_merge
:alt: OCA/product-attribute
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_merge
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/product-attribute&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

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.

**Table of contents**

.. contents::
:local:

Usage
=====

- In the product template tree view, select multiple products.
- Chose "Merge products" action
- At least two products must be selected, and each should have at most
one variant.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`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**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* ACSONE SA/NV

Contributors
------------

- Souheil Bejaoui [email protected]

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/16.0/product_merge>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions product_merge/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import wizards
from . import models
17 changes: 17 additions & 0 deletions product_merge/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Product Merge",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/product-attribute",
"depends": ["product"],
"data": [
"security/groups.xml",
"security/ir.model.access.csv",
"wizards/product_merge_wizard.xml",
],
"demo": [],
}
1 change: 1 addition & 0 deletions product_merge/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product_template
15 changes: 15 additions & 0 deletions product_merge/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class ProductTemplate(models.Model):

_inherit = "product.template"

def _create_variant_ids(self):
"""prevent variant creation at product merge process"""
if self.env.context.get("product_merge"):
return
return super()._create_variant_ids()
2 changes: 2 additions & 0 deletions product_merge/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Souheil Bejaoui <[email protected]>

8 changes: 8 additions & 0 deletions product_merge/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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.
3 changes: 3 additions & 0 deletions product_merge/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- In the product template tree view, select multiple products.
- Chose "Merge products" action
- At least two products must be selected, and each should have at most one variant.
14 changes: 14 additions & 0 deletions product_merge/security/groups.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2021 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo noupdate="1">
<record model="res.groups" id="group_can_merge_products">
<field name="name">Can merge products</field>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]" />
<field
name="users"
eval="[Command.link(ref('base.user_root')), Command.link(ref('base.user_admin'))]"
/>
</record>

</odoo>
3 changes: 3 additions & 0 deletions product_merge/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_product_merge_wizard,access_product_merge_wizard,model_product_merge_wizard,group_can_merge_products,1,1,1,1
access_product_merge_wizard_line,access_product_merge_wizard_line,model_product_merge_wizard_line,group_can_merge_products,1,1,1,1
Binary file added product_merge/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added product_merge/static/description/icon.png.oca
Binary file not shown.
Loading
Loading