Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] fieldservice_agreement #232

Merged
merged 3 commits into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion fieldservice_agreement/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion fieldservice_agreement/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from . import (
agreement,
fsm_equipment,
fsm_location,
fsm_order,
fsm_person
fsm_person,
)
26 changes: 26 additions & 0 deletions fieldservice_agreement/models/fsm_location.py
Original file line number Diff line number Diff line change
@@ -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)])
max3903 marked this conversation as resolved.
Show resolved Hide resolved
ids = []
for agree in agreements:
osi-scampbell marked this conversation as resolved.
Show resolved Hide resolved
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
24 changes: 24 additions & 0 deletions fieldservice_agreement/views/fsm_location.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Copyright 2019 Open Source Integrators
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) -->
<odoo>

<record id="fsm_location_agreement_serviceprofile" model="ir.ui.view">
<field name="name">fsm.location.agreement.serviceprofile</field>
<field name="model">fsm.location</field>
<field name="inherit_id" ref="fieldservice.fsm_location_form_view"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Service Profiles">
<field name="serviceprofile_ids">
<tree>
<field name="name"/>
<field name="agreement_id"/>
<field name="notes"/>
</tree>
</field>
</page>
</notebook>
</field>
</record>

</odoo>