diff --git a/agreement_fsm/__init__.py b/agreement_fsm/__init__.py new file mode 100644 index 000000000..631bd4893 --- /dev/null +++ b/agreement_fsm/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2018 - TODAY, Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/agreement_fsm/__manifest__.py b/agreement_fsm/__manifest__.py new file mode 100644 index 000000000..05fbf38ac --- /dev/null +++ b/agreement_fsm/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright (C) 2018 - TODAY, Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "FSM Agreements", + "summary": "Manage FSM Agreements", + "author": "Open Source Integrators, " + "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/contract", + "category": "Partner", + "license": "AGPL-3", + "version": "11.0.1.0.0", + "depends": [ + "fieldservice", + "agreement", + ], + "data": [ + "views/agreement_view.xml", + "views/fsm_order_view.xml", + ], + "application": True, + "development_status": "Beta", + "maintainers": ["max3903", "bodedra"], +} diff --git a/agreement_fsm/models/__init__.py b/agreement_fsm/models/__init__.py new file mode 100644 index 000000000..a8787cb0a --- /dev/null +++ b/agreement_fsm/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import fsm_order +from . import agreement diff --git a/agreement_fsm/models/agreement.py b/agreement_fsm/models/agreement.py new file mode 100644 index 000000000..2cbd62167 --- /dev/null +++ b/agreement_fsm/models/agreement.py @@ -0,0 +1,38 @@ +# Copyright (C) 2018 - TODAY, Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models, api + + +class Agreement(models.Model): + _inherit = 'agreement' + + service_order_count = fields.Integer( + compute='_compute_service_order_count', + string='# Service Orders' + ) + + @api.multi + def _compute_service_order_count(self): + for agreement in self: + res = self.env['fsm.order'].search_count( + [('agreement_id', '=', agreement.id)]) + agreement.service_order_count = res or 0 + + @api.multi + def action_view_service_order(self): + for agreement in self: + fsm_order_ids = self.env['fsm.order'].search( + [('agreement_id', '=', agreement.id)]) + action = self.env.ref( + 'fieldservice.action_fsm_operation_order').read()[0] + if len(fsm_order_ids) > 1: + action['domain'] = [('id', 'in', fsm_order_ids.ids)] + elif len(fsm_order_ids) == 1: + action['views'] = [( + self.env.ref('fieldservice.fsm_order_form').id, + 'form')] + action['res_id'] = fsm_order_ids.ids[0] + else: + action = {'type': 'ir.actions.act_window_close'} + return action diff --git a/agreement_fsm/models/fsm_order.py b/agreement_fsm/models/fsm_order.py new file mode 100644 index 000000000..88c923cd1 --- /dev/null +++ b/agreement_fsm/models/fsm_order.py @@ -0,0 +1,12 @@ +# Copyright (C) 2018 - TODAY, Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields + +from odoo.addons.base_geoengine import geo_model + + +class FSMOrder(geo_model.GeoModel): + _inherit = 'fsm.order' + + agreement_id = fields.Many2one('agreement', string='Agreement') diff --git a/agreement_fsm/readme/CONFIGURE.rst b/agreement_fsm/readme/CONFIGURE.rst new file mode 100644 index 000000000..e69de29bb diff --git a/agreement_fsm/readme/CONTRIBUTORS.rst b/agreement_fsm/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..567f85bd6 --- /dev/null +++ b/agreement_fsm/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Bhavesh Odedra diff --git a/agreement_fsm/readme/CREDITS.rst b/agreement_fsm/readme/CREDITS.rst new file mode 100644 index 000000000..8209266d9 --- /dev/null +++ b/agreement_fsm/readme/CREDITS.rst @@ -0,0 +1,3 @@ +The development of this module has been financially supported by: + +* Open Source Integrators diff --git a/agreement_fsm/readme/DESCRIPTION.rst b/agreement_fsm/readme/DESCRIPTION.rst new file mode 100644 index 000000000..715fea45c --- /dev/null +++ b/agreement_fsm/readme/DESCRIPTION.rst @@ -0,0 +1,7 @@ +Odoo Agreement App does not provide an easy way to access field service orders +related to an agreement. Some organizations needs to have a quick access to +field service orders to track the performance of an agreement. + +This module allows you to link a field service order to an agreement and adds a +smart button on the agreement to look at the list of related field service +orders. diff --git a/agreement_fsm/readme/ROADMAP.rst b/agreement_fsm/readme/ROADMAP.rst new file mode 100644 index 000000000..e69de29bb diff --git a/agreement_fsm/readme/USAGE.rst b/agreement_fsm/readme/USAGE.rst new file mode 100644 index 000000000..66cebd33d --- /dev/null +++ b/agreement_fsm/readme/USAGE.rst @@ -0,0 +1,8 @@ +To use this module: + +* Go to Field Service > Operations > Orders +* Select or create a field service order and set the agreement +* Go to Agreement > Agreements +* Open the previous agreement +* Click on the smart button "Service Orders" to see the list of related field + service orders diff --git a/agreement_fsm/static/description/icon.png b/agreement_fsm/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/agreement_fsm/static/description/icon.png differ diff --git a/agreement_fsm/views/agreement_view.xml b/agreement_fsm/views/agreement_view.xml new file mode 100644 index 000000000..5ae94d69f --- /dev/null +++ b/agreement_fsm/views/agreement_view.xml @@ -0,0 +1,19 @@ + + + + + + + agreement.form.fsm.order.view + agreement + + +
+ +
+
+
+
diff --git a/agreement_fsm/views/fsm_order_view.xml b/agreement_fsm/views/fsm_order_view.xml new file mode 100644 index 000000000..b6fe7d95a --- /dev/null +++ b/agreement_fsm/views/fsm_order_view.xml @@ -0,0 +1,17 @@ + + + + + + + fsm.order.agreement.form + fsm.order + + + + + + + +