Skip to content

Commit

Permalink
[IMP][ADD] Ticket #: 609, 608, 604 fsm_agreement
Browse files Browse the repository at this point in the history
[IMP] Add to serviceprofile_ids on agreement

[IMP] Github comments
  • Loading branch information
osi-scampbell committed Jun 11, 2019
1 parent c57c61e commit a270cf2
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
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)])
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
21 changes: 21 additions & 0 deletions fieldservice_agreement/views/fsm_location.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<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"/>
</tree>
</field>
</page>
</notebook>
</field>
</record>
</odoo>

0 comments on commit a270cf2

Please sign in to comment.