diff --git a/fieldservice_sale_agreement/README.rst b/fieldservice_sale_agreement/README.rst new file mode 100644 index 0000000000..8a59eac97f --- /dev/null +++ b/fieldservice_sale_agreement/README.rst @@ -0,0 +1,89 @@ +=============================== +Field Service - Sale Agreements +=============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:51e39dfe70b9f047e57fb1bddb25c479a39139d3388fbcf2ca252ae9d409ec16 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Ffield--service-lightgray.png?logo=github + :target: https://github.com/OCA/field-service/tree/17.0/fieldservice_sale_agreement + :alt: OCA/field-service +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/field-service-17-0/field-service-17-0-fieldservice_sale_agreement + :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/field-service&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Integrates the Field Service and Sale Agreements modules, to: + +- Propagate the ``agreement_id`` field from the Sales Order to the FSM + Order + +**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 +------- + +* Camptocamp + +Contributors +------------ + +- `Camptocamp `__: + + - Iván Todorovich + +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-ivantodorovich| image:: https://github.com/ivantodorovich.png?size=40px + :target: https://github.com/ivantodorovich + :alt: ivantodorovich + +Current `maintainer `__: + +|maintainer-ivantodorovich| + +This module is part of the `OCA/field-service `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/fieldservice_sale_agreement/__init__.py b/fieldservice_sale_agreement/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/fieldservice_sale_agreement/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/fieldservice_sale_agreement/__manifest__.py b/fieldservice_sale_agreement/__manifest__.py new file mode 100644 index 0000000000..646625831e --- /dev/null +++ b/fieldservice_sale_agreement/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2024 Camptocamp SA (https://www.camptocamp.com). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Field Service - Sale Agreements", + "summary": "Integrate Field Service with Sale Agreements", + "version": "17.0.1.0.0", + "author": "Camptocamp, Odoo Community Association (OCA)", + "maintainers": ["ivantodorovich"], + "website": "https://github.com/OCA/field-service", + "license": "AGPL-3", + "category": "Field Service", + "depends": [ + "fieldservice_agreement", + "fieldservice_sale", + "agreement_sale", + ], + "auto_install": True, +} diff --git a/fieldservice_sale_agreement/models/__init__.py b/fieldservice_sale_agreement/models/__init__.py new file mode 100644 index 0000000000..6aacb75313 --- /dev/null +++ b/fieldservice_sale_agreement/models/__init__.py @@ -0,0 +1 @@ +from . import sale_order diff --git a/fieldservice_sale_agreement/models/sale_order.py b/fieldservice_sale_agreement/models/sale_order.py new file mode 100644 index 0000000000..521b65b1bc --- /dev/null +++ b/fieldservice_sale_agreement/models/sale_order.py @@ -0,0 +1,14 @@ +# Copyright 2024 Camptocamp SA (https://www.camptocamp.com). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class SaleOrder(models.Model): + _inherit = "sale.order" + + def _prepare_fsm_values(self, **kwargs): + # OVERRIDE to propagate the agreement_id to the FSM Order + res = super()._prepare_fsm_values(**kwargs) + res.update({"agreement_id": self.agreement_id.id}) + return res diff --git a/fieldservice_sale_agreement/pyproject.toml b/fieldservice_sale_agreement/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/fieldservice_sale_agreement/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/fieldservice_sale_agreement/readme/CONTRIBUTORS.md b/fieldservice_sale_agreement/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..4fa5a70e1d --- /dev/null +++ b/fieldservice_sale_agreement/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [Camptocamp](https://camptocamp.com): + + - Iván Todorovich \<\> diff --git a/fieldservice_sale_agreement/readme/DESCRIPTION.md b/fieldservice_sale_agreement/readme/DESCRIPTION.md new file mode 100644 index 0000000000..3d5836afe8 --- /dev/null +++ b/fieldservice_sale_agreement/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +Integrates the Field Service and Sale Agreements modules, to: + +* Propagate the `agreement_id` field from the Sales Order to the FSM Order diff --git a/fieldservice_sale_agreement/static/description/index.html b/fieldservice_sale_agreement/static/description/index.html new file mode 100644 index 0000000000..e26878885e --- /dev/null +++ b/fieldservice_sale_agreement/static/description/index.html @@ -0,0 +1,432 @@ + + + + + +Field Service - Sale Agreements + + + +
+

Field Service - Sale Agreements

+ + +

Beta License: AGPL-3 OCA/field-service Translate me on Weblate Try me on Runboat

+

Integrates the Field Service and Sale Agreements modules, to:

+
    +
  • Propagate the agreement_id field from the Sales Order to the FSM +Order
  • +
+

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

+
    +
  • Camptocamp
  • +
+
+
+

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:

+

ivantodorovich

+

This module is part of the OCA/field-service project on GitHub.

+

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

+
+
+
+ + diff --git a/fieldservice_sale_agreement/tests/__init__.py b/fieldservice_sale_agreement/tests/__init__.py new file mode 100644 index 0000000000..f3b083d003 --- /dev/null +++ b/fieldservice_sale_agreement/tests/__init__.py @@ -0,0 +1 @@ +from . import test_fsm_sale_agreement diff --git a/fieldservice_sale_agreement/tests/test_fsm_sale_agreement.py b/fieldservice_sale_agreement/tests/test_fsm_sale_agreement.py new file mode 100644 index 0000000000..c835a25e46 --- /dev/null +++ b/fieldservice_sale_agreement/tests/test_fsm_sale_agreement.py @@ -0,0 +1,56 @@ +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import Command + +from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT +from odoo.addons.sale.tests.common import TestSaleCommonBase + + +class TestFieldServiceSaleAgreement(TestSaleCommonBase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT)) + cls.fsm_template = cls.env["fsm.template"].create( + { + "name": "Test FSM Template", + "instructions": "Test Notes", + "duration": 2, + } + ) + cls.product = cls.env["product.product"].create( + { + "name": "FSM Product", + "type": "service", + "invoice_policy": "delivery", + "field_service_tracking": "line", + "fsm_order_template_id": cls.fsm_template.id, + } + ) + cls.order = cls.env["sale.order"].create( + { + "partner_id": cls.env.ref("base.main_partner").id, + "agreement_id": cls.env.ref("agreement.market1").id, + "fsm_location_id": cls.env.ref("fieldservice.test_location").id, + "order_line": [ + Command.create( + { + "product_id": cls.product.id, + "product_uom_qty": 1, + } + ) + ], + } + ) + + def test_propagate_agreement_id(self): + self.order.action_confirm() + self.assertTrue( + self.order.fsm_order_ids, "The FSM Order should've been created" + ) + self.assertEqual( + self.order.fsm_order_ids.agreement_id, + self.order.agreement_id, + "The FSM Order should have the same agreement as the Sale Order", + )