Browse Source

[FIX] contract_fieldservice

pull/438/head
Maxime Chambreuil 5 years ago
committed by Murtuza Saleh
parent
commit
7bed94980d
  1. 9
      contract_fieldservice/models/__init__.py
  2. 22
      contract_fieldservice/models/contract_contract.py
  3. 5
      contract_fieldservice/models/contract_line.py
  4. 13
      contract_fieldservice/models/fsm_location.py
  5. 4
      contract_fieldservice/views/sale_view.xml

9
contract_fieldservice/models/__init__.py

@ -1,3 +1,8 @@
# Copyright (C) 2019 Open Source Integrators
# Copyright (C) 2019 Serpent Consulting Services
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import contract_line
from . import (
contract_contract,
contract_line,
fsm_location,
)

22
contract_fieldservice/models/contract_contract.py

@ -0,0 +1,22 @@
# Copyright (C) 2019 Open Source Integrators
# Copyright (C) 2019 Serpent Consulting Services
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class ContractContract(models.Model):
_inherit = 'contract.contract'
fsm_location_ids = fields.Many2many(
'fsm.location', 'contract_fsm_location',
'contract_id', 'fsm_location_id', string='Service Locations',
compute='compute_fsm_locations', readonly=True, store=True, index=True)
@api.depends('contract_line_ids.fsm_location_id')
@api.model
def compute_fsm_locations(self):
location_ids = []
for line in self.contract_line_ids:
location_ids.append(line.fsm_location_id and
line.fsm_location_id.id)
self.fsm_location_ids = [(6, 0, location_ids)]

5
contract_fieldservice/models/contract_line.py

@ -1,10 +1,11 @@
# Copyright (C) 2019 Open Source Integrators # Copyright (C) 2019 Open Source Integrators
# Copyright (C) 2019 Serpent Consulting Services
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models from odoo import fields, models
class ContractLine(models.Model): class ContractLine(models.Model):
_inherit = 'contract.line' _inherit = 'contract.line'
fsm_location_id = fields.Many2one('fsm.location', 'Service To')
fsm_location_id = fields.Many2one('fsm.location', string='Service To',
index=True)

13
contract_fieldservice/models/fsm_location.py

@ -0,0 +1,13 @@
# Copyright (C) 2019 Open Source Integrators
# Copyright (C) 2019 Serpent Consulting Services
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class FsmLocation(models.Model):
_inherit = 'fsm.location'
contract_ids = fields.Many2many(
'contract.contract', 'contract_fsm_location',
'fsm_location_id', 'contract_id', string='Contracts',
readonly=True, store=True, index=True)

4
contract_fieldservice/views/sale_view.xml

@ -3,10 +3,10 @@
<record id="view_order_form_inherit_contract_fieldservice" model="ir.ui.view"> <record id="view_order_form_inherit_contract_fieldservice" model="ir.ui.view">
<field name="name">sale.order.form</field> <field name="name">sale.order.form</field>
<field name="model">sale.order</field> <field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="inherit_id" ref="fieldservice_sale.view_order_form_inherit_sale_fieldservice"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="fsm_location_id" position="attributes"> <field name="fsm_location_id" position="attributes">
<attribute name="domain">[('contract_ids', 'in', parent.contract_id)]</attribute>
<attribute name="domain">[('contract_ids', 'in', contract_id)]</attribute>
</field> </field>
</field> </field>
</record> </record>

Loading…
Cancel
Save