Skip to content

Commit

Permalink
[IMP] Connect fsm.skill to fsm.template (OCA#113)
Browse files Browse the repository at this point in the history
* [IMP] Connect fsm.skill to fsm.template
  • Loading branch information
osi-scampbell authored and Freni-OSI committed Apr 14, 2021
1 parent 6341241 commit d9f5021
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 5 deletions.
1 change: 1 addition & 0 deletions fieldservice_skill/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"views/fsm_person_skill.xml",
"views/fsm_order.xml",
"views/hr_skill.xml",
"views/fsm_template.xml"
],
"installable": True,
"development_status": "Beta",
Expand Down
1 change: 1 addition & 0 deletions fieldservice_skill/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
fsm_person,
fsm_category,
fsm_order,
fsm_template
)
16 changes: 12 additions & 4 deletions fieldservice_skill/models/fsm_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ class FSMOrder(geo_model.GeoModel):

@api.onchange('category_ids')
def _onchange_category_ids(self):
skill_ids = []
for category in self.category_ids:
skill_ids.extend([skill.id for skill in category.skill_ids])
self.skill_ids = [(6, 0, skill_ids)]
if not self.template_id:
skill_ids = []
for category in self.category_ids:
skill_ids.extend([skill.id for skill in category.skill_ids])
self.skill_ids = [(6, 0, skill_ids)]

@api.onchange('template_id')
def _onchange_template_id(self):
if self.template_id:
self.category_ids = self.template_id.category_ids
self.skill_ids = self.template_id.skill_ids
self.description = self.template_id.instructions
10 changes: 10 additions & 0 deletions fieldservice_skill/models/fsm_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class FSMTemplate(models.Model):
_inherit = 'fsm.template'

skill_ids = fields.Many2many('hr.skill', string="Required Skills")
2 changes: 1 addition & 1 deletion fieldservice_skill/views/fsm_order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<field name="category_ids" position="after">
<field name="skill_ids"
widget="many2many_tags"
options="{'color_field': '0'}"/>
options="{'color_field': 'color'}"/>
</field>
</field>
</record>
Expand Down
17 changes: 17 additions & 0 deletions fieldservice_skill/views/fsm_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Field Service Order Form Extended-->
<record id="fsm_template_form" model="ir.ui.view">
<field name="name">fsm.template.form</field>
<field name="model">fsm.template</field>
<field name="inherit_id" ref="fieldservice.fsm_template_form_view"/>
<field name="arch" type="xml">
<field name="category_ids" position="after">
<field name="skill_ids"
widget="many2many_tags"
options="{'color_field': 'color'}"/>
</field>
</field>
</record>

</odoo>

0 comments on commit d9f5021

Please sign in to comment.