diff --git a/oca_dependencies.txt b/oca_dependencies.txt new file mode 100644 index 00000000..9b5df92e --- /dev/null +++ b/oca_dependencies.txt @@ -0,0 +1 @@ +server-ux diff --git a/repair_substate/README.rst b/repair_substate/README.rst new file mode 100644 index 00000000..9d4728ce --- /dev/null +++ b/repair_substate/README.rst @@ -0,0 +1,91 @@ +================ +Repair Sub State +================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:bd1b4c8d66f914e77d41ab47d2b18cdf01c17356287d83955afb9399b1934b5b + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Frepair-lightgray.png?logo=github + :target: https://github.com/OCA/repair/tree/17.0/repair_substate + :alt: OCA/repair +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/repair-17-0/repair-17-0-repair_substate + :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/repair&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to add a substate to repair order. For each repair +order state you can define a substate. With this module substates can be +defined allowing to extend the repair workflow. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +1. | Go to \*\* Settings > Technical > Sub State Configuration \*\* and + Add "Base Substate". + | If necessary you can add "Target State values" (ex define a + substate for "cancel" state). Substate sequence is very important. + +2. Create a repair order and check if the substate are displayed on the + header of form view. Check if you can't set substate defined for + repair if repair is draft. + +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 +------- + +* 360ERP + +Contributors +------------ + +- Marco Verbeij +- Antonio Buric + +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/repair `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/repair_substate/__init__.py b/repair_substate/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/repair_substate/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/repair_substate/__manifest__.py b/repair_substate/__manifest__.py new file mode 100644 index 00000000..015e00e5 --- /dev/null +++ b/repair_substate/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2024 360ERP () +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +{ + "name": "Repair Sub State", + "version": "17.0.1.0.0", + "category": "Tools", + "author": "360ERP, " "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/repair", + "license": "AGPL-3", + "depends": ["base_substate", "repair"], + "data": [ + "views/repair_views.xml", + "data/repair_substate_data.xml", + ], + "installable": True, +} diff --git a/repair_substate/data/repair_substate_data.xml b/repair_substate/data/repair_substate_data.xml new file mode 100644 index 00000000..ebec7033 --- /dev/null +++ b/repair_substate/data/repair_substate_data.xml @@ -0,0 +1,19 @@ + + + + Repair order Substate + repair.order + state + + + + New + + draft + + + Confirmed + + confirmed + + diff --git a/repair_substate/models/__init__.py b/repair_substate/models/__init__.py new file mode 100644 index 00000000..2251f67d --- /dev/null +++ b/repair_substate/models/__init__.py @@ -0,0 +1 @@ +from . import repair_order diff --git a/repair_substate/models/repair_order.py b/repair_substate/models/repair_order.py new file mode 100644 index 00000000..3186c01b --- /dev/null +++ b/repair_substate/models/repair_order.py @@ -0,0 +1,54 @@ +# Copyright 2024 360ERP () +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class BaseSubstateType(models.Model): + _inherit = "base.substate.type" + + model = fields.Selection( + selection_add=[("repair.order", "Repair order")], + ondelete={"repair.order": "cascade"}, + ) + + +class RepairOrder(models.Model): + _inherit = ["base.substate.mixin", "repair.order"] + _name = "repair.order" + + @api.constrains("substate_id", "state") + def check_substate_id_value(self): + repair_states = dict(self._fields["state"].selection) + for order in self: + target_state = order.substate_id.target_state_value_id.target_state_value + if order.substate_id and order.state != target_state and target_state: + raise ValidationError( + _( + "The substate %(name)s is not defined for the state" + " %(state)s but for %(target_state)s " + ) + % { + "name": order.substate_id.name, + "state": _(repair_states[order.state]), + "target_state": _(repair_states[target_state]), + } + ) + + def _track_template(self, changes): + res = super()._track_template(changes) + track = self[0] + if "substate_id" in changes and track.substate_id.mail_template_id: + res["substate_id"] = ( + track.substate_id.mail_template_id, + { + "composition_mode": "comment", + "auto_delete_message": True, + "subtype_id": self.env["ir.model.data"]._xmlid_to_res_id( + "mail.mt_note" + ), + "email_layout_xmlid": "mail.mail_notification_light", + }, + ) + return res diff --git a/repair_substate/pyproject.toml b/repair_substate/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/repair_substate/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/repair_substate/readme/CONTRIBUTORS.md b/repair_substate/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..962fb09f --- /dev/null +++ b/repair_substate/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Marco Verbeij \<\> +- Antonio Buric \<\> diff --git a/repair_substate/readme/DESCRIPTION.md b/repair_substate/readme/DESCRIPTION.md new file mode 100644 index 00000000..a7bf8581 --- /dev/null +++ b/repair_substate/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +This module allows to add a substate to repair order. For each repair +order state you can define a substate. With this module substates can be +defined allowing to extend the repair workflow. diff --git a/repair_substate/readme/USAGE.md b/repair_substate/readme/USAGE.md new file mode 100644 index 00000000..03327397 --- /dev/null +++ b/repair_substate/readme/USAGE.md @@ -0,0 +1,7 @@ +1. Go to \*\* Settings \> Technical \> Sub State Configuration \*\* and Add "Base Substate". + If necessary you can add "Target State values" (ex define a substate + for "cancel" state). Substate sequence is very important. + +2. Create a repair order and check if the substate are displayed on the + header of form view. Check if you can't set substate defined for + repair if repair is draft. diff --git a/repair_substate/static/description/icon.png b/repair_substate/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/repair_substate/static/description/icon.png differ diff --git a/repair_substate/static/description/index.html b/repair_substate/static/description/index.html new file mode 100644 index 00000000..16788d49 --- /dev/null +++ b/repair_substate/static/description/index.html @@ -0,0 +1,443 @@ + + + + + +Repair Sub State + + + +
+

Repair Sub State

+ + +

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

+

This module allows to add a substate to repair order. For each repair +order state you can define a substate. With this module substates can be +defined allowing to extend the repair workflow.

+

Table of contents

+ +
+

Usage

+
    +
  1. +
    Go to ** Settings > Technical > Sub State Configuration ** and +Add “Base Substate”.
    +
    If necessary you can add “Target State values” (ex define a +substate for “cancel” state). Substate sequence is very important.
    +
    +
  2. +
  3. Create a repair order and check if the substate are displayed on the +header of form view. Check if you can’t set substate defined for +repair if repair is draft.

    +
  4. +
+
+
+

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

+
    +
  • 360ERP
  • +
+
+
+

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.

+

This module is part of the OCA/repair project on GitHub.

+

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

+
+
+
+ + diff --git a/repair_substate/views/repair_views.xml b/repair_substate/views/repair_views.xml new file mode 100644 index 00000000..cf6fe3a0 --- /dev/null +++ b/repair_substate/views/repair_views.xml @@ -0,0 +1,47 @@ + + + + repair.order + + + +
+ +
+
+
+
+ + + repair.order + + + + + + + + + + repair.order + + + + + + + + + + + +