From 22648322f937c688167f5572d8fb7e3329313ab9 Mon Sep 17 00:00:00 2001 From: Andreu Orensanz Date: Mon, 4 Nov 2024 17:22:14 +0100 Subject: [PATCH] [ADD] repair_service --- repair_service/README.rst | 91 ++++ repair_service/__init__.py | 3 + repair_service/__manifest__.py | 17 + repair_service/models/__init__.py | 4 + repair_service/models/repair_order.py | 17 + repair_service/models/repair_service.py | 70 +++ repair_service/pyproject.toml | 3 + repair_service/readme/CONTRIBUTORS.md | 3 + repair_service/readme/DESCRIPTION.md | 1 + repair_service/readme/USAGE.md | 1 + repair_service/security/ir.model.access.csv | 2 + repair_service/static/description/index.html | 439 +++++++++++++++++++ repair_service/views/repair_views.xml | 22 + 13 files changed, 673 insertions(+) create mode 100644 repair_service/README.rst create mode 100644 repair_service/__init__.py create mode 100644 repair_service/__manifest__.py create mode 100644 repair_service/models/__init__.py create mode 100644 repair_service/models/repair_order.py create mode 100644 repair_service/models/repair_service.py create mode 100644 repair_service/pyproject.toml create mode 100644 repair_service/readme/CONTRIBUTORS.md create mode 100644 repair_service/readme/DESCRIPTION.md create mode 100644 repair_service/readme/USAGE.md create mode 100644 repair_service/security/ir.model.access.csv create mode 100644 repair_service/static/description/index.html create mode 100644 repair_service/views/repair_views.xml diff --git a/repair_service/README.rst b/repair_service/README.rst new file mode 100644 index 00000000..f8bdf2cc --- /dev/null +++ b/repair_service/README.rst @@ -0,0 +1,91 @@ +============== +Repair Service +============== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:ac26551a9ce89d1e4c4a02728cea444025c7f7ebc7ed6fa7553f91d625a9840a + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_service + :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_service + :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 introduces repair services. It adds a new "Services" tab in +the repair orders, where users can add and manage services associated +with the repair. Once the repair order is confirmed and a sale order is +created, these services can be automatically added as sale order lines. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +When creating or editing a repair order, you will find a new "Services" +tab within the repair order form. In this tab, you can input and manage +the services performed as part of the repair order. Once the repair +order is confirmed, when you creating a sale order from the repair +order, the services listed in the "Services" tab will be automatically +added as sale order lines. + +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 +------- + +* ForgeFlow + +Contributors +------------ + +- `ForgeFlow `__: + + - Andreu Orensanz + +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_service/__init__.py b/repair_service/__init__.py new file mode 100644 index 00000000..31660d6a --- /dev/null +++ b/repair_service/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/repair_service/__manifest__.py b/repair_service/__manifest__.py new file mode 100644 index 00000000..247bc9c9 --- /dev/null +++ b/repair_service/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Repair Service", + "summary": """ + Adds services to repair orders, so that they can be added + as sale order lines. + """, + "version": "17.0.1.0.0", + "category": "Repair", + "website": "https://github.com/OCA/repair", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": ["repair"], + "data": ["security/ir.model.access.csv", "views/repair_views.xml"], +} diff --git a/repair_service/models/__init__.py b/repair_service/models/__init__.py new file mode 100644 index 00000000..c5c31165 --- /dev/null +++ b/repair_service/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import repair_service +from . import repair_order diff --git a/repair_service/models/repair_order.py b/repair_service/models/repair_order.py new file mode 100644 index 00000000..53926a5c --- /dev/null +++ b/repair_service/models/repair_order.py @@ -0,0 +1,17 @@ +# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class RepairOrder(models.Model): + _inherit = "repair.order" + + repair_service_ids = fields.One2many( + "repair.service", "repair_id", "Operations", copy=True + ) + + def action_create_sale_order(self): + action = super().action_create_sale_order() + self.repair_service_ids._create_repair_sale_order_line() + return action diff --git a/repair_service/models/repair_service.py b/repair_service/models/repair_service.py new file mode 100644 index 00000000..2901a7dd --- /dev/null +++ b/repair_service/models/repair_service.py @@ -0,0 +1,70 @@ +# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class RepairService(models.Model): + _name = "repair.service" + + repair_id = fields.Many2one( + "repair.order", "Repair Order Reference", ondelete="cascade", required=True + ) + display_name = fields.Text( + "Description", + required=True, + compute="_compute_name", + store=True, + precompute=True, + ) + product_id = fields.Many2one( + "product.product", "Product", domain=[("type", "=", "service")], required=True + ) + product_uom = fields.Many2one("uom.uom", required=True) + product_uom_qty = fields.Float( + "Quantity", digits="Product Unit of Measure", required=True, default=1.0 + ) + + @api.onchange("product_id") + def _onchange_product_id(self): + if self.product_id: + self.product_uom = self.product_id.uom_id + return { + "domain": { + "product_uom": [ + ( + "category_id", + "=", + self.product_id.product_tmpl_id.uom_id.category_id.id, + ) + ] + } + } + else: + return {"domain": {"product_uom": []}} + + @api.depends("product_id") + def _compute_name(self): + for service in self: + service.display_name = service.product_id.name + + def _create_repair_sale_order_line(self): + if not self: + return + so_line_vals = [] + for service in self: + if not service.repair_id.sale_order_id: + continue + product_qty = ( + service.product_uom_qty + if service.repair_id.state != "done" + else service.product_uom_qty + ) + so_line_vals.append( + { + "order_id": service.repair_id.sale_order_id.id, + "product_id": service.product_id.id, + "product_uom_qty": product_qty, + } + ) + self.env["sale.order.line"].create(so_line_vals) diff --git a/repair_service/pyproject.toml b/repair_service/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/repair_service/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/repair_service/readme/CONTRIBUTORS.md b/repair_service/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..650a4c13 --- /dev/null +++ b/repair_service/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [ForgeFlow](https://forgeflow.com): + + > - Andreu Orensanz \<\> \ No newline at end of file diff --git a/repair_service/readme/DESCRIPTION.md b/repair_service/readme/DESCRIPTION.md new file mode 100644 index 00000000..d3611ef5 --- /dev/null +++ b/repair_service/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module introduces repair services. It adds a new "Services" tab in the repair orders, where users can add and manage services associated with the repair. Once the repair order is confirmed and a sale order is created, these services can be automatically added as sale order lines. diff --git a/repair_service/readme/USAGE.md b/repair_service/readme/USAGE.md new file mode 100644 index 00000000..9187238a --- /dev/null +++ b/repair_service/readme/USAGE.md @@ -0,0 +1 @@ +When creating or editing a repair order, you will find a new "Services" tab within the repair order form. In this tab, you can input and manage the services performed as part of the repair order. Once the repair order is confirmed, when you creating a sale order from the repair order, the services listed in the "Services" tab will be automatically added as sale order lines. diff --git a/repair_service/security/ir.model.access.csv b/repair_service/security/ir.model.access.csv new file mode 100644 index 00000000..76c012f6 --- /dev/null +++ b/repair_service/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_repair_service_user,repair.service user,model_repair_service,stock.group_stock_user,1,1,1,1 diff --git a/repair_service/static/description/index.html b/repair_service/static/description/index.html new file mode 100644 index 00000000..b60bca5d --- /dev/null +++ b/repair_service/static/description/index.html @@ -0,0 +1,439 @@ + + + + + +Repair Service + + + +
+

Repair Service

+ + +

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

+

This module introduces repair services. It adds a new “Services” tab in +the repair orders, where users can add and manage services associated +with the repair. Once the repair order is confirmed and a sale order is +created, these services can be automatically added as sale order lines.

+

Table of contents

+ +
+

Usage

+

When creating or editing a repair order, you will find a new “Services” +tab within the repair order form. In this tab, you can input and manage +the services performed as part of the repair order. Once the repair +order is confirmed, when you creating a sale order from the repair +order, the services listed in the “Services” tab will be automatically +added as sale order lines.

+
+
+

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

+
    +
  • ForgeFlow
  • +
+
+
+

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_service/views/repair_views.xml b/repair_service/views/repair_views.xml new file mode 100644 index 00000000..7bc43c0e --- /dev/null +++ b/repair_service/views/repair_views.xml @@ -0,0 +1,22 @@ + + + + repair.order.form.inherit.operations + repair.order + + + + + + + + + + + + + + + + +