diff --git a/fieldservice_agreement/__manifest__.py b/fieldservice_agreement/__manifest__.py index 71ec3aa804..9fa96e4f9d 100644 --- a/fieldservice_agreement/__manifest__.py +++ b/fieldservice_agreement/__manifest__.py @@ -18,7 +18,8 @@ 'views/fsm_order_view.xml', 'views/fsm_equipment_view.xml', 'views/agreement_view.xml', - 'views/fsm_person.xml' + 'views/fsm_person.xml', + 'views/fsm_location.xml' ], 'installable': True, 'development_status': 'Beta', diff --git a/fieldservice_agreement/models/__init__.py b/fieldservice_agreement/models/__init__.py index fe35aa88a5..98a54f21cc 100644 --- a/fieldservice_agreement/models/__init__.py +++ b/fieldservice_agreement/models/__init__.py @@ -3,6 +3,7 @@ from . import ( agreement, fsm_equipment, + fsm_location, fsm_order, - fsm_person + fsm_person, ) diff --git a/fieldservice_agreement/models/fsm_location.py b/fieldservice_agreement/models/fsm_location.py new file mode 100644 index 0000000000..d8127c93f4 --- /dev/null +++ b/fieldservice_agreement/models/fsm_location.py @@ -0,0 +1,26 @@ +# Copyright (C) 2018 - TODAY, Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class FSMLocation(models.Model): + _inherit = 'fsm.location' + + serviceprofile_ids = fields.Many2many('agreement.serviceprofile', + string="Service Profiles", + compute='_compute_service_ids') + + @api.multi + def _compute_service_ids(self): + for loc in self: + agreements = self.env['agreement'].\ + search([('fsm_location_id', '=', self.name)]) + ids = [] + for agree in agreements: + servpros = self.env['agreement.serviceprofile'].\ + search([('agreement_id', '=', agree.id)]) + for ser in servpros: + if ser.id not in ids: + ids.append(ser.id) + self.serviceprofile_ids = ids diff --git a/fieldservice_agreement/views/fsm_location.xml b/fieldservice_agreement/views/fsm_location.xml new file mode 100644 index 0000000000..97a8f4a64d --- /dev/null +++ b/fieldservice_agreement/views/fsm_location.xml @@ -0,0 +1,21 @@ + + + + + fsm.location.agreement.serviceprofile + fsm.location + + + + + + + + + + + + + + +