diff --git a/product_attribute_value_menu/README.rst b/product_attribute_value_menu/README.rst new file mode 100644 index 00000000000..a27945f2575 --- /dev/null +++ b/product_attribute_value_menu/README.rst @@ -0,0 +1,114 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +============================ +Product Attribute Value Menu +============================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:c3005a9bd64df444f9d8ddc0bae79de6774d4326e8d9667e7c37a5edcd0ebb96 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github + :target: https://github.com/OCA/product-attribute/tree/19.0/product_attribute_value_menu + :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-19-0/product-attribute-19-0-product_attribute_value_menu + :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=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds: + +- A menu item in Sales > Configuration called *Attribute Values Extra + Prices* where user can see/edit all extra prices set for each + attribute value in each product template. It also allows extra prices + to be imported via standard csv/xlsx import. +- A menu item in Sales and Inventory Applications called *Attribute + Values*, located under the *Attributes*' one. The new menu item + contains all the Attribute Values on a tree view, having the attribute + associated with a link and the value. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +- Got to: Sales -> Configuration -> Attribute Values Extra Prices to + manage extra price lines. +- You can edit *Extra Price* right in the list view. + +To update values through spreadsheet, it is recommended to: + +- export records' external ID and relevant fields necessary to work on + the spreadsheet (product template, attribute, attribute value, value + price extra). +- re-import records using only columns External ID and Value price + extra. + +To acces the attribute value view, simply go to Sales/Inventory > +Configuration > Attribute Values. + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Ilyas +* Ooops404 + +Contributors +------------ + +- `Ooops404 `__: + + - Ilyas + +- `ForgeFlow `__: + + - Guillem Casassas + +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_attribute_value_menu/__init__.py b/product_attribute_value_menu/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/product_attribute_value_menu/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/product_attribute_value_menu/__manifest__.py b/product_attribute_value_menu/__manifest__.py new file mode 100644 index 00000000000..24a8e583903 --- /dev/null +++ b/product_attribute_value_menu/__manifest__.py @@ -0,0 +1,16 @@ +{ + "name": "Product Attribute Value Menu", + "summary": """Product attributes values tree and form. Import attribute values.""", + "version": "19.0.1.0.0", + "website": "https://github.com/OCA/product-attribute", + "author": "Ilyas, Ooops404, Odoo Community Association (OCA)", + "license": "LGPL-3", + "category": "Stock", + "depends": ["sale_stock"], + "data": [ + "views/product_template_attribute_value_views.xml", + "views/product_attribute_value_views.xml", + ], + "installable": True, + "application": False, +} diff --git a/product_attribute_value_menu/i18n/es.po b/product_attribute_value_menu/i18n/es.po new file mode 100644 index 00000000000..bf66801189a --- /dev/null +++ b/product_attribute_value_menu/i18n/es.po @@ -0,0 +1,60 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_attribute_value_menu +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-12-29 17:34+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: product_attribute_value_menu +#: model_terms:ir.ui.view,arch_db:product_attribute_value_menu.product_attribute_value_search_view +msgid "Attribute" +msgstr "Atributo" + +#. module: product_attribute_value_menu +#: model:ir.model,name:product_attribute_value_menu.model_product_attribute_value +msgid "Attribute Value" +msgstr "Valor del Atributo" + +#. module: product_attribute_value_menu +#: model:ir.actions.act_window,name:product_attribute_value_menu.import_product_attribute_value_action +#: model:ir.ui.menu,name:product_attribute_value_menu.import_product_attribute_value_configuration_action_menu +msgid "Attribute Values Extra Prices" +msgstr "Valores de los Atributos Precios Extra" + +#. module: product_attribute_value_menu +#: model:ir.actions.act_window,name:product_attribute_value_menu.attribute_value_action +#: model:ir.ui.menu,name:product_attribute_value_menu.sale_menu_product_archived_attribute_action +#: model:ir.ui.menu,name:product_attribute_value_menu.stock_menu_product_archived_attribute_action +msgid "Attributes Values" +msgstr "Valores del Atributo" + +#. module: product_attribute_value_menu +#: model_terms:ir.ui.view,arch_db:product_attribute_value_menu.product_attribute_value_search_view +msgid "Group By" +msgstr "Grupo por" + +#. module: product_attribute_value_menu +#: model:ir.model.fields,field_description:product_attribute_value_menu.field_product_attribute_value__product_count +msgid "Product" +msgstr "Producto" + +#. module: product_attribute_value_menu +#: model_terms:ir.ui.view,arch_db:product_attribute_value_menu.pt_attribute_value_inherit_view_form +msgid "Product Attribute" +msgstr "Atributo de Producto" + +#. module: product_attribute_value_menu +#: model_terms:ir.ui.view,arch_db:product_attribute_value_menu.product_attribute_value_tree_view +msgid "Products" +msgstr "Productos" diff --git a/product_attribute_value_menu/i18n/it.po b/product_attribute_value_menu/i18n/it.po new file mode 100644 index 00000000000..1fe2f6e0b0c --- /dev/null +++ b/product_attribute_value_menu/i18n/it.po @@ -0,0 +1,75 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_attribute_value_menu +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-04-29 17:37+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: product_attribute_value_menu +#: model_terms:ir.ui.view,arch_db:product_attribute_value_menu.product_attribute_value_search_view +msgid "Attribute" +msgstr "Attributo" + +#. module: product_attribute_value_menu +#: model:ir.model,name:product_attribute_value_menu.model_product_attribute_value +msgid "Attribute Value" +msgstr "Valore attributo" + +#. module: product_attribute_value_menu +#: model:ir.actions.act_window,name:product_attribute_value_menu.import_product_attribute_value_action +#: model:ir.ui.menu,name:product_attribute_value_menu.import_product_attribute_value_configuration_action_menu +msgid "Attribute Values Extra Prices" +msgstr "Prezzi extra valori attributo" + +#. module: product_attribute_value_menu +#: model:ir.actions.act_window,name:product_attribute_value_menu.attribute_value_action +#: model:ir.ui.menu,name:product_attribute_value_menu.sale_menu_product_archived_attribute_action +#: model:ir.ui.menu,name:product_attribute_value_menu.stock_menu_product_archived_attribute_action +msgid "Attributes Values" +msgstr "Valori attributo" + +#. module: product_attribute_value_menu +#: model_terms:ir.ui.view,arch_db:product_attribute_value_menu.product_attribute_value_search_view +msgid "Group By" +msgstr "Raggruppa per" + +#. module: product_attribute_value_menu +#: model:ir.model.fields,field_description:product_attribute_value_menu.field_product_attribute_value__product_count +msgid "Product" +msgstr "Prodotto" + +#. module: product_attribute_value_menu +#: model_terms:ir.ui.view,arch_db:product_attribute_value_menu.pt_attribute_value_inherit_view_form +msgid "Product Attribute" +msgstr "Attributo prodotto" + +#. module: product_attribute_value_menu +#: model_terms:ir.ui.view,arch_db:product_attribute_value_menu.product_attribute_value_tree_view +msgid "Products" +msgstr "Prodotti" + +#~ msgid "Attribute Values" +#~ msgstr "Valori attributo" + +#~ msgid "Attributes" +#~ msgstr "Attributi" + +#~ msgid "Display Name" +#~ msgstr "Nome visualizzato" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Ultima modifica il" diff --git a/product_attribute_value_menu/i18n/product_attribute_value_menu.pot b/product_attribute_value_menu/i18n/product_attribute_value_menu.pot new file mode 100644 index 00000000000..b53c37d29b0 --- /dev/null +++ b/product_attribute_value_menu/i18n/product_attribute_value_menu.pot @@ -0,0 +1,57 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_attribute_value_menu +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: product_attribute_value_menu +#: model_terms:ir.ui.view,arch_db:product_attribute_value_menu.product_attribute_value_search_view +msgid "Attribute" +msgstr "" + +#. module: product_attribute_value_menu +#: model:ir.model,name:product_attribute_value_menu.model_product_attribute_value +msgid "Attribute Value" +msgstr "" + +#. module: product_attribute_value_menu +#: model:ir.actions.act_window,name:product_attribute_value_menu.import_product_attribute_value_action +#: model:ir.ui.menu,name:product_attribute_value_menu.import_product_attribute_value_configuration_action_menu +msgid "Attribute Values Extra Prices" +msgstr "" + +#. module: product_attribute_value_menu +#: model:ir.actions.act_window,name:product_attribute_value_menu.attribute_value_action +#: model:ir.ui.menu,name:product_attribute_value_menu.sale_menu_product_archived_attribute_action +#: model:ir.ui.menu,name:product_attribute_value_menu.stock_menu_product_archived_attribute_action +msgid "Attributes Values" +msgstr "" + +#. module: product_attribute_value_menu +#: model_terms:ir.ui.view,arch_db:product_attribute_value_menu.product_attribute_value_search_view +msgid "Group By" +msgstr "" + +#. module: product_attribute_value_menu +#: model:ir.model.fields,field_description:product_attribute_value_menu.field_product_attribute_value__product_count +msgid "Product" +msgstr "" + +#. module: product_attribute_value_menu +#: model_terms:ir.ui.view,arch_db:product_attribute_value_menu.pt_attribute_value_inherit_view_form +msgid "Product Attribute" +msgstr "" + +#. module: product_attribute_value_menu +#: model_terms:ir.ui.view,arch_db:product_attribute_value_menu.product_attribute_value_tree_view +msgid "Products" +msgstr "" diff --git a/product_attribute_value_menu/models/__init__.py b/product_attribute_value_menu/models/__init__.py new file mode 100644 index 00000000000..967ba8ab066 --- /dev/null +++ b/product_attribute_value_menu/models/__init__.py @@ -0,0 +1 @@ +from . import product_attribute_value diff --git a/product_attribute_value_menu/models/product_attribute_value.py b/product_attribute_value_menu/models/product_attribute_value.py new file mode 100644 index 00000000000..09b4554e68e --- /dev/null +++ b/product_attribute_value_menu/models/product_attribute_value.py @@ -0,0 +1,37 @@ +# Copyright 2022 ForgeFlow, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class ProductAttributeValue(models.Model): + _inherit = "product.attribute.value" + + product_count = fields.Integer(string="Product", compute="_compute_product_count") + + @api.depends("pav_attribute_line_ids") + def _compute_product_count(self): + for value in self: + value.product_count = len(value.pav_attribute_line_ids) + + def action_view_product(self): + action = self.env["ir.actions.act_window"]._for_xml_id( + "product.product_template_action" + ) + products = self.pav_attribute_line_ids.mapped("product_tmpl_id") + + if len(products) > 1: + action["domain"] = [("id", "in", products.ids)] + elif products: + form_view = [ + (self.env.ref("product.product_template_only_form_view").id, "form") + ] + if "views" in action: + action["views"] = form_view + [ + (state, view) for state, view in action["views"] if view != "form" + ] + else: + action["views"] = form_view + action["res_id"] = products.id + action["context"] = self.env.context + return action diff --git a/product_attribute_value_menu/pyproject.toml b/product_attribute_value_menu/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/product_attribute_value_menu/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/product_attribute_value_menu/readme/CONTRIBUTORS.md b/product_attribute_value_menu/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..f2d729a3268 --- /dev/null +++ b/product_attribute_value_menu/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- [Ooops404](https://www.ooops404.com): + - Ilyas \<\> +- [ForgeFlow](http://www.forgeflow.com): + - Guillem Casassas \<\> diff --git a/product_attribute_value_menu/readme/DESCRIPTION.md b/product_attribute_value_menu/readme/DESCRIPTION.md new file mode 100644 index 00000000000..1521684d7fc --- /dev/null +++ b/product_attribute_value_menu/readme/DESCRIPTION.md @@ -0,0 +1,10 @@ +This module adds: + +- A menu item in Sales \> Configuration called *Attribute Values Extra + Prices* where user can see/edit all extra prices set for each + attribute value in each product template. It also allows extra prices + to be imported via standard csv/xlsx import. +- A menu item in Sales and Inventory Applications called *Attribute + Values*, located under the *Attributes*' one. The new menu item + contains all the Attribute Values on a tree view, having the attribute + associated with a link and the value. diff --git a/product_attribute_value_menu/readme/USAGE.md b/product_attribute_value_menu/readme/USAGE.md new file mode 100644 index 00000000000..fe071e6162e --- /dev/null +++ b/product_attribute_value_menu/readme/USAGE.md @@ -0,0 +1,13 @@ +- Got to: Sales -\> Configuration -\> Attribute Values Extra Prices to manage + extra price lines. +- You can edit *Extra Price* right in the list view. + +To update values through spreadsheet, it is recommended to: +- export records' external ID and relevant fields necessary to work on + the spreadsheet (product template, attribute, attribute value, value + price extra). +- re-import records using only columns External ID and Value price + extra. + +To acces the attribute value view, simply go to Sales/Inventory \> +Configuration \> Attribute Values. diff --git a/product_attribute_value_menu/static/description/icon.png b/product_attribute_value_menu/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/product_attribute_value_menu/static/description/icon.png differ diff --git a/product_attribute_value_menu/static/description/index.html b/product_attribute_value_menu/static/description/index.html new file mode 100644 index 00000000000..4c45a58fc80 --- /dev/null +++ b/product_attribute_value_menu/static/description/index.html @@ -0,0 +1,466 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Product Attribute Value Menu

+ +

Beta License: LGPL-3 OCA/product-attribute Translate me on Weblate Try me on Runboat

+

This module adds:

+
    +
  • A menu item in Sales > Configuration called Attribute Values Extra +Prices where user can see/edit all extra prices set for each +attribute value in each product template. It also allows extra prices +to be imported via standard csv/xlsx import.
  • +
  • A menu item in Sales and Inventory Applications called Attribute +Values, located under the Attributes’ one. The new menu item +contains all the Attribute Values on a tree view, having the attribute +associated with a link and the value.
  • +
+

Table of contents

+ +
+

Usage

+
    +
  • Got to: Sales -> Configuration -> Attribute Values Extra Prices to +manage extra price lines.
  • +
  • You can edit Extra Price right in the list view.
  • +
+

To update values through spreadsheet, it is recommended to:

+
    +
  • export records’ external ID and relevant fields necessary to work on +the spreadsheet (product template, attribute, attribute value, value +price extra).
  • +
  • re-import records using only columns External ID and Value price +extra.
  • +
+

To acces the attribute value view, simply go to Sales/Inventory > +Configuration > Attribute Values.

+
+
+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Ilyas
  • +
  • Ooops404
  • +
+
+
+

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_attribute_value_menu/tests/__init__.py b/product_attribute_value_menu/tests/__init__.py new file mode 100644 index 00000000000..4e66d41036f --- /dev/null +++ b/product_attribute_value_menu/tests/__init__.py @@ -0,0 +1 @@ +from . import test_product_attribute_value diff --git a/product_attribute_value_menu/tests/test_product_attribute_value.py b/product_attribute_value_menu/tests/test_product_attribute_value.py new file mode 100644 index 00000000000..dd991229fe0 --- /dev/null +++ b/product_attribute_value_menu/tests/test_product_attribute_value.py @@ -0,0 +1,76 @@ +from odoo.tests.common import TransactionCase + + +class TestProductAttributeValue(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + + ProductTemplate = cls.env["product.template"] + Attribute = cls.env["product.attribute"] + AttributeValue = cls.env["product.attribute.value"] + + # Create attribute and value + cls.attribute = Attribute.create({"name": "Color"}) + cls.value = AttributeValue.create( + { + "name": "Red", + "attribute_id": cls.attribute.id, + } + ) + + # Attribute line values for product creation + cls.attribute_line_vals = { + "attribute_id": cls.attribute.id, + "value_ids": [(6, 0, cls.value.ids)], + } + + # Create products + cls.product_1 = ProductTemplate.create( + { + "name": "Test Product A", + "attribute_line_ids": [(0, 0, cls.attribute_line_vals)], + } + ) + cls.product_2 = ProductTemplate.create( + { + "name": "Test Product B", + "attribute_line_ids": [(0, 0, cls.attribute_line_vals)], + } + ) + + def test_product_count(self): + """Test that product_count reflects the number of products linked to + the attribute value.""" + self.assertEqual( + self.value.product_count, + 2, + "Product count should be equal to number of linked products", + ) + + def test_action_view_product_multiple(self): + """Test that action_view_product returns a + product list when multiple products are linked.""" + action = self.value.action_view_product() + self.assertIn( + "domain", + action, + "product_count does not match the number of linked products", + ) + self.assertEqual( + action["domain"], + [("id", "in", [self.product_1.id, self.product_2.id])], + "Domain does not include both linked products", + ) + + def test_action_view_product_single(self): + """Test that action_view_product opens the product + form directly when there is a single linked product.""" + self.product_2.attribute_line_ids.unlink() + action = self.value.action_view_product() + self.assertEqual( + action.get("res_id"), + self.product_1.id, + "Action did not open the single linked product's form view", + ) diff --git a/product_attribute_value_menu/views/product_attribute_value_views.xml b/product_attribute_value_menu/views/product_attribute_value_views.xml new file mode 100644 index 00000000000..826a6f0fd1c --- /dev/null +++ b/product_attribute_value_menu/views/product_attribute_value_views.xml @@ -0,0 +1,70 @@ + + + + + product.attribute.value.tree + product.attribute.value + 1 + + + + + +