diff --git a/product_company_default/README.rst b/product_company_default/README.rst new file mode 100644 index 00000000000..dd9c734d17e --- /dev/null +++ b/product_company_default/README.rst @@ -0,0 +1,88 @@ +======================= +Product Company Default +======================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:d1775ceb80c8eb6e0c4c8689c19f97df927830171283af4c7ffc9f4fe22419f5 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_company_default + :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_company_default + :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| + +This module populates the company field with user's company as the +default value when creating new products. + +**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 +------- + +* Quartile Limited + +Contributors +------------ + +- Aung Ko Ko Lin (Quartile) +- `APSL-Nagarro `__: + + - Antoni Marroig + +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. + +.. |maintainer-AungKoKoLin1997| image:: https://github.com/AungKoKoLin1997.png?size=40px + :target: https://github.com/AungKoKoLin1997 + :alt: AungKoKoLin1997 + +Current `maintainer `__: + +|maintainer-AungKoKoLin1997| + +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_company_default/__init__.py b/product_company_default/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/product_company_default/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/product_company_default/__manifest__.py b/product_company_default/__manifest__.py new file mode 100644 index 00000000000..eb09ee4984a --- /dev/null +++ b/product_company_default/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2023 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Product Company Default", + "version": "17.0.1.0.0", + "author": "Quartile Limited, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/product-attribute", + "depends": ["product"], + "maintainers": ["AungKoKoLin1997"], + "license": "AGPL-3", + "data": ["data/ir_config_parameter.xml"], + "demo": ["demo/demo_ir_config_parameter.xml"], + "installable": True, +} diff --git a/product_company_default/data/ir_config_parameter.xml b/product_company_default/data/ir_config_parameter.xml new file mode 100644 index 00000000000..6777b7829ba --- /dev/null +++ b/product_company_default/data/ir_config_parameter.xml @@ -0,0 +1,8 @@ + + + + + product_company_default.default_company_enable + 1 + + diff --git a/product_company_default/demo/demo_ir_config_parameter.xml b/product_company_default/demo/demo_ir_config_parameter.xml new file mode 100644 index 00000000000..0ac5f959632 --- /dev/null +++ b/product_company_default/demo/demo_ir_config_parameter.xml @@ -0,0 +1,8 @@ + + + + + product_company_default.default_company_enable + 0 + + diff --git a/product_company_default/i18n/it.po b/product_company_default/i18n/it.po new file mode 100644 index 00000000000..d27c025c79d --- /dev/null +++ b/product_company_default/i18n/it.po @@ -0,0 +1,28 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_company_default +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-11-07 09:39+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_company_default +#: model:ir.model.fields,field_description:product_company_default.field_product_product__company_id +#: model:ir.model.fields,field_description:product_company_default.field_product_template__company_id +msgid "Company" +msgstr "Azienda" + +#. module: product_company_default +#: model:ir.model,name:product_company_default.model_product_template +msgid "Product" +msgstr "Prodotto" diff --git a/product_company_default/i18n/product_company_default.pot b/product_company_default/i18n/product_company_default.pot new file mode 100644 index 00000000000..f18a184881c --- /dev/null +++ b/product_company_default/i18n/product_company_default.pot @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_company_default +# +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_company_default +#: model:ir.model.fields,field_description:product_company_default.field_product_product__company_id +#: model:ir.model.fields,field_description:product_company_default.field_product_template__company_id +msgid "Company" +msgstr "" + +#. module: product_company_default +#: model:ir.model,name:product_company_default.model_product_template +msgid "Product" +msgstr "" diff --git a/product_company_default/models/__init__.py b/product_company_default/models/__init__.py new file mode 100644 index 00000000000..e8fa8f6bf1e --- /dev/null +++ b/product_company_default/models/__init__.py @@ -0,0 +1 @@ +from . import product_template diff --git a/product_company_default/models/product_template.py b/product_company_default/models/product_template.py new file mode 100644 index 00000000000..fab5f479189 --- /dev/null +++ b/product_company_default/models/product_template.py @@ -0,0 +1,22 @@ +# Copyright 2023 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + company_id = fields.Many2one(default=lambda self: self._default_company_id()) + + @api.model + def _default_company_id(self): + # Get the system parameter configuration + param = ( + self.env["ir.config_parameter"] + .sudo() + .get_param("product_company_default.default_company_enable") + ) + if param == "1": + return self.env.company + return False diff --git a/product_company_default/pyproject.toml b/product_company_default/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/product_company_default/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/product_company_default/readme/CONTRIBUTORS.md b/product_company_default/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..bb096f0bac0 --- /dev/null +++ b/product_company_default/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Aung Ko Ko Lin (Quartile) +- [APSL-Nagarro](): + - Antoni Marroig \<\> \ No newline at end of file diff --git a/product_company_default/readme/DESCRIPTION.md b/product_company_default/readme/DESCRIPTION.md new file mode 100644 index 00000000000..08837b27c19 --- /dev/null +++ b/product_company_default/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module populates the company field with user's company as the +default value when creating new products. diff --git a/product_company_default/static/description/icon.png b/product_company_default/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/product_company_default/static/description/icon.png differ diff --git a/product_company_default/static/description/index.html b/product_company_default/static/description/index.html new file mode 100644 index 00000000000..1269d2d7258 --- /dev/null +++ b/product_company_default/static/description/index.html @@ -0,0 +1,430 @@ + + + + + +Product Company Default + + + +
+

Product Company Default

+ + +

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

+

This module populates the company field with user’s company as the +default value when creating new products.

+

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

+
    +
  • Quartile Limited
  • +
+
+
+

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.

+

Current maintainer:

+

AungKoKoLin1997

+

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_company_default/tests/__init__.py b/product_company_default/tests/__init__.py new file mode 100644 index 00000000000..c1bcf9f65ae --- /dev/null +++ b/product_company_default/tests/__init__.py @@ -0,0 +1 @@ +from . import test_product_company_default diff --git a/product_company_default/tests/test_product_company_default.py b/product_company_default/tests/test_product_company_default.py new file mode 100644 index 00000000000..11bd8cbd91c --- /dev/null +++ b/product_company_default/tests/test_product_company_default.py @@ -0,0 +1,16 @@ +from odoo.tests.common import TransactionCase + + +class TestProductCompanyDefault(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + # Enable the configuration using ir.config_parameter + cls.env["ir.config_parameter"].sudo().set_param( + "product_company_default.default_company_enable", "1" + ) + + def test_product_company(self): + # Create a sample product + product = self.env["product.product"].create({"name": "Test Product"}) + self.assertEqual(product.company_id, self.env.company)