Skip to content

Commit

Permalink
[FIX] fieldservice_agreement (OCA#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
osi-scampbell authored and szekawong committed Nov 6, 2023
1 parent 628a21c commit a40aa97
Show file tree
Hide file tree
Showing 4 changed files with 54 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
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>

0 comments on commit a40aa97

Please sign in to comment.