-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
694 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
======================== | ||
Maintenance Request Sale | ||
======================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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-oxigensalud%2Fodoo--addons-lightgray.png?logo=github | ||
:target: https://github.com/oxigensalud/odoo-addons/tree/14.0/maintenance_request_sale | ||
:alt: oxigensalud/odoo-addons | ||
|
||
|badge1| |badge2| |badge3| | ||
|
||
This is a bridge module between Maintenance and Sale | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/oxigensalud/odoo-addons/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/oxigensalud/odoo-addons/issues/new?body=module:%20maintenance_request_sale%0Aversion:%2014.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 | ||
~~~~~~~ | ||
|
||
* Dixmit | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Enric Tobella | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is part of the `oxigensalud/odoo-addons <https://github.com/oxigensalud/odoo-addons/tree/14.0/maintenance_request_sale>`_ project on GitHub. | ||
|
||
You are welcome to contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2023 Dixmit | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Maintenance Request Sale", | ||
"summary": """ | ||
This is a bridge module between Maintenance and Sale""", | ||
"version": "14.0.1.0.0", | ||
"license": "AGPL-3", | ||
"category": "Maintenance", | ||
"author": "Dixmit,Odoo Community Association (OCA)", | ||
"website": "https://github.com/oxigensalud/odoo-addons", | ||
"depends": [ | ||
"maintenance", | ||
"sale", | ||
], | ||
"data": [ | ||
"views/maintenance_request.xml", | ||
"views/sale_order.xml", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import maintenance_request | ||
from . import sale_order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright 2023 Dixmit | ||
# # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class MaintenanceRequest(models.Model): | ||
|
||
_inherit = "maintenance.request" | ||
|
||
sale_order_id = fields.Many2one( | ||
"sale.order", "Sale Order", groups="sales_team.group_sale_salesman" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright 2023 Dixmit | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class SaleOrder(models.Model): | ||
|
||
_inherit = "sale.order" | ||
|
||
maintenance_request_ids = fields.One2many( | ||
"maintenance.request", "sale_order_id", string="Maintenance Requests" | ||
) | ||
|
||
maintenance_request_count = fields.Integer( | ||
compute="_compute_maintenance_request_count", string="# Maintenances" | ||
) | ||
|
||
@api.depends("maintenance_request_ids") | ||
def _compute_maintenance_request_count(self): | ||
for sale in self: | ||
sale.maintenance_request_count = len(sale.maintenance_request_ids) | ||
|
||
def action_view_maintenance_request(self): | ||
"""This function returns an action that display existing maintenance requests | ||
of given repair order ids. When only one found, show the maintenance request | ||
immediately. | ||
""" | ||
action = self.env.ref("maintenance.hr_equipment_request_action") | ||
result = action.read()[0] | ||
# override the context to get rid of the default filtering on repair order | ||
result["context"] = {"default_sale_order_id": self.id} | ||
maintenance_request_ids = self.mapped("maintenance_request_ids") | ||
# choose the view_mode accordingly | ||
if not maintenance_request_ids or len(maintenance_request_ids) > 1: | ||
result["domain"] = [("sale_order_id", "=", self.id)] | ||
elif len(maintenance_request_ids) == 1: | ||
res = self.env.ref("maintenance.hr_equipment_request_view_form", False) | ||
form_view = [(res and res.id or False, "form")] | ||
if "views" in result: | ||
result["views"] = form_view + [ | ||
(state, view) for state, view in result["views"] if view != "form" | ||
] | ||
else: | ||
result["views"] = form_view | ||
result["res_id"] = maintenance_request_ids.id | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Enric Tobella |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is a bridge module between Maintenance and Sale |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.