Skip to content

Commit

Permalink
[ADD] repair_service
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreuOForgeFlow committed Nov 4, 2024
1 parent 2e4601f commit 2264832
Show file tree
Hide file tree
Showing 13 changed files with 673 additions and 0 deletions.
91 changes: 91 additions & 0 deletions repair_service/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/OCA/repair/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 <https://github.com/OCA/repair/issues/new?body=module:%20repair_service%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* ForgeFlow

Contributors
------------

- `ForgeFlow <https://forgeflow.com>`__:

- Andreu Orensanz <[email protected]>

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 <https://github.com/OCA/repair/tree/17.0/repair_service>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions repair_service/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
17 changes: 17 additions & 0 deletions repair_service/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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"],
}
4 changes: 4 additions & 0 deletions repair_service/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import repair_service
from . import repair_order
17 changes: 17 additions & 0 deletions repair_service/models/repair_order.py
Original file line number Diff line number Diff line change
@@ -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

Check warning on line 17 in repair_service/models/repair_order.py

View check run for this annotation

Codecov / codecov/patch

repair_service/models/repair_order.py#L15-L17

Added lines #L15 - L17 were not covered by tests
70 changes: 70 additions & 0 deletions repair_service/models/repair_service.py
Original file line number Diff line number Diff line change
@@ -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 {

Check warning on line 32 in repair_service/models/repair_service.py

View check run for this annotation

Codecov / codecov/patch

repair_service/models/repair_service.py#L31-L32

Added lines #L31 - L32 were not covered by tests
"domain": {
"product_uom": [
(
"category_id",
"=",
self.product_id.product_tmpl_id.uom_id.category_id.id,
)
]
}
}
else:
return {"domain": {"product_uom": []}}

Check warning on line 44 in repair_service/models/repair_service.py

View check run for this annotation

Codecov / codecov/patch

repair_service/models/repair_service.py#L44

Added line #L44 was not covered by tests

@api.depends("product_id")
def _compute_name(self):
for service in self:
service.display_name = service.product_id.name

Check warning on line 49 in repair_service/models/repair_service.py

View check run for this annotation

Codecov / codecov/patch

repair_service/models/repair_service.py#L49

Added line #L49 was not covered by tests

def _create_repair_sale_order_line(self):
if not self:
return
so_line_vals = []

Check warning on line 54 in repair_service/models/repair_service.py

View check run for this annotation

Codecov / codecov/patch

repair_service/models/repair_service.py#L53-L54

Added lines #L53 - L54 were not covered by tests
for service in self:
if not service.repair_id.sale_order_id:
continue
product_qty = (

Check warning on line 58 in repair_service/models/repair_service.py

View check run for this annotation

Codecov / codecov/patch

repair_service/models/repair_service.py#L57-L58

Added lines #L57 - L58 were not covered by tests
service.product_uom_qty
if service.repair_id.state != "done"
else service.product_uom_qty
)
so_line_vals.append(

Check warning on line 63 in repair_service/models/repair_service.py

View check run for this annotation

Codecov / codecov/patch

repair_service/models/repair_service.py#L63

Added line #L63 was not covered by tests
{
"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)

Check warning on line 70 in repair_service/models/repair_service.py

View check run for this annotation

Codecov / codecov/patch

repair_service/models/repair_service.py#L70

Added line #L70 was not covered by tests
3 changes: 3 additions & 0 deletions repair_service/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
3 changes: 3 additions & 0 deletions repair_service/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- [ForgeFlow](https://forgeflow.com):

> - Andreu Orensanz \<<[email protected]>\>
1 change: 1 addition & 0 deletions repair_service/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions repair_service/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions repair_service/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 2264832

Please sign in to comment.