diff --git a/product_equivalent_category/README.rst b/product_equivalent_category/README.rst new file mode 100644 index 000000000000..d82407fe65b2 --- /dev/null +++ b/product_equivalent_category/README.rst @@ -0,0 +1,75 @@ +=========================== +Product Equivalent Category +=========================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/12.0/product_equivalent_category + :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-12-0/product-attribute-12-0-product_equivalent_category + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/135/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds the concept of equivalent category. A product can +belong to a certain equivalent category and all products in that +category will be considered equivalent. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow S.L. + +Contributors +~~~~~~~~~~~~ + +* Adrià Gil Sorribes + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/product_equivalent_category/__init__.py b/product_equivalent_category/__init__.py new file mode 100644 index 000000000000..0650744f6bc6 --- /dev/null +++ b/product_equivalent_category/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/product_equivalent_category/__manifest__.py b/product_equivalent_category/__manifest__.py new file mode 100644 index 000000000000..e06c33fa4236 --- /dev/null +++ b/product_equivalent_category/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2019 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Product Equivalent Category', + 'summary': """ + This module adds the concept of equivalent category. A product can + belong to a certain equivalent category and all products in that + category will be considered equivalent.""", + 'version': '12.0.1.0.0', + 'license': 'AGPL-3', + 'author': 'ForgeFlow S.L., Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/product-attribute', + 'depends': [ + 'product' + ], + 'data': [ + 'security/ir.model.access.csv', + 'views/product_equivalent_category_views.xml', + 'views/product_template_views.xml', + ], + 'demo': [ + ], +} diff --git a/product_equivalent_category/models/__init__.py b/product_equivalent_category/models/__init__.py new file mode 100644 index 000000000000..a5f13e914551 --- /dev/null +++ b/product_equivalent_category/models/__init__.py @@ -0,0 +1,2 @@ +from . import product_equivalent_category +from . import product_template diff --git a/product_equivalent_category/models/product_equivalent_category.py b/product_equivalent_category/models/product_equivalent_category.py new file mode 100644 index 000000000000..aaa7d8dd23d6 --- /dev/null +++ b/product_equivalent_category/models/product_equivalent_category.py @@ -0,0 +1,25 @@ +# Copyright 2019 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class ProductEquivalentCategory(models.Model): + _name = "product.equivalent.category" + _description = "Product Equivalent Category" + + name = fields.Char("Name", index=True, required=True, translate=True) + product_count = fields.Integer( + "# Products", + compute="_compute_product_count", + help="The number of products under this category", + ) + + @api.multi + def _compute_product_count(self): + for categ in self: + categ.product_count = len( + self.env["product.template"].search( + [("equivalent_categ_id", "=", categ.id)] + ) + ) diff --git a/product_equivalent_category/models/product_template.py b/product_equivalent_category/models/product_template.py new file mode 100644 index 000000000000..7396bc7ad881 --- /dev/null +++ b/product_equivalent_category/models/product_template.py @@ -0,0 +1,13 @@ +# Copyright 2019 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + equivalent_categ_id = fields.Many2one( + 'product.equivalent.category', 'Product Equivalent Category', + change_default=True, + help="Select equivalent category for the current product") diff --git a/product_equivalent_category/readme/CONTRIBUTORS.rst b/product_equivalent_category/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..881697982a03 --- /dev/null +++ b/product_equivalent_category/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Adrià Gil Sorribes diff --git a/product_equivalent_category/readme/DESCRIPTION.rst b/product_equivalent_category/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..73fbe2e6c792 --- /dev/null +++ b/product_equivalent_category/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module adds the concept of equivalent category. A product can +belong to a certain equivalent category and all products in that +category will be considered equivalent. diff --git a/product_equivalent_category/security/ir.model.access.csv b/product_equivalent_category/security/ir.model.access.csv new file mode 100644 index 000000000000..c7e2f392c9c8 --- /dev/null +++ b/product_equivalent_category/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_product_equivalent_category_manager,product.equivalent.category.manager,model_product_equivalent_category,base.group_partner_manager,1,1,1,1 +access_product_equivalent_category_user,product.equivalent.category.user,model_product_equivalent_category,,1,0,0,0 \ No newline at end of file diff --git a/product_equivalent_category/static/description/icon.png b/product_equivalent_category/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/product_equivalent_category/static/description/icon.png differ diff --git a/product_equivalent_category/static/description/index.html b/product_equivalent_category/static/description/index.html new file mode 100644 index 000000000000..a00e7a41612d --- /dev/null +++ b/product_equivalent_category/static/description/index.html @@ -0,0 +1,421 @@ + + + + + + +Product Equivalent Category + + + +
+

Product Equivalent Category

+ + +

Beta License: AGPL-3 OCA/product-attribute Translate me on Weblate Try me on Runbot

+

This module adds the concept of equivalent category. A product can +belong to a certain equivalent category and all products in that +category will be considered equivalent.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow S.L.
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/product_equivalent_category/views/product_equivalent_category_views.xml b/product_equivalent_category/views/product_equivalent_category_views.xml new file mode 100644 index 000000000000..03b9907c995d --- /dev/null +++ b/product_equivalent_category/views/product_equivalent_category_views.xml @@ -0,0 +1,58 @@ + + + + + product.equivalent.category.search + product.equivalent.category + + + + + + + + product.equivalent.category.form + product.equivalent.category + +
+ +
+ +
+
+
+
+
+
+
+ + product.equivalent.category.list + product.equivalent.category + 1 + + + + + + + + Product Equivalent Categories + ir.actions.act_window + product.equivalent.category + form + + + + +
diff --git a/product_equivalent_category/views/product_template_views.xml b/product_equivalent_category/views/product_template_views.xml new file mode 100644 index 000000000000..5a59305a82b5 --- /dev/null +++ b/product_equivalent_category/views/product_template_views.xml @@ -0,0 +1,24 @@ + + + + + product.template + + + + + + + + + + product.template + + + + + + + + +