diff --git a/fieldservice_equipment_warranty/README.rst b/fieldservice_equipment_warranty/README.rst new file mode 100644 index 0000000000..ad387ba63c --- /dev/null +++ b/fieldservice_equipment_warranty/README.rst @@ -0,0 +1,94 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +================================ +Field Service Equipment Warranty +================================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:932b493a6218f4df718414d5ff143c3e30f765bb9c31f00e09655cedbe4f78d9 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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/19.0/fieldservice_equipment_warranty + :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-19-0/field-service-19-0-fieldservice_equipment_warranty + :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=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Customizations related to ``fieldservice_equipment_stock`` module and +``product_warranty`` module. + +This module allows managing warranties for equipment in the field +service module. It extends the functionality of the +``fieldservice_equipment_stock`` and ``product_warranty`` modules to +provide a link between equipment and product warranties. + +**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 +------------ + +- Italo LOPES + +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-imlopes| image:: https://github.com/imlopes.png?size=40px + :target: https://github.com/imlopes + :alt: imlopes + +Current `maintainer `__: + +|maintainer-imlopes| + +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_equipment_warranty/__init__.py b/fieldservice_equipment_warranty/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/fieldservice_equipment_warranty/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/fieldservice_equipment_warranty/__manifest__.py b/fieldservice_equipment_warranty/__manifest__.py new file mode 100644 index 0000000000..9800eefa66 --- /dev/null +++ b/fieldservice_equipment_warranty/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2025 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Field Service Equipment Warranty", + "summary": "Field Service equipment warranty", + "category": "Field Service", + "version": "19.0.1.0.0", + "author": "Camptocamp, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": [ + # OCA/RMA + "product_warranty", + # OCA/field-service + "fieldservice_equipment_stock", + ], + "website": "https://github.com/OCA/field-service", + "data": [ + # Views + "views/fsm_equipment.xml", + ], + "installable": True, + "maintainers": ["imlopes"], +} diff --git a/fieldservice_equipment_warranty/i18n/fieldservice_equipment_warranty.pot b/fieldservice_equipment_warranty/i18n/fieldservice_equipment_warranty.pot new file mode 100644 index 0000000000..3dc41b5e85 --- /dev/null +++ b/fieldservice_equipment_warranty/i18n/fieldservice_equipment_warranty.pot @@ -0,0 +1,55 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_equipment_warranty +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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_equipment_warranty +#: model:ir.model,name:fieldservice_equipment_warranty.model_fsm_equipment +msgid "Field Service Equipment" +msgstr "" + +#. module: fieldservice_equipment_warranty +#: model_terms:ir.ui.view,arch_db:fieldservice_equipment_warranty.fsm_equipment_form_view_stock +msgid "Product Warranty" +msgstr "" + +#. module: fieldservice_equipment_warranty +#: model:ir.model.fields,field_description:fieldservice_equipment_warranty.field_fsm_equipment__product_warranty +msgid "Warranty Duration" +msgstr "" + +#. module: fieldservice_equipment_warranty +#: model:ir.model.fields,field_description:fieldservice_equipment_warranty.field_fsm_equipment__warranty_end_date +msgid "Warranty End Date" +msgstr "" + +#. module: fieldservice_equipment_warranty +#: model_terms:ir.ui.view,arch_db:fieldservice_equipment_warranty.fsm_equipment_form_view_stock +msgid "Warranty Period" +msgstr "" + +#. module: fieldservice_equipment_warranty +#: model:ir.model.fields,field_description:fieldservice_equipment_warranty.field_fsm_equipment__warranty_start_date +msgid "Warranty Start Date" +msgstr "" + +#. module: fieldservice_equipment_warranty +#: model:ir.model.fields,field_description:fieldservice_equipment_warranty.field_fsm_equipment__product_warranty_type +msgid "Warranty Type" +msgstr "" + +#. module: fieldservice_equipment_warranty +#. odoo-python +#: code:addons/fieldservice_equipment_warranty/models/fsm_equipment.py:0 +msgid "Warranty end date must be after warranty start date." +msgstr "" diff --git a/fieldservice_equipment_warranty/i18n/fr.po b/fieldservice_equipment_warranty/i18n/fr.po new file mode 100644 index 0000000000..ff2e931104 --- /dev/null +++ b/fieldservice_equipment_warranty/i18n/fr.po @@ -0,0 +1,71 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * behring_fieldservice_equipment_stock_warranty +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-22 13:47+0000\n" +"PO-Revision-Date: 2024-10-22 13:47+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: fieldservice_equipment_warranty +#: model:ir.model,name:fieldservice_equipment_warranty.model_fsm_equipment +msgid "Field Service Equipment" +msgstr "Équipement de service sur site" + +#. module: fieldservice_equipment_warranty +#: model_terms:ir.ui.view,arch_db:fieldservice_equipment_warranty.fsm_equipment_form_view_stock +msgid "Product Warranty" +msgstr "Garantie du produit" + +#. module: fieldservice_equipment_warranty +#: model:ir.model.fields,field_description:fieldservice_equipment_warranty.field_fsm_equipment__product_warranty +msgid "Warranty Duration" +msgstr "Durée de garantie" + +#. module: fieldservice_equipment_warranty +#: model:ir.model.fields,field_description:fieldservice_equipment_warranty.field_fsm_equipment__warranty_end_date +msgid "Warranty End Date" +msgstr "Date de fin de garantie" + +#. module: fieldservice_equipment_warranty +#: model_terms:ir.ui.view,arch_db:fieldservice_equipment_warranty.fsm_equipment_form_view_stock +#, fuzzy +msgid "Warranty Period" +msgstr "Durée de garantie" + +#. module: fieldservice_equipment_warranty +#: model:ir.model.fields,field_description:fieldservice_equipment_warranty.field_fsm_equipment__warranty_start_date +msgid "Warranty Start Date" +msgstr "Date de début de garantie" + +#. module: fieldservice_equipment_warranty +#: model:ir.model.fields,field_description:fieldservice_equipment_warranty.field_fsm_equipment__product_warranty_type +msgid "Warranty Type" +msgstr "Type de garantie" + +#. module: fieldservice_equipment_warranty +#. odoo-python +#: code:addons/fieldservice_equipment_warranty/models/fsm_equipment.py:0 +msgid "Warranty end date must be after warranty start date." +msgstr "" + +#~ msgid "Day(s)" +#~ msgstr "Jour(s)" + +#~ msgid "Month(s)" +#~ msgstr "Mois" + +#~ msgid "Week(s)" +#~ msgstr "Semaine(s)" + +#~ msgid "Year(s)" +#~ msgstr "Année(s)" diff --git a/fieldservice_equipment_warranty/i18n/it.po b/fieldservice_equipment_warranty/i18n/it.po new file mode 100644 index 0000000000..732cec1d83 --- /dev/null +++ b/fieldservice_equipment_warranty/i18n/it.po @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_equipment_warranty +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-09-08 09:55+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_equipment_warranty +#: model:ir.model,name:fieldservice_equipment_warranty.model_fsm_equipment +msgid "Field Service Equipment" +msgstr "Attrezzatura assistenza sul campo" + +#. module: fieldservice_equipment_warranty +#: model_terms:ir.ui.view,arch_db:fieldservice_equipment_warranty.fsm_equipment_form_view_stock +msgid "Product Warranty" +msgstr "Garanzia prodotto" + +#. module: fieldservice_equipment_warranty +#: model:ir.model.fields,field_description:fieldservice_equipment_warranty.field_fsm_equipment__product_warranty +msgid "Warranty Duration" +msgstr "Durata Garanzia" + +#. module: fieldservice_equipment_warranty +#: model:ir.model.fields,field_description:fieldservice_equipment_warranty.field_fsm_equipment__warranty_end_date +msgid "Warranty End Date" +msgstr "Data fine garanzia" + +#. module: fieldservice_equipment_warranty +#: model_terms:ir.ui.view,arch_db:fieldservice_equipment_warranty.fsm_equipment_form_view_stock +msgid "Warranty Period" +msgstr "Periodo garanzia" + +#. module: fieldservice_equipment_warranty +#: model:ir.model.fields,field_description:fieldservice_equipment_warranty.field_fsm_equipment__warranty_start_date +msgid "Warranty Start Date" +msgstr "Data inizio garanzia" + +#. module: fieldservice_equipment_warranty +#: model:ir.model.fields,field_description:fieldservice_equipment_warranty.field_fsm_equipment__product_warranty_type +msgid "Warranty Type" +msgstr "Tipo garanzia" + +#. module: fieldservice_equipment_warranty +#. odoo-python +#: code:addons/fieldservice_equipment_warranty/models/fsm_equipment.py:0 +msgid "Warranty end date must be after warranty start date." +msgstr "La data fine garanzia deve essere successiva alla data inizio garanzia." diff --git a/fieldservice_equipment_warranty/models/__init__.py b/fieldservice_equipment_warranty/models/__init__.py new file mode 100644 index 0000000000..69631fa677 --- /dev/null +++ b/fieldservice_equipment_warranty/models/__init__.py @@ -0,0 +1 @@ +from . import fsm_equipment diff --git a/fieldservice_equipment_warranty/models/fsm_equipment.py b/fieldservice_equipment_warranty/models/fsm_equipment.py new file mode 100644 index 0000000000..1fef43ffa3 --- /dev/null +++ b/fieldservice_equipment_warranty/models/fsm_equipment.py @@ -0,0 +1,63 @@ +# Copyright 2025 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from dateutil.relativedelta import relativedelta + +from odoo import api, fields, models +from odoo.exceptions import ValidationError + + +class FSMEquipment(models.Model): + _inherit = "fsm.equipment" + + warranty_start_date = fields.Date( + copy=False, tracking=True, default=fields.Date.today + ) + warranty_end_date = fields.Date( + tracking=True, compute="_compute_warranty_end_date", store=True, readonly=False + ) + product_warranty = fields.Integer( + related="product_id.warranty", string="Warranty Duration" + ) + product_warranty_type = fields.Selection( + related="product_id.warranty_type", string="Warranty Type" + ) + + @api.constrains("warranty_start_date", "warranty_end_date") + def _check_warranty_dates(self): + for equip in self: + if ( + equip.warranty_start_date + and equip.warranty_end_date + and equip.warranty_end_date < equip.warranty_start_date + ): + raise ValidationError( + self.env._("Warranty end date must be after warranty start date.") + ) + + def _get_warranty_end_date(self): + self.ensure_one() + warranty_end_date = fields.Date.today() + if self.product_id and self.product_id.warranty: + if self.product_id.warranty_type == "week": + warranty_end_date = self.warranty_start_date + relativedelta( + weeks=self.product_id.warranty + ) + elif self.product_id.warranty_type == "month": + warranty_end_date = self.warranty_start_date + relativedelta( + months=self.product_id.warranty + ) + elif self.product_id.warranty_type == "year": + warranty_end_date = self.warranty_start_date + relativedelta( + years=self.product_id.warranty + ) + else: + warranty_end_date = self.warranty_start_date + relativedelta( + days=self.product_id.warranty + ) + return warranty_end_date + + @api.depends("product_id", "product_id.warranty", "warranty_start_date") + def _compute_warranty_end_date(self): + for equip in self: + equip.warranty_end_date = equip._get_warranty_end_date() diff --git a/fieldservice_equipment_warranty/pyproject.toml b/fieldservice_equipment_warranty/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/fieldservice_equipment_warranty/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/fieldservice_equipment_warranty/readme/CONTRIBUTORS.md b/fieldservice_equipment_warranty/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..0b564563c9 --- /dev/null +++ b/fieldservice_equipment_warranty/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Italo LOPES \<\> diff --git a/fieldservice_equipment_warranty/readme/DESCRIPTION.md b/fieldservice_equipment_warranty/readme/DESCRIPTION.md new file mode 100644 index 0000000000..201d9fa5da --- /dev/null +++ b/fieldservice_equipment_warranty/readme/DESCRIPTION.md @@ -0,0 +1,5 @@ +Customizations related to ``fieldservice_equipment_stock`` module and ``product_warranty`` module. + +This module allows managing warranties for equipment in the field service module. +It extends the functionality of the `fieldservice_equipment_stock` and `product_warranty` modules +to provide a link between equipment and product warranties. diff --git a/fieldservice_equipment_warranty/static/description/icon.png b/fieldservice_equipment_warranty/static/description/icon.png new file mode 100644 index 0000000000..1dcc49c24f Binary files /dev/null and b/fieldservice_equipment_warranty/static/description/icon.png differ diff --git a/fieldservice_equipment_warranty/static/description/index.html b/fieldservice_equipment_warranty/static/description/index.html new file mode 100644 index 0000000000..b4d6d1d5e6 --- /dev/null +++ b/fieldservice_equipment_warranty/static/description/index.html @@ -0,0 +1,436 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Field Service Equipment Warranty

+ +

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

+

Customizations related to fieldservice_equipment_stock module and +product_warranty module.

+

This module allows managing warranties for equipment in the field +service module. It extends the functionality of the +fieldservice_equipment_stock and product_warranty modules to +provide a link between equipment and product warranties.

+

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
  • +
+
+ +
+

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:

+

imlopes

+

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_equipment_warranty/tests/__init__.py b/fieldservice_equipment_warranty/tests/__init__.py new file mode 100644 index 0000000000..77d66c4643 --- /dev/null +++ b/fieldservice_equipment_warranty/tests/__init__.py @@ -0,0 +1 @@ +from . import test_fsm_equipment_warranty diff --git a/fieldservice_equipment_warranty/tests/test_fsm_equipment_warranty.py b/fieldservice_equipment_warranty/tests/test_fsm_equipment_warranty.py new file mode 100644 index 0000000000..a93480c645 --- /dev/null +++ b/fieldservice_equipment_warranty/tests/test_fsm_equipment_warranty.py @@ -0,0 +1,58 @@ +# Copyright 2025 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + +from dateutil.relativedelta import relativedelta + +from odoo import fields +from odoo.tests.common import TransactionCase, tagged + + +@tagged("post_install", "-at_install") +class TestFSMEquipmentWarranty(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + ProductTemplate = cls.env["product.template"] + + tmpl_month = ProductTemplate.create( + {"name": "Product 3M", "warranty": 3, "warranty_type": "month"} + ) + cls.product_month = tmpl_month.product_variant_id + + cls.Equipment = cls.env["fsm.equipment"] + cls.start_a = fields.Date.to_date("2025-01-15") + cls.start_b = fields.Date.to_date("2025-02-10") + + def test_01_create_sets_warranty_end_date(self): + equip = self.Equipment.create( + { + "name": "Equip A", + "product_id": self.product_month.id, + "warranty_start_date": self.start_a, + } + ) + expected = self.start_a + relativedelta(months=3) + self.assertEqual(equip.warranty_end_date, expected) + + def test_02_write_recomputes_on_start_date_change(self): + equip = self.Equipment.create( + { + "name": "Equip B", + "product_id": self.product_month.id, + "warranty_start_date": self.start_a, + } + ) + equip.write({"warranty_start_date": self.start_b}) + expected = self.start_b + relativedelta(months=3) + self.assertEqual(equip.warranty_end_date, expected) + + def test_03_create_without_product_sets_today(self): + today = fields.Date.today() + equip = self.Equipment.create( + { + "name": "Equipment without product", + "warranty_start_date": self.start_a, + } + ) + self.assertEqual(equip.warranty_end_date, today) diff --git a/fieldservice_equipment_warranty/views/fsm_equipment.xml b/fieldservice_equipment_warranty/views/fsm_equipment.xml new file mode 100644 index 0000000000..e21aec2796 --- /dev/null +++ b/fieldservice_equipment_warranty/views/fsm_equipment.xml @@ -0,0 +1,43 @@ + + + fsm.equipment + + + + + + + + + + + fsm.equipment + + + + + + + + + diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000000..0b909136b3 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,5 @@ +odoo-addon-base_territory @ git+https://github.com/OCA/field-service.git@refs/pull/1495/head#subdirectory=base_territory +odoo-addon-fieldservice @ git+https://github.com/OCA/field-service.git@refs/pull/1496/head#subdirectory=fieldservice +odoo-addon-fieldservice_stock @ git+https://github.com/OCA/field-service.git@refs/pull/1499/head#subdirectory=fieldservice_stock +odoo-addon-fieldservice_equipment_stock @ git+https://github.com/OCA/field-service.git@refs/pull/1506/head#subdirectory=fieldservice_equipment_stock +odoo-addon-product_warranty @ git+https://github.com/OCA/rma.git@refs/pull/506/head#subdirectory=product_warranty