diff --git a/product_supplierinfo_code/README.rst b/product_supplierinfo_code/README.rst new file mode 100644 index 000000000000..816dd8352bc4 --- /dev/null +++ b/product_supplierinfo_code/README.rst @@ -0,0 +1,79 @@ +========================= +Product Supplierinfo Code +========================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:d30f93de41035a3961a464ca7a98264c9040845176dea8a62558ea3a72f093a9 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/17.0/product_supplierinfo_code + :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-17-0/product-attribute-17-0-product_supplierinfo_code + :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=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Allows to retrieve main supplier product code on product level. + +**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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* ACSONE SA/NV + +Contributors +------------ + +- Denis Roussel +- `360ERP `__: + + - Andrea Stirpe + +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_supplierinfo_code/__init__.py b/product_supplierinfo_code/__init__.py new file mode 100644 index 000000000000..0650744f6bc6 --- /dev/null +++ b/product_supplierinfo_code/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/product_supplierinfo_code/__manifest__.py b/product_supplierinfo_code/__manifest__.py new file mode 100644 index 000000000000..01928b7f80ec --- /dev/null +++ b/product_supplierinfo_code/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Product Supplierinfo Code", + "summary": """ + Allows to get main supplierinfo product_code on product level""", + "version": "17.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": [ + "views/product_template.xml", + ], +} diff --git a/product_supplierinfo_code/i18n/es.po b/product_supplierinfo_code/i18n/es.po new file mode 100644 index 000000000000..c1e56fbf14f8 --- /dev/null +++ b/product_supplierinfo_code/i18n/es.po @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_supplierinfo_code +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-03-26 22:36+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_supplierinfo_code +#: model:ir.model,name:product_supplierinfo_code.model_product_template +msgid "Product" +msgstr "Producto" + +#. module: product_supplierinfo_code +#: model_terms:ir.ui.view,arch_db:product_supplierinfo_code.product_template_kanban_view +msgid "Supplier Code:" +msgstr "Código Proveedor:" + +#. module: product_supplierinfo_code +#: model:ir.model.fields,field_description:product_supplierinfo_code.field_product_product__supplier_product_code +#: model:ir.model.fields,field_description:product_supplierinfo_code.field_product_template__supplier_product_code +#: model_terms:ir.ui.view,arch_db:product_supplierinfo_code.product_template_search_view +msgid "Supplier Product Code" +msgstr "Código producto proveedor" + +#. module: product_supplierinfo_code +#: model:ir.model.fields,help:product_supplierinfo_code.field_product_product__supplier_product_code +#: model:ir.model.fields,help:product_supplierinfo_code.field_product_template__supplier_product_code +msgid "This is the supplier product code from Main Supplier." +msgstr "Este es el código de producto del proveedor principal." diff --git a/product_supplierinfo_code/i18n/it.po b/product_supplierinfo_code/i18n/it.po new file mode 100644 index 000000000000..032d961e508f --- /dev/null +++ b/product_supplierinfo_code/i18n/it.po @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_supplierinfo_code +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-03-12 13:33+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_supplierinfo_code +#: model:ir.model,name:product_supplierinfo_code.model_product_template +msgid "Product" +msgstr "Prodotto" + +#. module: product_supplierinfo_code +#: model_terms:ir.ui.view,arch_db:product_supplierinfo_code.product_template_kanban_view +msgid "Supplier Code:" +msgstr "Codice fornitore:" + +#. module: product_supplierinfo_code +#: model:ir.model.fields,field_description:product_supplierinfo_code.field_product_product__supplier_product_code +#: model:ir.model.fields,field_description:product_supplierinfo_code.field_product_template__supplier_product_code +#: model_terms:ir.ui.view,arch_db:product_supplierinfo_code.product_template_search_view +msgid "Supplier Product Code" +msgstr "Codice prodotto fornitore" + +#. module: product_supplierinfo_code +#: model:ir.model.fields,help:product_supplierinfo_code.field_product_product__supplier_product_code +#: model:ir.model.fields,help:product_supplierinfo_code.field_product_template__supplier_product_code +msgid "This is the supplier product code from Main Supplier." +msgstr "Questo è il codice prodotto fornitore da fornitore principale." diff --git a/product_supplierinfo_code/i18n/product_supplierinfo_code.pot b/product_supplierinfo_code/i18n/product_supplierinfo_code.pot new file mode 100644 index 000000000000..1c6e924894fc --- /dev/null +++ b/product_supplierinfo_code/i18n/product_supplierinfo_code.pot @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_supplierinfo_code +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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_supplierinfo_code +#: model:ir.model,name:product_supplierinfo_code.model_product_template +msgid "Product" +msgstr "" + +#. module: product_supplierinfo_code +#: model_terms:ir.ui.view,arch_db:product_supplierinfo_code.product_template_kanban_view +msgid "Supplier Code:" +msgstr "" + +#. module: product_supplierinfo_code +#: model:ir.model.fields,field_description:product_supplierinfo_code.field_product_product__supplier_product_code +#: model:ir.model.fields,field_description:product_supplierinfo_code.field_product_template__supplier_product_code +#: model_terms:ir.ui.view,arch_db:product_supplierinfo_code.product_template_search_view +msgid "Supplier Product Code" +msgstr "" + +#. module: product_supplierinfo_code +#: model:ir.model.fields,help:product_supplierinfo_code.field_product_product__supplier_product_code +#: model:ir.model.fields,help:product_supplierinfo_code.field_product_template__supplier_product_code +msgid "This is the supplier product code from Main Supplier." +msgstr "" diff --git a/product_supplierinfo_code/models/__init__.py b/product_supplierinfo_code/models/__init__.py new file mode 100644 index 000000000000..e8fa8f6bf1e0 --- /dev/null +++ b/product_supplierinfo_code/models/__init__.py @@ -0,0 +1 @@ +from . import product_template diff --git a/product_supplierinfo_code/models/product_template.py b/product_supplierinfo_code/models/product_template.py new file mode 100644 index 000000000000..ad64198e375a --- /dev/null +++ b/product_supplierinfo_code/models/product_template.py @@ -0,0 +1,25 @@ +# Copyright 2021 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import api, fields, models +from odoo.fields import first + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + supplier_product_code = fields.Char( + compute="_compute_supplier_product_code", + help="This is the supplier product code from Main Supplier.", + compute_sudo=False, + search="_search_supplier_product_code", + readonly=True, + ) + + def _compute_supplier_product_code(self): + for prod in self: + seller = first(prod.seller_ids) + prod.supplier_product_code = seller.product_code + + @api.model + def _search_supplier_product_code(self, operator, value): + return [("seller_ids.product_code", operator, value)] diff --git a/product_supplierinfo_code/pyproject.toml b/product_supplierinfo_code/pyproject.toml new file mode 100644 index 000000000000..4231d0cccb3d --- /dev/null +++ b/product_supplierinfo_code/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/product_supplierinfo_code/readme/CONTRIBUTORS.md b/product_supplierinfo_code/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..0da68fb1537b --- /dev/null +++ b/product_supplierinfo_code/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Denis Roussel \<\> +- [360ERP](https://www.360erp.com): + - Andrea Stirpe diff --git a/product_supplierinfo_code/readme/DESCRIPTION.md b/product_supplierinfo_code/readme/DESCRIPTION.md new file mode 100644 index 000000000000..223f7a67c5d9 --- /dev/null +++ b/product_supplierinfo_code/readme/DESCRIPTION.md @@ -0,0 +1 @@ +Allows to retrieve main supplier product code on product level. diff --git a/product_supplierinfo_code/static/description/icon.png b/product_supplierinfo_code/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/product_supplierinfo_code/static/description/icon.png differ diff --git a/product_supplierinfo_code/static/description/index.html b/product_supplierinfo_code/static/description/index.html new file mode 100644 index 000000000000..ccef8a780401 --- /dev/null +++ b/product_supplierinfo_code/static/description/index.html @@ -0,0 +1,424 @@ + + + + + +Product Supplierinfo Code + + + +
+

Product Supplierinfo Code

+ + +

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

+

Allows to retrieve main supplier product code on product level.

+

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

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE SA/NV
  • +
+
+
+

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_supplierinfo_code/tests/__init__.py b/product_supplierinfo_code/tests/__init__.py new file mode 100644 index 000000000000..1741fce1f78f --- /dev/null +++ b/product_supplierinfo_code/tests/__init__.py @@ -0,0 +1 @@ +from . import test_supplierinfo_code diff --git a/product_supplierinfo_code/tests/test_supplierinfo_code.py b/product_supplierinfo_code/tests/test_supplierinfo_code.py new file mode 100644 index 000000000000..9af6229ff36d --- /dev/null +++ b/product_supplierinfo_code/tests/test_supplierinfo_code.py @@ -0,0 +1,36 @@ +# Copyright 2021 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo.tests.common import TransactionCase + + +class TestSupplierinfoCode(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + cls.product = cls.env.ref("product.product_product_6_product_template") + cls.product_supplierinfo = cls.env.ref("product.product_supplierinfo_1") + cls.product_supplierinfo2 = cls.env.ref("product.product_supplierinfo_2") + + # Set product code on supplierinfos + cls.product_supplierinfo.product_code = "CODE1" + cls.product_supplierinfo2.product_code = "CODE2" + + # Set sequence on supplierinfos + cls.product.seller_ids.write({"sequence": 10}) + cls.product_supplierinfo.sequence = 1 + cls.product._invalidate_cache() + + def test_supplierinfo_code(self): + """ + Check if first supplier product code is CODE1 + Search for product based on supplier_product_code + """ + self.assertEqual( + self.product.supplier_product_code, + "CODE1", + ) + product = self.product.search([("supplier_product_code", "=", "CODE1")]) + self.assertEqual(product, self.product) + product = self.product.search([("supplier_product_code", "=", "CODE2")]) + self.assertEqual(product, self.product) diff --git a/product_supplierinfo_code/views/product_template.xml b/product_supplierinfo_code/views/product_template.xml new file mode 100644 index 000000000000..d5539c359987 --- /dev/null +++ b/product_supplierinfo_code/views/product_template.xml @@ -0,0 +1,63 @@ + + + + + + product.template.form (in product_supplierinfo_code) + product.template + + + + + + + + + + product.template.search (in product_supplierinfo_code) + product.template + + + + + + + + + + product.template.tree (in product_supplierinfo_code) + product.template + + + + + + + + + + product.template.kanban (in product_supplierinfo_code) + product.template + + + + + +
+
+ Supplier Code: +
+
+
+
+ +