diff --git a/fieldservice_operating_unit/README.rst b/fieldservice_operating_unit/README.rst new file mode 100644 index 0000000000..1ab7e10c6d --- /dev/null +++ b/fieldservice_operating_unit/README.rst @@ -0,0 +1,99 @@ +================================== +Field Service with Operating Units +================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:3c9da5ccbc80d8789bb8f449c9145d75861c0d39a3f6222d05aec95e35b3c379 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Foperating--unit-lightgray.png?logo=github + :target: https://github.com/OCA/operating-unit/tree/15.0/fieldservice_operating_unit + :alt: OCA/operating-unit +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/operating-unit-15-0/operating-unit-15-0-fieldservice_operating_unit + :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/operating-unit&target_branch=15.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds operating unit information to Field Service orders. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +* Go to Field Service +* You only see the FSM orders of your operating units +* Create an order. It is assigned to your default operating unit. + +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 +~~~~~~~ + +* Open Source Integrators +* Serpent Consulting Services Pvt. Ltd. + +Contributors +~~~~~~~~~~~~ + +* Nikul Chaudhary +* Maxime Chambreuil + +Other credits +~~~~~~~~~~~~~ + +* Open Source Integrators +* Serpent Consulting Services Pvt. Ltd. + +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-max3903| image:: https://github.com/max3903.png?size=40px + :target: https://github.com/max3903 + :alt: max3903 + +Current `maintainer `__: + +|maintainer-max3903| + +This module is part of the `OCA/operating-unit `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/fieldservice_operating_unit/__init__.py b/fieldservice_operating_unit/__init__.py new file mode 100644 index 0000000000..0bf91417fc --- /dev/null +++ b/fieldservice_operating_unit/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2021 Open Source Integrators +# Copyright (C) 2021 Serpent Consulting Services +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import models diff --git a/fieldservice_operating_unit/__manifest__.py b/fieldservice_operating_unit/__manifest__.py new file mode 100644 index 0000000000..e179563a7b --- /dev/null +++ b/fieldservice_operating_unit/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright (C) 2021 Open Source Integrators +# Copyright (C) 2021 Serpent Consulting Services +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Field Service with Operating Units", + "summary": """ + This module adds operating unit information to Field Service orders.""", + "version": "15.0.1.0.0", + "author": "Open Source Integrators, " + "Serpent Consulting Services Pvt. Ltd.," + "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/operating-unit", + "category": "Field Service", + "depends": ["operating_unit", "fieldservice"], + "license": "AGPL-3", + "data": [ + "security/fieldservice_security.xml", + "views/fsm_order.xml", + ], + "installable": True, + "development_status": "Beta", + "maintainers": [ + "max3903", + ], +} diff --git a/fieldservice_operating_unit/i18n/fieldservice_operating_unit.pot b/fieldservice_operating_unit/i18n/fieldservice_operating_unit.pot new file mode 100644 index 0000000000..85c51ca091 --- /dev/null +++ b/fieldservice_operating_unit/i18n/fieldservice_operating_unit.pot @@ -0,0 +1,39 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_operating_unit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.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: fieldservice_operating_unit +#: model:ir.model,name:fieldservice_operating_unit.model_fsm_order +msgid "Field Service Order" +msgstr "" + +#. module: fieldservice_operating_unit +#: model:ir.model.fields,field_description:fieldservice_operating_unit.field_fsm_order__id +msgid "ID" +msgstr "" + +#. module: fieldservice_operating_unit +#: model:ir.model.fields,field_description:fieldservice_operating_unit.field_fsm_order____last_update +msgid "Last Modified on" +msgstr "" + +#. module: fieldservice_operating_unit +#: model:ir.model.fields,field_description:fieldservice_operating_unit.field_fsm_order__operating_unit_id +msgid "Operating Unit" +msgstr "" + +#. module: fieldservice_operating_unit +#: model:ir.model.fields,field_description:fieldservice_operating_unit.field_fsm_order__display_name +msgid "Order" +msgstr "" diff --git a/fieldservice_operating_unit/i18n/fr.po b/fieldservice_operating_unit/i18n/fr.po new file mode 100644 index 0000000000..4dae2d6599 --- /dev/null +++ b/fieldservice_operating_unit/i18n/fr.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_operating_unit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-06-28 11:05+0000\n" +"Last-Translator: Khalid Hazam \n" +"Language-Team: none\n" +"Language: fr\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.3.2\n" + +#. module: fieldservice_operating_unit +#: model:ir.model,name:fieldservice_operating_unit.model_fsm_order +#, fuzzy +msgid "Field Service Order" +msgstr "Ordre de mission" + +#. module: fieldservice_operating_unit +#: model:ir.model.fields,field_description:fieldservice_operating_unit.field_fsm_order__id +msgid "ID" +msgstr "ID" + +#. module: fieldservice_operating_unit +#: model:ir.model.fields,field_description:fieldservice_operating_unit.field_fsm_order____last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: fieldservice_operating_unit +#: model:ir.model.fields,field_description:fieldservice_operating_unit.field_fsm_order__operating_unit_id +msgid "Operating Unit" +msgstr "Unité opérationnelle" + +#. module: fieldservice_operating_unit +#: model:ir.model.fields,field_description:fieldservice_operating_unit.field_fsm_order__display_name +msgid "Order" +msgstr "Ordre" diff --git a/fieldservice_operating_unit/i18n/it.po b/fieldservice_operating_unit/i18n/it.po new file mode 100644 index 0000000000..e78f1321a2 --- /dev/null +++ b/fieldservice_operating_unit/i18n/it.po @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_operating_unit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-07-23 17:25+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 5.10.4\n" + +#. module: fieldservice_operating_unit +#: model:ir.model,name:fieldservice_operating_unit.model_fsm_order +msgid "Field Service Order" +msgstr "Ordine assistenza sul campo" + +#. module: fieldservice_operating_unit +#: model:ir.model.fields,field_description:fieldservice_operating_unit.field_fsm_order__id +msgid "ID" +msgstr "ID" + +#. module: fieldservice_operating_unit +#: model:ir.model.fields,field_description:fieldservice_operating_unit.field_fsm_order____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: fieldservice_operating_unit +#: model:ir.model.fields,field_description:fieldservice_operating_unit.field_fsm_order__operating_unit_id +msgid "Operating Unit" +msgstr "Unità operativa" + +#. module: fieldservice_operating_unit +#: model:ir.model.fields,field_description:fieldservice_operating_unit.field_fsm_order__display_name +msgid "Order" +msgstr "Ordine" diff --git a/fieldservice_operating_unit/i18n/pt.po b/fieldservice_operating_unit/i18n/pt.po new file mode 100644 index 0000000000..ac80be9c6b --- /dev/null +++ b/fieldservice_operating_unit/i18n/pt.po @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_operating_unit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: pt\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" + +#. module: fieldservice_operating_unit +#: model:ir.model,name:fieldservice_operating_unit.model_fsm_order +msgid "Field Service Order" +msgstr "" + +#. module: fieldservice_operating_unit +#: model:ir.model.fields,field_description:fieldservice_operating_unit.field_fsm_order__id +msgid "ID" +msgstr "" + +#. module: fieldservice_operating_unit +#: model:ir.model.fields,field_description:fieldservice_operating_unit.field_fsm_order____last_update +msgid "Last Modified on" +msgstr "" + +#. module: fieldservice_operating_unit +#: model:ir.model.fields,field_description:fieldservice_operating_unit.field_fsm_order__operating_unit_id +msgid "Operating Unit" +msgstr "" + +#. module: fieldservice_operating_unit +#: model:ir.model.fields,field_description:fieldservice_operating_unit.field_fsm_order__display_name +msgid "Order" +msgstr "" diff --git a/fieldservice_operating_unit/models/__init__.py b/fieldservice_operating_unit/models/__init__.py new file mode 100644 index 0000000000..9b363ee05a --- /dev/null +++ b/fieldservice_operating_unit/models/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import fsm_order diff --git a/fieldservice_operating_unit/models/fsm_order.py b/fieldservice_operating_unit/models/fsm_order.py new file mode 100644 index 0000000000..5dccb29139 --- /dev/null +++ b/fieldservice_operating_unit/models/fsm_order.py @@ -0,0 +1,14 @@ +# Copyright (C) 2021 Open Source Integrators +# Copyright (C) 2021 Serpent Consulting Services +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class FSMOrder(models.Model): + _inherit = "fsm.order" + + operating_unit_id = fields.Many2one( + comodel_name="operating.unit", + string="Operating Unit", + default=lambda self: self.env.user.default_operating_unit_id, + ) diff --git a/fieldservice_operating_unit/readme/CONTRIBUTORS.rst b/fieldservice_operating_unit/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..e61704632a --- /dev/null +++ b/fieldservice_operating_unit/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Nikul Chaudhary +* Maxime Chambreuil diff --git a/fieldservice_operating_unit/readme/CREDITS.rst b/fieldservice_operating_unit/readme/CREDITS.rst new file mode 100644 index 0000000000..bfc05668a8 --- /dev/null +++ b/fieldservice_operating_unit/readme/CREDITS.rst @@ -0,0 +1,2 @@ +* Open Source Integrators +* Serpent Consulting Services Pvt. Ltd. diff --git a/fieldservice_operating_unit/readme/DESCRIPTION.rst b/fieldservice_operating_unit/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..6c6723b0a0 --- /dev/null +++ b/fieldservice_operating_unit/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module adds operating unit information to Field Service orders. diff --git a/fieldservice_operating_unit/readme/USAGE.rst b/fieldservice_operating_unit/readme/USAGE.rst new file mode 100644 index 0000000000..a572667e9a --- /dev/null +++ b/fieldservice_operating_unit/readme/USAGE.rst @@ -0,0 +1,3 @@ +* Go to Field Service +* You only see the FSM orders of your operating units +* Create an order. It is assigned to your default operating unit. diff --git a/fieldservice_operating_unit/security/fieldservice_security.xml b/fieldservice_operating_unit/security/fieldservice_security.xml new file mode 100644 index 0000000000..9b1d07a0fe --- /dev/null +++ b/fieldservice_operating_unit/security/fieldservice_security.xml @@ -0,0 +1,21 @@ + + + + + + + ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',user.operating_unit_ids.ids)] + + Field Service Operating Unit + + + + + + + + diff --git a/fieldservice_operating_unit/static/description/icon.png b/fieldservice_operating_unit/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/fieldservice_operating_unit/static/description/icon.png differ diff --git a/fieldservice_operating_unit/static/description/index.html b/fieldservice_operating_unit/static/description/index.html new file mode 100644 index 0000000000..7b78494ee5 --- /dev/null +++ b/fieldservice_operating_unit/static/description/index.html @@ -0,0 +1,444 @@ + + + + + +Field Service with Operating Units + + + +
+

Field Service with Operating Units

+ + +

Beta License: AGPL-3 OCA/operating-unit Translate me on Weblate Try me on Runboat

+

This module adds operating unit information to Field Service orders.

+

Table of contents

+ +
+

Usage

+
    +
  • Go to Field Service
  • +
  • You only see the FSM orders of your operating units
  • +
  • Create an order. It is assigned to your default operating unit.
  • +
+
+
+

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

+
    +
  • Open Source Integrators
  • +
  • Serpent Consulting Services Pvt. Ltd.
  • +
+
+ +
+

Other credits

+
    +
  • Open Source Integrators
  • +
  • Serpent Consulting Services Pvt. Ltd.
  • +
+
+
+

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:

+

max3903

+

This module is part of the OCA/operating-unit project on GitHub.

+

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

+
+
+
+ + diff --git a/fieldservice_operating_unit/tests/__init__.py b/fieldservice_operating_unit/tests/__init__.py new file mode 100644 index 0000000000..98ffc0b3de --- /dev/null +++ b/fieldservice_operating_unit/tests/__init__.py @@ -0,0 +1,5 @@ +# Copyright (C) 2021 Open Source Integrators +# Copyright (C) 2021 Serpent Consulting Services +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_fieldservice_operating_unit diff --git a/fieldservice_operating_unit/tests/test_fieldservice_operating_unit.py b/fieldservice_operating_unit/tests/test_fieldservice_operating_unit.py new file mode 100644 index 0000000000..1f1a0267d2 --- /dev/null +++ b/fieldservice_operating_unit/tests/test_fieldservice_operating_unit.py @@ -0,0 +1,88 @@ +# Copyright (C) 2021 Open Source Integrators +# Copyright (C) 2021 Serpent Consulting Services +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from datetime import timedelta + +from odoo import fields +from odoo.tests import common + + +class TestFSMOrder(common.TransactionCase): + def setUp(self): + super(TestFSMOrder, self).setUp() + self.fsm_order_obj = self.env["fsm.order"] + self.res_users_model = self.env["res.users"] + self.test_location = self.env.ref("fieldservice.test_location") + + # Groups + self.grp_fieldservice_mngr = self.env.ref("fieldservice.group_fsm_manager") + self.grp_user = self.env.ref("base.group_user") + # Company + self.company = self.env.ref("base.main_company") + # Main Operating Unit + self.main_OU = self.env.ref("operating_unit.main_operating_unit") + # B2C Operating Unit + self.b2c_OU = self.env.ref("operating_unit.b2c_operating_unit") + # Create User 1 with Main OU + self.user1 = self._create_user( + "user_1", + [self.grp_fieldservice_mngr, self.grp_user], + self.company, + [self.main_OU], + ) + # Create User 2 with B2C OU + self.user2 = self._create_user( + "user_2", + [self.grp_fieldservice_mngr, self.grp_user], + self.company, + [self.b2c_OU], + ) + + self.fsm_order1 = self._create_fsm_order(self.user1, self.main_OU) + self.fsm_order2 = self._create_fsm_order(self.user2, self.b2c_OU) + + def _create_user(self, login, groups, company, operating_units): + """Create a user.""" + group_ids = [group.id for group in groups] + user = self.res_users_model.create( + { + "name": login, + "login": login, + "password": "demo", + "email": "test@yourcompany.com", + "company_id": company.id, + "company_ids": [(4, company.id)], + "operating_unit_ids": [(4, ou.id) for ou in operating_units], + "groups_id": [(6, 0, group_ids)], + } + ) + return user + + def _create_fsm_order(self, uid, operating_unit): + fsm_order = self.fsm_order_obj.with_user(uid).create( + { + "location_id": self.test_location.id, + "operating_unit_id": operating_unit.id, + "date_start": fields.Datetime.today(), + "date_end": fields.Datetime.today() + timedelta(hours=100), + "request_early": fields.Datetime.today(), + } + ) + return fsm_order + + def test_fsm_order(self): + # User 2 is only assigned to B2C Operating Unit, and cannot + # access FSM Orders for Main Operating Unit. + fsm_orders = self.fsm_order_obj.with_user(self.user2).search( + [ + ("id", "=", self.fsm_order2.id), + ("operating_unit_id", "=", self.main_OU.id), + ] + ) + self.assertEqual( + fsm_orders.ids, + [], + "User 2 should not have access to " "%s" % self.main_OU.name, + ) + + self.assertEqual(self.fsm_order1.operating_unit_id.id, self.main_OU.id) diff --git a/fieldservice_operating_unit/views/fsm_order.xml b/fieldservice_operating_unit/views/fsm_order.xml new file mode 100644 index 0000000000..51da56080a --- /dev/null +++ b/fieldservice_operating_unit/views/fsm_order.xml @@ -0,0 +1,17 @@ + + + + + fsm.order.form + fsm.order + + + + + + + + + diff --git a/setup/fieldservice_operating_unit/odoo/addons/fieldservice_operating_unit b/setup/fieldservice_operating_unit/odoo/addons/fieldservice_operating_unit new file mode 120000 index 0000000000..1c33015a8b --- /dev/null +++ b/setup/fieldservice_operating_unit/odoo/addons/fieldservice_operating_unit @@ -0,0 +1 @@ +../../../../fieldservice_operating_unit \ No newline at end of file diff --git a/setup/fieldservice_operating_unit/setup.py b/setup/fieldservice_operating_unit/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/fieldservice_operating_unit/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)