diff --git a/pos_category_multi_company/README.rst b/pos_category_multi_company/README.rst new file mode 100644 index 00000000000..16d222a05bf --- /dev/null +++ b/pos_category_multi_company/README.rst @@ -0,0 +1,85 @@ +========================== +Pos Category multi-company +========================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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%2Fmulti--company-lightgray.png?logo=github + :target: https://github.com/OCA/multi-company/tree/13.0/pos_category_multi_company + :alt: OCA/multi-company +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/multi-company-13-0/multi-company-13-0-pos_category_multi_company + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/133/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This modules allows to select in which of the companies you want to use each of the pos categories. + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +Just install + +Usage +===== + +On the pos category form view, put the companies +in which you want to use that pos category. If none is selected, the pos category will +be visible in all of them. The default value is the current one. + +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 +~~~~~~~ + +* Camptocamp + +Contributors +~~~~~~~~~~~~ + +* Damien Crier + +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/multi-company `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/pos_category_multi_company/__init__.py b/pos_category_multi_company/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/pos_category_multi_company/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_category_multi_company/__manifest__.py b/pos_category_multi_company/__manifest__.py new file mode 100644 index 00000000000..ac0f04d3270 --- /dev/null +++ b/pos_category_multi_company/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2021 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Pos category multi-company", + "summary": "Select individually the pos categories visibility on each company", + "author": "Camptocamp," "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/multi-company", + "category": "Point of Sale", + "version": "13.0.1.0.0", + "license": "AGPL-3", + "depends": ["base_multi_company", "point_of_sale"], + "data": ["views/pos_category_view.xml"], +} diff --git a/pos_category_multi_company/models/__init__.py b/pos_category_multi_company/models/__init__.py new file mode 100644 index 00000000000..0912c531e5d --- /dev/null +++ b/pos_category_multi_company/models/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2021 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import pos_category diff --git a/pos_category_multi_company/models/pos_category.py b/pos_category_multi_company/models/pos_category.py new file mode 100644 index 00000000000..50e89beb315 --- /dev/null +++ b/pos_category_multi_company/models/pos_category.py @@ -0,0 +1,9 @@ +# Copyright 2021 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class PosCategory(models.Model): + _inherit = ["multi.company.abstract", "pos.category"] + _name = "pos.category" diff --git a/pos_category_multi_company/readme/CONTRIBUTORS.rst b/pos_category_multi_company/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..f24b9d52679 --- /dev/null +++ b/pos_category_multi_company/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Damien Crier diff --git a/pos_category_multi_company/readme/DESCRIPTION.rst b/pos_category_multi_company/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..4592f4794e6 --- /dev/null +++ b/pos_category_multi_company/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This modules allows to select in which of the companies you want to use each of the pos categories. diff --git a/pos_category_multi_company/readme/INSTALL.rst b/pos_category_multi_company/readme/INSTALL.rst new file mode 100644 index 00000000000..95c0bc85923 --- /dev/null +++ b/pos_category_multi_company/readme/INSTALL.rst @@ -0,0 +1 @@ +Just install it diff --git a/pos_category_multi_company/readme/USAGE.rst b/pos_category_multi_company/readme/USAGE.rst new file mode 100644 index 00000000000..45edaaea23a --- /dev/null +++ b/pos_category_multi_company/readme/USAGE.rst @@ -0,0 +1,3 @@ +On the pos category form view, put the companies +in which you want to use that pos category. If none is selected, the pos category will +be visible in all of them. The default value is the current one. diff --git a/pos_category_multi_company/tests/__init__.py b/pos_category_multi_company/tests/__init__.py new file mode 100644 index 00000000000..a10f3b3525d --- /dev/null +++ b/pos_category_multi_company/tests/__init__.py @@ -0,0 +1 @@ +from . import test_pos_category_multi_company diff --git a/pos_category_multi_company/tests/test_pos_category_multi_company.py b/pos_category_multi_company/tests/test_pos_category_multi_company.py new file mode 100644 index 00000000000..2436ad32113 --- /dev/null +++ b/pos_category_multi_company/tests/test_pos_category_multi_company.py @@ -0,0 +1,78 @@ +# Copyright 2021 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests import common + + +@common.at_install(False) +@common.post_install(True) +class TestPosCategoryMultiCompany(common.TransactionCase): + def setUp(self): + super().setUp() + groups = self.env.ref("base.group_system") + self.company_1 = self.env["res.company"].create({"name": "Test company 1"}) + self.company_2 = self.env["res.company"].create({"name": "Test company 2"}) + self.pos_category = self.env["pos.category"] + self.pos_category_company_none = self.pos_category.create( + { + "name": "Product without company", + "company_ids": [(6, 0, [])], + "company_id": False, + } + ) + self.pos_category_company_1 = self.pos_category.create( + { + "name": "Pos category from company 1", + "company_ids": [(6, 0, self.company_1.ids)], + } + ) + self.pos_category_company_2 = self.pos_category.create( + { + "name": "Pos category from company 2", + "company_ids": [(6, 0, self.company_2.ids)], + } + ) + self.pos_category_company_both = self.pos_category.create( + { + "name": "Pos category for both companies", + "company_ids": [(6, 0, (self.company_1 + self.company_2).ids)], + } + ) + self.user_company_1 = self.env["res.users"].create( + { + "name": "User company 1", + "login": "user_company_1", + "groups_id": [(6, 0, groups.ids)], + "company_id": self.company_1.id, + "company_ids": [(6, 0, self.company_1.ids)], + } + ) + self.user_company_2 = self.env["res.users"].create( + { + "name": "User company 2", + "login": "user_company_2", + "groups_id": [(6, 0, groups.ids)], + "company_id": self.company_2.id, + "company_ids": [(6, 0, self.company_2.ids)], + } + ) + + def test_create_pos_category(self): + pos_category = self.pos_category.create({"name": "Test"}) + company = self.env.company + self.assertTrue(company.id in pos_category.company_ids.ids) + + def test_company_none(self): + self.assertFalse(self.pos_category_company_none.company_id) + + def test_company_1(self): + self.assertEqual( + self.pos_category_company_1.with_user(self.user_company_1).company_id, + self.company_1, + ) + + def test_company_2(self): + self.assertEqual( + self.pos_category_company_2.with_user(self.user_company_2).company_id, + self.company_2, + ) diff --git a/pos_category_multi_company/views/pos_category_view.xml b/pos_category_multi_company/views/pos_category_view.xml new file mode 100644 index 00000000000..5a952036d37 --- /dev/null +++ b/pos_category_multi_company/views/pos_category_view.xml @@ -0,0 +1,23 @@ + + + + Pos category form view (with multi-company) + pos.category + + + + + + + + +