diff --git a/product_attribute_value_archive/tests/test_archive_attribute_value.py b/product_attribute_value_archive/tests/test_archive_attribute_value.py index 76b3c1414..f8db389ba 100644 --- a/product_attribute_value_archive/tests/test_archive_attribute_value.py +++ b/product_attribute_value_archive/tests/test_archive_attribute_value.py @@ -30,7 +30,7 @@ def setUpClassAttribute(cls): cls.value_model = cls.env["product.attribute.value"] cls.attribute_line_model = cls.env["product.template.attribute.line"] cls.attribute_value_model = cls.env["product.template.attribute.value"] - cls.attribute = cls.attribute_model.create({"name": "color"}) + cls.attribute = cls.attribute_model.create({"name": "AT_color"}) cls.values = cls.env["product.attribute.value"] for color in ["red", "blue", "green", "black"]: value = cls.value_model.create( @@ -122,7 +122,7 @@ def test_value_archive(self): self._create_sale_order_lines(self.red_products) # Trying to unlink the value here should raise an exception # since it's still referenced by the car and pen product templates - regex = f"You cannot delete the value color: {self.red.name}" + regex = f"You cannot delete the value {self.attribute.name}: {self.red.name}" with self.assertRaisesRegex(UserError, regex): self.red.unlink() # Remove the value from the set @@ -145,7 +145,7 @@ def test_value_non_archiveable(self): # to archive or unlink the value, and odoo should raise # an exception saying that red is still referenced by car regex = ( - f"You cannot delete the value color: {self.red.name} " + f"You cannot delete the value {self.attribute.name}: {self.red.name} " f"because it is used on the following products:\n{self.car.name}" ) with self.assertRaisesRegex(UserError, regex): diff --git a/product_matrix_show_color/README.rst b/product_matrix_show_color/README.rst new file mode 100644 index 000000000..8ae30da95 --- /dev/null +++ b/product_matrix_show_color/README.rst @@ -0,0 +1,95 @@ +========================= +Product Matrix Show Color +========================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:15822e9000d242ca7cd72e87f4f0ef148b8f9c7dfc73eba75d479868556e3f39 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-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--variant-lightgray.png?logo=github + :target: https://github.com/OCA/product-variant/tree/18.0/product_matrix_show_color + :alt: OCA/product-variant +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/product-variant-18-0/product-variant-18-0-product_matrix_show_color + :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-variant&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module shows colors of product variants in matrix table + +|image| + +.. |image| image:: https://raw.githubusercontent.com/OCA/product-variant/18.0/product_matrix_show_color/static/img/screenshot.png + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + + + +Known issues / Roadmap +====================== + + + +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 +------- + +* Nextev S.r.l +* Studio73 + +Contributors +------------ + +- Nextev Srl <`https://nextev.it\\> >`__: +- Studio73 : +- `Studio73 `__: + + - Miguel Gandia + +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-variant `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/product_matrix_show_color/__init__.py b/product_matrix_show_color/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/product_matrix_show_color/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/product_matrix_show_color/__manifest__.py b/product_matrix_show_color/__manifest__.py new file mode 100644 index 000000000..005313557 --- /dev/null +++ b/product_matrix_show_color/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2020 Studio73 - Miguel Gandia +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). +{ + "name": "Product Matrix Show Color", + "summary": """ + Technical module: Show attribute color in product matrix table + """, + "category": "Sales/Sales", + "version": "18.0.1.0.0", + "license": "LGPL-3", + "author": "Nextev S.r.l, Studio73," "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/product-variant", + "depends": ["product_matrix"], + "installable": True, + "assets": { + "web.assets_backend": [ + "product_matrix_show_color/static/src/scss/product_matrix.scss", + "product_matrix_show_color/static/src/xml/product_matrix.xml", + ], + }, +} diff --git a/product_matrix_show_color/models/__init__.py b/product_matrix_show_color/models/__init__.py new file mode 100644 index 000000000..b259dd285 --- /dev/null +++ b/product_matrix_show_color/models/__init__.py @@ -0,0 +1 @@ +from . import product_template_attribute_value diff --git a/product_matrix_show_color/models/product_template_attribute_value.py b/product_matrix_show_color/models/product_template_attribute_value.py new file mode 100644 index 000000000..ba4d1262b --- /dev/null +++ b/product_matrix_show_color/models/product_template_attribute_value.py @@ -0,0 +1,16 @@ +# Copyright 2020 Studio73 - Miguel Gandia + +from odoo import models + + +class ProductTemplateAttributeValue(models.Model): + _inherit = "product.template.attribute.value" + + def _grid_header_cell(self, fro_currency, to_currency, company, display_extra=True): + header_cell = super()._grid_header_cell( + fro_currency, to_currency, company, display_extra=display_extra + ) + header_cell.update( + {"html_color": self[0].html_color if self and self[0].html_color else False} + ) + return header_cell diff --git a/product_matrix_show_color/pyproject.toml b/product_matrix_show_color/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/product_matrix_show_color/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/product_matrix_show_color/readme/CONFIGURATION.rst b/product_matrix_show_color/readme/CONFIGURATION.rst new file mode 100644 index 000000000..e69de29bb diff --git a/product_matrix_show_color/readme/CONTRIBUTORS.md b/product_matrix_show_color/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..2e066373f --- /dev/null +++ b/product_matrix_show_color/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- Nextev Srl \: +- Studio73 \: +- [Studio73](https://studio73.es): + - Miguel Gandia diff --git a/product_matrix_show_color/readme/DESCRIPTION.md b/product_matrix_show_color/readme/DESCRIPTION.md new file mode 100644 index 000000000..316e42f50 --- /dev/null +++ b/product_matrix_show_color/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +This module shows colors of product variants in matrix table + +![image](../static/img/screenshot.png) diff --git a/product_matrix_show_color/readme/ROADMAP.md b/product_matrix_show_color/readme/ROADMAP.md new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/product_matrix_show_color/readme/ROADMAP.md @@ -0,0 +1 @@ + diff --git a/product_matrix_show_color/readme/USAGE.md b/product_matrix_show_color/readme/USAGE.md new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/product_matrix_show_color/readme/USAGE.md @@ -0,0 +1 @@ + diff --git a/product_matrix_show_color/static/description/icon.png b/product_matrix_show_color/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/product_matrix_show_color/static/description/icon.png differ diff --git a/product_matrix_show_color/static/description/index.html b/product_matrix_show_color/static/description/index.html new file mode 100644 index 000000000..c1c29bcae --- /dev/null +++ b/product_matrix_show_color/static/description/index.html @@ -0,0 +1,438 @@ + + + + + +Product Matrix Show Color + + + +
+

Product Matrix Show Color

+ + +

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

+

This module shows colors of product variants in matrix table

+

image

+

Table of contents

+ +
+

Usage

+
+ +
+

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

+
    +
  • Nextev S.r.l
  • +
  • Studio73
  • +
+
+
+

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

+

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

+
+
+
+ + diff --git a/product_matrix_show_color/static/img/screenshot.png b/product_matrix_show_color/static/img/screenshot.png new file mode 100644 index 000000000..728d53fda Binary files /dev/null and b/product_matrix_show_color/static/img/screenshot.png differ diff --git a/product_matrix_show_color/static/src/scss/product_matrix.scss b/product_matrix_show_color/static/src/scss/product_matrix.scss new file mode 100644 index 000000000..d00b3a5a5 --- /dev/null +++ b/product_matrix_show_color/static/src/scss/product_matrix.scss @@ -0,0 +1,8 @@ +.o_matrix_input_table { + .o_field_widget { + .o_field_color { + width: 17px; + height: 17px; + } + } +} diff --git a/product_matrix_show_color/static/src/xml/product_matrix.xml b/product_matrix_show_color/static/src/xml/product_matrix.xml new file mode 100644 index 000000000..68ef46faa --- /dev/null +++ b/product_matrix_show_color/static/src/xml/product_matrix.xml @@ -0,0 +1,28 @@ + diff --git a/product_matrix_show_color/tests/__init__.py b/product_matrix_show_color/tests/__init__.py new file mode 100644 index 000000000..8811bb545 --- /dev/null +++ b/product_matrix_show_color/tests/__init__.py @@ -0,0 +1 @@ +from . import test_product_template diff --git a/product_matrix_show_color/tests/test_product_template.py b/product_matrix_show_color/tests/test_product_template.py new file mode 100644 index 000000000..44b310a99 --- /dev/null +++ b/product_matrix_show_color/tests/test_product_template.py @@ -0,0 +1,57 @@ +# Copyright 2020 Studio73 - Miguel Gandia +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from odoo import Command + +from odoo.addons.base.tests.common import BaseCommon + + +class TestProductTemplateAttributeValue(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + + product_attributes = cls.env["product.attribute"].create( + [ + {"name": "PA1_test", "create_variant": "always", "sequence": 1}, + {"name": "PA2_test", "create_variant": "always", "sequence": 2}, + {"name": "PA3_test", "create_variant": "dynamic", "sequence": 3}, + {"name": "PA4_test", "create_variant": "no_variant", "sequence": 4}, + ] + ) + + cls.env["product.attribute.value"].create( + [ + { + "name": "PAV" + str(product_attribute.sequence) + str(i), + "html_color": "#24292e", + "attribute_id": product_attribute.id, + } + for i in range(1, 3) + for product_attribute in product_attributes + ] + ) + + cls.matrix_template2 = cls.env["product.template"].create( + { + "name": "Matrix", + "type": "consu", + "uom_id": cls.env.ref("uom.product_uom_unit").id, + "uom_po_id": cls.env.ref("uom.product_uom_unit").id, + "attribute_line_ids": [ + Command.create( + { + "attribute_id": attribute.id, + "value_ids": [Command.set(attribute.value_ids.ids)], + }, + ) + for attribute in product_attributes + ], + } + ) + + def test_01_check__html_color_matrix(self): + matrix = self.matrix_template2._get_template_matrix() + self.assertEqual( + matrix["header"][1]["html_color"], "#24292e", "Html color does not match" + ) diff --git a/setup/product_matrix_show_color/odoo/addons/product_matrix_show_color b/setup/product_matrix_show_color/odoo/addons/product_matrix_show_color new file mode 120000 index 000000000..e44ad5559 --- /dev/null +++ b/setup/product_matrix_show_color/odoo/addons/product_matrix_show_color @@ -0,0 +1 @@ +../../../../product_matrix_show_color \ No newline at end of file diff --git a/setup/product_matrix_show_color/setup.py b/setup/product_matrix_show_color/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/product_matrix_show_color/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)