diff --git a/fieldservice/security/ir.model.access.csv b/fieldservice/security/ir.model.access.csv
index 4d6e19d489..eab45d554f 100644
--- a/fieldservice/security/ir.model.access.csv
+++ b/fieldservice/security/ir.model.access.csv
@@ -8,17 +8,7 @@ access_fsm_person_manager,fsm.person.manager,model_fsm_person,fieldservice.group
access_fsm_location_user,fsm.location.user,model_fsm_location,fieldservice.group_fsm_user,1,1,0,0
access_fsm_location_dispatcher,fsm.location.dispatcher,model_fsm_location,fieldservice.group_fsm_dispatcher,1,1,1,0
access_fsm_order_user,fsm.order.user,model_fsm_order,fieldservice.group_fsm_user,1,1,0,0
-access_fsm_order_dispatcher,fsm.order.dispatcher,model_fsm_order,fieldservice.group_fsm_dispatcher,1,1,1,0
-access_fsm_route_user,fsm.route.user,model_fsm_route,fieldservice.group_fsm_user,1,1,0,0
-access_fsm_route_dispatcher,fsm.route.dispatcher,model_fsm_route,fieldservice.group_fsm_dispatcher,1,1,1,1
-access_fsm_territory_user,territory.user,model_fsm_territory,fieldservice.group_fsm_user,1,0,0,0
-access_fsm_territory_manager,territory.manager,model_fsm_territory,fieldservice.group_fsm_manager,1,1,1,1
-access_fsm_branch_user,branch.user,model_fsm_branch,fieldservice.group_fsm_user,1,0,0,0
-access_fsm_branch_manager,branch.manager,model_fsm_branch,fieldservice.group_fsm_manager,1,1,1,1
-access_fsm_district_user,district.user,model_fsm_district,fieldservice.group_fsm_user,1,0,0,0
-access_fsm_district_manager,district.manager,model_fsm_district,fieldservice.group_fsm_manager,1,1,1,1
-access_fsm_region_user,region.user,model_fsm_region,fieldservice.group_fsm_user,1,0,0,0
-access_fsm_region_manager,region.manager,model_fsm_region,fieldservice.group_fsm_manager,1,1,1,1
+access_fsm_order_dispatcher,fsm.order.dispatcher,model_fsm_order,fieldservice.group_fsm_dispatcher,1,1,1,1
access_fsm_equipment_fsm_user,fsm.equipment.user,model_fsm_equipment,fieldservice.group_fsm_user,1,0,0,0
access_fsm_equipment_fsm_manager,fsm.equipment.manager,model_fsm_equipment,fieldservice.group_fsm_manager,1,1,1,1
access_fsm_category_user,fsm.category.user,model_fsm_category,fieldservice.group_fsm_user,1,0,0,0
@@ -29,3 +19,5 @@ access_fsm_team_user,fsm.team.user,model_fsm_team,fieldservice.group_fsm_user,1,
access_fsm_team_manager,fsm.team.manager,model_fsm_team,fieldservice.group_fsm_manager,1,1,1,1
access_fsm_location_person_user,fsm.location.person.user,model_fsm_location_person,fieldservice.group_fsm_user,1,1,0,0
access_fsm_location_person_manager,fsm.location.person.manager,model_fsm_location_person,fieldservice.group_fsm_manager,1,1,1,1
+access_fsm_order_type_user,fsm.order.type.user,model_fsm_order_type,fieldservice.group_fsm_user,1,1,0,0
+access_fsm_order_type_manager,fsm.order.type.manager,model_fsm_order_type,fieldservice.group_fsm_manager,1,1,1,1
diff --git a/fieldservice/security/ir_rule.xml b/fieldservice/security/ir_rule.xml
index ce879b1381..44f60fd36e 100644
--- a/fieldservice/security/ir_rule.xml
+++ b/fieldservice/security/ir_rule.xml
@@ -17,13 +17,6 @@
['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
-
- FSM Routes Entry
-
-
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
-
-
FSM Teams Entry
@@ -52,4 +45,11 @@
['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+
+ FSM Stage Entry
+
+
+ ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+
+
diff --git a/fieldservice/security/res_groups.xml b/fieldservice/security/res_groups.xml
index 67e98cc034..5ee8b223cf 100644
--- a/fieldservice/security/res_groups.xml
+++ b/fieldservice/security/res_groups.xml
@@ -1,4 +1,3 @@
-
@@ -37,11 +36,6 @@
-
- Manage Field Service Substatus
-
-
-
Manage Field Service Equipment
diff --git a/fieldservice/tests/__init__.py b/fieldservice/tests/__init__.py
index 2dacb17345..673737b616 100644
--- a/fieldservice/tests/__init__.py
+++ b/fieldservice/tests/__init__.py
@@ -1,4 +1,3 @@
-# Copyright (C) 2019 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import test_fsm_wizard
diff --git a/fieldservice/tests/test_fsm_equipment.py b/fieldservice/tests/test_fsm_equipment.py
index e6387b35fb..c0149f219d 100644
--- a/fieldservice/tests/test_fsm_equipment.py
+++ b/fieldservice/tests/test_fsm_equipment.py
@@ -1,20 +1,19 @@
-# Copyright (C) 2019 - TODAY, Open Source Integrators
+# Copyright (C) 2020 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo.tests.common import TransactionCase, Form
+from odoo.tests.common import Form, TransactionCase
class FSMEquipment(TransactionCase):
-
def setUp(self):
super(FSMEquipment, self).setUp()
- self.Equipment = self.env['fsm.equipment']
- self.test_location = self.env.ref('fieldservice.test_location')
- self.test_territory = self.env.ref('fieldservice.test_territory')
- self.test_branch = self.env.ref('fieldservice.test_branch')
- self.test_district = self.env.ref('fieldservice.test_district')
- self.test_region = self.env.ref('fieldservice.test_region')
- self.current_location = self.env.ref('fieldservice.location_1')
+ self.Equipment = self.env["fsm.equipment"]
+ self.test_location = self.env.ref("fieldservice.test_location")
+ self.test_territory = self.env.ref("base_territory.test_territory")
+ self.test_branch = self.env.ref("base_territory.test_branch")
+ self.test_district = self.env.ref("base_territory.test_district")
+ self.test_region = self.env.ref("base_territory.test_region")
+ self.current_location = self.env.ref("fieldservice.location_1")
def test_fsm_equipment(self):
""" Test createing new equipment
@@ -23,9 +22,9 @@ def test_fsm_equipment(self):
- Change stage
"""
# Create an equipment
- view_id = ('fieldservice.fsm_equipment_form_view')
+ view_id = "fieldservice.fsm_equipment_form_view"
with Form(self.Equipment, view=view_id) as f:
- f.name = 'Equipment 1'
+ f.name = "Equipment 1"
f.current_location_id = self.current_location
f.location_id = self.test_location
equipment = f.save()
@@ -35,16 +34,20 @@ def test_fsm_equipment(self):
self.assertEqual(self.test_district, equipment.district_id)
self.assertEqual(self.test_region, equipment.region_id)
# Test initial stage
- self.assertEqual(equipment.stage_id,
- self.env.ref('fieldservice.equipment_stage_1'))
+ self.assertEqual(
+ equipment.stage_id, self.env.ref("fieldservice.equipment_stage_1")
+ )
# Test change state
equipment.next_stage()
- self.assertEqual(equipment.stage_id,
- self.env.ref('fieldservice.equipment_stage_2'))
+ self.assertEqual(
+ equipment.stage_id, self.env.ref("fieldservice.equipment_stage_2")
+ )
equipment.next_stage()
- self.assertEqual(equipment.stage_id,
- self.env.ref('fieldservice.equipment_stage_3'))
+ self.assertEqual(
+ equipment.stage_id, self.env.ref("fieldservice.equipment_stage_3")
+ )
self.assertTrue(equipment.hide) # hide as max stage
equipment.previous_stage()
- self.assertEqual(equipment.stage_id,
- self.env.ref('fieldservice.equipment_stage_2'))
+ self.assertEqual(
+ equipment.stage_id, self.env.ref("fieldservice.equipment_stage_2")
+ )
diff --git a/fieldservice/tests/test_fsm_location.py b/fieldservice/tests/test_fsm_location.py
index 27a98a3ed4..a253e2f898 100644
--- a/fieldservice/tests/test_fsm_location.py
+++ b/fieldservice/tests/test_fsm_location.py
@@ -1,29 +1,24 @@
-# Copyright (C) 2019 - TODAY, Open Source Integrators
+# Copyright (C) 2020 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo.tests.common import TransactionCase, Form
from odoo.exceptions import ValidationError
+from odoo.tests.common import Form, TransactionCase
class FSMLocation(TransactionCase):
-
def setUp(self):
super(FSMLocation, self).setUp()
- self.Location = self.env['fsm.location']
- self.Equipment = self.env['fsm.equipment']
- self.test_location = self.env.ref('fieldservice.test_location')
- self.location_1 = self.env.ref('fieldservice.location_1')
- self.location_2 = self.env.ref('fieldservice.location_2')
- self.location_3 = self.env.ref('fieldservice.location_3')
- self.test_territory = self.env.ref('fieldservice.test_territory')
- self.test_loc_partner = self.env.ref('fieldservice.'
- 'test_loc_partner')
- self.location_partner_1 = self.env.ref('fieldservice.'
- 'location_partner_1')
- self.location_partner_2 = self.env.ref('fieldservice.'
- 'location_partner_2')
- self.location_partner_3 = self.env.ref('fieldservice.'
- 'location_partner_3')
+ self.Location = self.env["fsm.location"]
+ self.Equipment = self.env["fsm.equipment"]
+ self.test_location = self.env.ref("fieldservice.test_location")
+ self.location_1 = self.env.ref("fieldservice.location_1")
+ self.location_2 = self.env.ref("fieldservice.location_2")
+ self.location_3 = self.env.ref("fieldservice.location_3")
+ self.test_territory = self.env.ref("base_territory.test_territory")
+ self.test_loc_partner = self.env.ref("fieldservice.test_loc_partner")
+ self.location_partner_1 = self.env.ref("fieldservice.location_partner_1")
+ self.location_partner_2 = self.env.ref("fieldservice.location_partner_2")
+ self.location_partner_3 = self.env.ref("fieldservice.location_partner_3")
def test_fsm_location(self):
""" Test createing new location
@@ -33,37 +28,53 @@ def test_fsm_location(self):
- Create fsm.location.person if auto_populate_persons_on_location
"""
# Create an equipment
- view_id = ('fieldservice.fsm_location_form_view')
+ view_id = "fieldservice.fsm_location_form_view"
with Form(self.Location, view=view_id) as f:
- f.name = 'Child Location'
+ f.name = "Child Location"
f.fsm_parent_id = self.test_location
location = f.save()
# Test child location equal to parent location
- for x in ['owner_id', 'customer_id', 'contact_id', 'direction',
- 'street', 'street2', 'city', 'zip', 'state_id', 'country_id',
- 'tz', 'territory_id']:
+ for x in [
+ "owner_id",
+ "contact_id",
+ "direction",
+ "street",
+ "street2",
+ "city",
+ "zip",
+ "state_id",
+ "country_id",
+ "tz",
+ "territory_id",
+ ]:
self.assertEqual(location[x], self.test_location[x])
# Test initial stage
- self.assertEqual(location.stage_id,
- self.env.ref('fieldservice.location_stage_1'))
+ self.assertEqual(
+ location.stage_id, self.env.ref("fieldservice.location_stage_1")
+ )
# Test change state
location.next_stage()
- self.assertEqual(location.stage_id,
- self.env.ref('fieldservice.location_stage_2'))
+ self.assertEqual(
+ location.stage_id, self.env.ref("fieldservice.location_stage_2")
+ )
location.next_stage()
- self.assertEqual(location.stage_id,
- self.env.ref('fieldservice.location_stage_3'))
+ self.assertEqual(
+ location.stage_id, self.env.ref("fieldservice.location_stage_3")
+ )
self.assertTrue(location.hide) # hide as max stage
location.previous_stage()
- self.assertEqual(location.stage_id,
- self.env.ref('fieldservice.location_stage_2'))
+ self.assertEqual(
+ location.stage_id, self.env.ref("fieldservice.location_stage_2")
+ )
# Test create fsm.location.person, when has if territory has person_ids
self.env.user.company_id.auto_populate_persons_on_location = True
- person_ids = [self.env.ref('fieldservice.person_1').id,
- self.env.ref('fieldservice.person_2').id,
- self.env.ref('fieldservice.person_3').id]
- self.test_territory.write({'person_ids': [(6, 0, person_ids)]})
+ person_ids = [
+ self.env.ref("fieldservice.person_1").id,
+ self.env.ref("fieldservice.person_2").id,
+ self.env.ref("fieldservice.person_3").id,
+ ]
+ self.test_territory.write({"person_ids": [(6, 0, person_ids)]})
location.territory_id = self.test_territory
self.assertEqual(len(location.person_ids), 0)
location._onchange_territory_id()
@@ -79,16 +90,22 @@ def test_fsm_multi_sublocation(self):
self.location_2.fsm_parent_id = self.location_1
self.location_1.fsm_parent_id = self.test_location
# Test sublocation_count of each level
- self.assertEqual((self.test_location.sublocation_count,
- self.location_1.sublocation_count,
- self.location_2.sublocation_count,
- self.location_3.sublocation_count), (3, 2, 1, 0))
- loc_ids = self.test_location.action_view_sublocation()['domain'][0][2]
- loc_1_ids = self.location_1.action_view_sublocation()['domain'][0][2]
- loc_2_ids = [self.location_2.action_view_sublocation()['res_id']]
- loc_3_ids = self.location_3.action_view_sublocation()['domain'][0][2]
- self.assertEqual((len(loc_ids), len(loc_1_ids), len(loc_2_ids),
- len(loc_3_ids)), (3, 2, 1, 0))
+ self.assertEqual(
+ (
+ self.test_location.sublocation_count,
+ self.location_1.sublocation_count,
+ self.location_2.sublocation_count,
+ self.location_3.sublocation_count,
+ ),
+ (3, 2, 1, 0),
+ )
+ loc_ids = self.test_location.action_view_sublocation()["domain"][0][2]
+ loc_1_ids = self.location_1.action_view_sublocation()["domain"][0][2]
+ loc_2_ids = [self.location_2.action_view_sublocation()["res_id"]]
+ loc_3_ids = self.location_3.action_view_sublocation()["domain"][0][2]
+ self.assertEqual(
+ (len(loc_ids), len(loc_1_ids), len(loc_2_ids), len(loc_3_ids)), (3, 2, 1, 0)
+ )
# Test recursion exception
with self.assertRaises(ValidationError):
@@ -96,28 +113,40 @@ def test_fsm_multi_sublocation(self):
self.test_location.fsm_parent_id = False # Set back
# Add equipments on each locations, and test counting
- location_vs_num_eq = {self.test_location.id: 1, # Topup = 9
- self.location_1.id: 1, # Topup = 8
- self.location_2.id: 5, # Topup = 7
- self.location_3.id: 2} # Topup = 2
+ location_vs_num_eq = {
+ self.test_location.id: 1, # Topup = 9
+ self.location_1.id: 1, # Topup = 8
+ self.location_2.id: 5, # Topup = 7
+ self.location_3.id: 2,
+ } # Topup = 2
for loc_id, num_eq in location_vs_num_eq.items():
for i in range(num_eq):
- self.Equipment.create({
- 'name': 'Eq-%s-%s' % (str(loc_id), str(i+1)),
- 'location_id': loc_id,
- 'current_location_id': loc_id, })
+ self.Equipment.create(
+ {
+ "name": "Eq-{}-{}".format(str(loc_id), str(i + 1)),
+ "location_id": loc_id,
+ "current_location_id": loc_id,
+ }
+ )
# Test valid equipments at each location
- self.assertEqual((self.test_location.equipment_count,
- self.location_1.equipment_count,
- self.location_2.equipment_count,
- self.location_3.equipment_count), (9, 8, 7, 2)) # !!
+ self.assertEqual(
+ (
+ self.test_location.equipment_count,
+ self.location_1.equipment_count,
+ self.location_2.equipment_count,
+ self.location_3.equipment_count,
+ ),
+ (9, 8, 7, 2),
+ ) # !!
# Test smart button to open equipment
- loc_eq_ids = self.test_location.action_view_equipment()['domain'][0][2]
- loc_1_eq_ids = self.location_1.action_view_equipment()['domain'][0][2]
- loc_2_eq_ids = self.location_2.action_view_equipment()['domain'][0][2]
- loc_3_eq_ids = self.location_3.action_view_equipment()['domain'][0][2]
- self.assertEqual((len(loc_eq_ids), len(loc_1_eq_ids),
- len(loc_2_eq_ids), len(loc_3_eq_ids)), (9, 8, 7, 2))
+ loc_eq_ids = self.test_location.action_view_equipment()["domain"][0][2]
+ loc_1_eq_ids = self.location_1.action_view_equipment()["domain"][0][2]
+ loc_2_eq_ids = self.location_2.action_view_equipment()["domain"][0][2]
+ loc_3_eq_ids = self.location_3.action_view_equipment()["domain"][0][2]
+ self.assertEqual(
+ (len(loc_eq_ids), len(loc_1_eq_ids), len(loc_2_eq_ids), len(loc_3_eq_ids)),
+ (9, 8, 7, 2),
+ )
# Set service_location_id, on relavant res.partner, test contact count
self.test_loc_partner.service_location_id = self.test_location
@@ -125,14 +154,21 @@ def test_fsm_multi_sublocation(self):
self.location_partner_2.service_location_id = self.location_2
self.location_partner_3.service_location_id = self.location_3
# Test valid contacts at each location
- self.assertEqual((self.test_location.contact_count,
- self.location_1.contact_count,
- self.location_2.contact_count,
- self.location_3.contact_count), (4, 3, 2, 1))
+ self.assertEqual(
+ (
+ self.test_location.contact_count,
+ self.location_1.contact_count,
+ self.location_2.contact_count,
+ self.location_3.contact_count,
+ ),
+ (4, 3, 2, 1),
+ )
# Test smart button to open contacts
- cont_ids = self.test_location.action_view_contacts()['domain'][0][2]
- cont_1_ids = self.location_1.action_view_contacts()['domain'][0][2]
- cont_2_ids = self.location_2.action_view_contacts()['domain'][0][2]
- cont_3_ids = [self.location_3.action_view_contacts()['res_id']]
- self.assertEqual((len(cont_ids), len(cont_1_ids),
- len(cont_2_ids), len(cont_3_ids)), (4, 3, 2, 1))
+ cont_ids = self.test_location.action_view_contacts()["domain"][0][2]
+ cont_1_ids = self.location_1.action_view_contacts()["domain"][0][2]
+ cont_2_ids = self.location_2.action_view_contacts()["domain"][0][2]
+ cont_3_ids = [self.location_3.action_view_contacts()["res_id"]]
+ self.assertEqual(
+ (len(cont_ids), len(cont_1_ids), len(cont_2_ids), len(cont_3_ids)),
+ (4, 3, 2, 1),
+ )
diff --git a/fieldservice/tests/test_fsm_order.py b/fieldservice/tests/test_fsm_order.py
index 58ade20665..8405671ffb 100644
--- a/fieldservice/tests/test_fsm_order.py
+++ b/fieldservice/tests/test_fsm_order.py
@@ -1,17 +1,17 @@
-# Copyright (C) 2019 - TODAY, Open Source Integrators
+# Copyright (C) 2020 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from datetime import timedelta
+
from odoo import fields
-from odoo.tests.common import TransactionCase, Form
+from odoo.tests.common import Form, TransactionCase
class TestFSMOrder(TransactionCase):
-
def setUp(self):
super(TestFSMOrder, self).setUp()
- self.Order = self.env['fsm.order']
- self.test_location = self.env.ref('fieldservice.test_location')
+ self.Order = self.env["fsm.order"]
+ self.test_location = self.env.ref("fieldservice.test_location")
def test_fsm_order(self):
""" Test creating new workorders, and test following functions,
@@ -21,7 +21,7 @@ def test_fsm_order(self):
- scheduled_date_end = scheduled_date_start + duration (hrs)
"""
# Create an Orders
- view_id = ('fieldservice.fsm_order_form')
+ view_id = "fieldservice.fsm_order_form"
hours_diff = 100
with Form(self.Order, view=view_id) as f:
f.location_id = self.test_location
@@ -32,35 +32,38 @@ def test_fsm_order(self):
# Test _compute_duration
self.assertEqual(order.duration, hours_diff)
# Test _compute_request_late()
- priority_vs_late_days = {'0': 3, '1': 2, '2': 1, '3': 1/3}
+ priority_vs_late_days = {"0": 3, "1": 2, "2": 1, "3": 1 / 3}
for priority, late_days in priority_vs_late_days.items():
order.priority = priority
order.request_late = False
- vals = {
- 'request_early': fields.Datetime.today(),
- 'priority': priority
- }
+ vals = {"request_early": fields.Datetime.today(), "priority": priority}
vals = order._compute_request_late(vals)
- self.assertEqual(vals['request_late'],
- order.request_early + timedelta(days=late_days))
+ self.assertEqual(
+ vals["request_late"], order.request_early + timedelta(days=late_days)
+ )
# Test set scheduled_date_start using request_early w/o time
- self.assertEqual(order.scheduled_date_start,
- order.request_early.replace(minute=0, second=0))
+ self.assertEqual(
+ order.scheduled_date_start, order.request_early.replace(minute=0, second=0)
+ )
# Test scheduled_date_end = scheduled_date_start + duration (hrs)
# Set date start
- order.scheduled_date_start = \
- order.scheduled_date_start.replace(hour=0, minute=0, second=0)
+ order.scheduled_date_start = order.scheduled_date_start.replace(
+ hour=0, minute=0, second=0
+ )
# Set duration
duration = 10
order.scheduled_duration = duration
# Check date end
self.assertEqual(
order.scheduled_date_end,
- order.scheduled_date_start + timedelta(hours=duration))
+ order.scheduled_date_start + timedelta(hours=duration),
+ )
# Set new date end
- order.scheduled_date_end = \
- order.scheduled_date_end.replace(hour=1, minute=1, second=1)
+ order.scheduled_date_end = order.scheduled_date_end.replace(
+ hour=1, minute=1, second=0
+ )
# Check date start
self.assertEqual(
order.scheduled_date_start,
- order.scheduled_date_end - timedelta(hours=duration))
+ order.scheduled_date_end - timedelta(hours=duration),
+ )
diff --git a/fieldservice/tests/test_fsm_order_template_onchange.py b/fieldservice/tests/test_fsm_order_template_onchange.py
index 01519f3b31..93238ff622 100644
--- a/fieldservice/tests/test_fsm_order_template_onchange.py
+++ b/fieldservice/tests/test_fsm_order_template_onchange.py
@@ -1,25 +1,20 @@
# Copyright (C) 2019 Brian McMaster
+# Copyright (C) 2020 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields
+
from . import test_fsm_order
class TestTemplateOnchange(test_fsm_order.TestFSMOrder):
-
def setUp(self):
super(TestTemplateOnchange, self).setUp()
- self.fsm_category_a = self.env['fsm.category'].create({
- 'name': 'Category A'
- })
- self.fsm_category_b = self.env['fsm.category'].create({
- 'name': 'Category B'
- })
- self.fsm_type_a = self.env['fsm.order.type'].create({
- 'name': 'FSM Order Type A'
- })
- self.fsm_team_a = self.env['fsm.team'].create({
- 'name': 'FSM Team A'
- })
+ self.fsm_category_a = self.env["fsm.category"].create({"name": "Category A"})
+ self.fsm_category_b = self.env["fsm.category"].create({"name": "Category B"})
+ self.fsm_type_a = self.env["fsm.order.type"].create(
+ {"name": "FSM Order Type A"}
+ )
+ self.fsm_team_a = self.env["fsm.team"].create({"name": "FSM Team A"})
def test_fsm_order_onchange_template(self):
""" Test the onchange function for FSM Template
@@ -29,37 +24,28 @@ def test_fsm_order_onchange_template(self):
categories = []
categories.append(self.fsm_category_a.id)
categories.append(self.fsm_category_b.id)
- self.fsm_template_1 = self.env['fsm.template'].create({
- 'name': 'Test FSM Template #1',
- 'instructions': 'These are the instructions for Template #1',
- 'category_ids': (6, 0, categories),
- 'hours': 2.25,
- 'type_id': self.fsm_type_a.id,
- 'team_id': self.fsm_team_a.id,
- })
- self.fso = self.Order.create({
- 'location_id': self.test_location.id,
- 'template_id': self.fsm_template_1.id,
- 'scheduled_date_start': fields.Datetime.today(),
- })
- self.fso._onchange_template_id()
- self.assertEqual(
- self.fso.category_ids.ids,
- self.fsm_template_1.category_ids.ids
+ self.fsm_template_1 = self.env["fsm.template"].create(
+ {
+ "name": "Test FSM Template #1",
+ "instructions": "These are the instructions for Template #1",
+ "category_ids": [(6, 0, categories)],
+ "hours": 2.25,
+ "type_id": self.fsm_type_a.id,
+ "team_id": self.fsm_team_a.id,
+ }
)
- self.assertEqual(
- self.fso.scheduled_duration,
- self.fsm_template_1.hours
- )
- self.assertEqual(
- self.fso.type.id,
- self.fsm_template_1.type_id.id
- )
- self.assertEqual(
- self.fso.todo,
- self.fsm_template_1.instructions
+ self.fso = self.Order.create(
+ {
+ "location_id": self.test_location.id,
+ "template_id": self.fsm_template_1.id,
+ "scheduled_date_start": fields.Datetime.today(),
+ }
)
+ self.fso._onchange_template_id()
self.assertEqual(
- self.fso.team_id.id,
- self.fsm_team_a.id
+ self.fso.category_ids.ids, self.fsm_template_1.category_ids.ids
)
+ self.assertEqual(self.fso.scheduled_duration, self.fsm_template_1.hours)
+ self.assertEqual(self.fso.type.id, self.fsm_template_1.type_id.id)
+ self.assertEqual(self.fso.todo, self.fsm_template_1.instructions)
+ self.assertEqual(self.fso.team_id.id, self.fsm_team_a.id)
diff --git a/fieldservice/tests/test_fsm_person.py b/fieldservice/tests/test_fsm_person.py
index c5d7e94528..6dc9e55e0f 100644
--- a/fieldservice/tests/test_fsm_person.py
+++ b/fieldservice/tests/test_fsm_person.py
@@ -1,14 +1,13 @@
-# Copyright (C) 2019 - TODAY, Open Source Integrators
+# Copyright (C) 2020 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo.tests.common import TransactionCase, Form
+from odoo.tests.common import Form, TransactionCase
class FSMPerson(TransactionCase):
-
def setUp(self):
super(FSMPerson, self).setUp()
- self.Worker = self.env['fsm.person']
+ self.Worker = self.env["fsm.person"]
def test_fsm_location(self):
""" Test createing new person
@@ -17,23 +16,19 @@ def test_fsm_location(self):
- _search
"""
# Create an equipment
- view_id = ('fieldservice.fsm_person_form')
+ view_id = "fieldservice.fsm_person_form"
with Form(self.Worker, view=view_id) as f:
- f.name = 'Worker A'
+ f.name = "Worker A"
worker = f.save()
# Test initial stage
- self.assertEqual(worker.stage_id,
- self.env.ref('fieldservice.worker_stage_1'))
+ self.assertEqual(worker.stage_id, self.env.ref("fieldservice.worker_stage_1"))
# Test change state
worker.next_stage()
- self.assertEqual(worker.stage_id,
- self.env.ref('fieldservice.worker_stage_2'))
+ self.assertEqual(worker.stage_id, self.env.ref("fieldservice.worker_stage_2"))
worker.next_stage()
- self.assertEqual(worker.stage_id,
- self.env.ref('fieldservice.worker_stage_3'))
+ self.assertEqual(worker.stage_id, self.env.ref("fieldservice.worker_stage_3"))
self.assertTrue(worker.hide) # hide as max stage
worker.previous_stage()
- self.assertEqual(worker.stage_id,
- self.env.ref('fieldservice.worker_stage_2'))
+ self.assertEqual(worker.stage_id, self.env.ref("fieldservice.worker_stage_2"))
# TODO: https://github.com/OCA/field-service/issues/265
diff --git a/fieldservice/tests/test_fsm_team.py b/fieldservice/tests/test_fsm_team.py
index 13905e8acb..51f2ff008d 100644
--- a/fieldservice/tests/test_fsm_team.py
+++ b/fieldservice/tests/test_fsm_team.py
@@ -1,17 +1,16 @@
-# Copyright (C) 2019 - TODAY, Open Source Integrators
+# Copyright (C) 2020 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo.tests.common import TransactionCase, Form
+from odoo.tests.common import Form, TransactionCase
class FSMTeam(TransactionCase):
-
def setUp(self):
super(FSMTeam, self).setUp()
- self.Order = self.env['fsm.order']
- self.Team = self.env['fsm.team']
- self.test_location = self.env.ref('fieldservice.test_location')
- self.test_team = self.Team.create({'name': 'Test Team'})
+ self.Order = self.env["fsm.order"]
+ self.Team = self.env["fsm.team"]
+ self.test_location = self.env.ref("fieldservice.test_location")
+ self.test_team = self.Team.create({"name": "Test Team"})
def test_fsm_order(self):
""" Test creating new workorders
@@ -22,20 +21,26 @@ def test_fsm_order(self):
# Create 5 Orders, which are,
# - 2 assigned (3 unassigned)
# - 4 scheduled (1 unscheduled)
- todo = {'orders': 5, 'assigned': [3, 4], 'scheduled': [0, 1, 2, 3]}
- view_id = ('fieldservice.fsm_order_form')
+ todo = {"orders": 5, "assigned": [3, 4], "scheduled": [0, 1, 2, 3]}
+ view_id = "fieldservice.fsm_order_form"
orders = self.Order
- for i in range(todo['orders']):
+ for i in range(todo["orders"]):
with Form(self.Order, view=view_id) as f:
f.location_id = self.test_location
f.team_id = self.test_team
order = f.save()
orders += order
- order.person_id = i in todo['assigned'] and \
- self.env.ref('fieldservice.person_1') or False
+ order.person_id = (
+ i in todo["assigned"] and self.env.ref("fieldservice.person_1") or False
+ )
# TODO: after this https://github.com/OCA/field-service/issues/266
# assert should then be (5, 3, 1)
# order.scheduled_date_start = False
- self.assertEqual((self.test_team.order_count,
- self.test_team.order_need_assign_count,
- self.test_team.order_need_schedule_count), (5, 3, 0))
+ self.assertEqual(
+ (
+ self.test_team.order_count,
+ self.test_team.order_need_assign_count,
+ self.test_team.order_need_schedule_count,
+ ),
+ (5, 3, 0),
+ )
diff --git a/fieldservice/tests/test_fsm_wizard.py b/fieldservice/tests/test_fsm_wizard.py
index bfdeba009a..4d8e7f23ae 100644
--- a/fieldservice/tests/test_fsm_wizard.py
+++ b/fieldservice/tests/test_fsm_wizard.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2019 - TODAY, Open Source Integrators
+# Copyright (C) 2020 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests.common import TransactionCase
@@ -14,23 +14,24 @@ class FSMWizard(TransactionCase):
- test_convert_sublocation: tests that the sub-contacts on a
res.partner are converted into Other Addresses.
"""
+
def setUp(self):
super(FSMWizard, self).setUp()
- self.Wizard = self.env['fsm.wizard']
- self.test_partner = self.env.ref('fieldservice.test_partner')
- self.test_parent_partner = \
- self.env.ref('fieldservice.test_parent_partner')
- self.test_loc_partner = self.env.ref('fieldservice.test_loc_partner')
- self.test_location = self.env.ref('fieldservice.test_location')
- self.test_person = self.env.ref('fieldservice.test_person')
+ self.Wizard = self.env["fsm.wizard"]
+ self.test_partner = self.env.ref("fieldservice.test_partner")
+ self.test_parent_partner = self.env.ref("fieldservice.test_parent_partner")
+ self.test_loc_partner = self.env.ref("fieldservice.test_loc_partner")
+ self.test_location = self.env.ref("fieldservice.test_location")
+ self.test_person = self.env.ref("fieldservice.test_person")
def test_convert_location(self):
# convert test_partner to FSM Location
self.Wizard.action_convert_location(self.test_partner)
# check if there is a new FSM Location with name 'Test Partner'
- self.wiz_location = self.env['fsm.location'].\
- search([('name', '=', 'Test Partner')])
+ self.wiz_location = self.env["fsm.location"].search(
+ [("name", "=", "Test Partner")]
+ )
# check if 'Test Partner' creation successful and fields copied over
self.assertEqual(self.test_location.phone, self.wiz_location.phone)
@@ -41,8 +42,7 @@ def test_convert_person(self):
self.Wizard.action_convert_person(self.test_partner)
# check if there is a new FSM Person with name 'Test Partner'
- self.wiz_person = self.env['fsm.person'].\
- search([('name', '=', 'Test Partner')])
+ self.wiz_person = self.env["fsm.person"].search([("name", "=", "Test Partner")])
# check if 'Test Partner' creation successful and fields copied over
self.assertEqual(self.test_person.phone, self.wiz_person.phone)
@@ -53,9 +53,8 @@ def test_convert_sublocation(self):
self.Wizard.action_convert_location(self.test_parent_partner)
# check if 'Parent Partner' creation successful and fields copied over
- wiz_parent = self.env['fsm.location'].\
- search([('name', '=', 'Parent Partner')])
+ wiz_parent = self.env["fsm.location"].search([("name", "=", "Parent Partner")])
# check all children were assigned type 'other'
for child in wiz_parent.child_ids:
- self.assertEqual(child.type, 'other')
+ self.assertEqual(child.type, "other")
diff --git a/fieldservice/views/fsm_branch.xml b/fieldservice/views/fsm_branch.xml
deleted file mode 100644
index 7e642b122b..0000000000
--- a/fieldservice/views/fsm_branch.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
- fsm.branch.tree
- fsm.branch
-
-
-
-
-
-
-
-
-
-
- fsm.branch.form
- fsm.branch
-
-
-
-
-
-
- Branches
- fsm.branch
-
- form
- tree,form
-
-
-
diff --git a/fieldservice/views/fsm_category.xml b/fieldservice/views/fsm_category.xml
index 06645ea036..5c8193b01c 100644
--- a/fieldservice/views/fsm_category.xml
+++ b/fieldservice/views/fsm_category.xml
@@ -1,4 +1,3 @@
-
@@ -45,7 +44,6 @@
Field Service Category
fsm.category
- form
tree,form
diff --git a/fieldservice/views/fsm_district.xml b/fieldservice/views/fsm_district.xml
deleted file mode 100644
index c4f36f416b..0000000000
--- a/fieldservice/views/fsm_district.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
- fsm.district.tree
- fsm.district
-
-
-
-
-
-
-
-
-
-
- fsm.district.form
- fsm.district
-
-
-
-
-
-
- Districts
- fsm.district
-
- form
- tree,form
-
-
-
diff --git a/fieldservice/views/fsm_equipment.xml b/fieldservice/views/fsm_equipment.xml
index a258cb2432..a3d92ed325 100644
--- a/fieldservice/views/fsm_equipment.xml
+++ b/fieldservice/views/fsm_equipment.xml
@@ -1,4 +1,3 @@
-
@@ -41,6 +40,8 @@
+
+
@@ -123,7 +124,6 @@
Field Service Equipment
fsm.equipment
- form
tree,form
{'default_location_id':
@@ -195,7 +195,6 @@
Field Service Equipment
fsm.equipment
- form
tree,kanban,form
@@ -228,7 +227,6 @@
Equipments
fsm.equipment
- form
graph,pivot
diff --git a/fieldservice/views/fsm_location.xml b/fieldservice/views/fsm_location.xml
index 590e8047ca..4bc5621b93 100644
--- a/fieldservice/views/fsm_location.xml
+++ b/fieldservice/views/fsm_location.xml
@@ -1,4 +1,3 @@
-
@@ -18,7 +17,6 @@
-
@@ -71,7 +69,6 @@
-
@@ -155,7 +152,6 @@
string="Location"/>
-
@@ -174,7 +170,6 @@
-
@@ -184,7 +179,6 @@
Service Locations
fsm.location
- form
tree,form
@@ -217,7 +211,6 @@
Locations
fsm.location
- form
pivot,graph
diff --git a/fieldservice/views/fsm_location_person.xml b/fieldservice/views/fsm_location_person.xml
index b30bad35ba..f248fdc526 100644
--- a/fieldservice/views/fsm_location_person.xml
+++ b/fieldservice/views/fsm_location_person.xml
@@ -1,4 +1,3 @@
-
@@ -25,7 +24,6 @@
-
@@ -59,7 +57,6 @@
Location Persons
fsm.location.person
- form
tree,form
diff --git a/fieldservice/views/fsm_order.xml b/fieldservice/views/fsm_order.xml
index d3bba25256..5dbe482073 100644
--- a/fieldservice/views/fsm_order.xml
+++ b/fieldservice/views/fsm_order.xml
@@ -1,4 +1,3 @@
-
@@ -21,7 +20,8 @@
attrs="{'invisible': [('stage_id', 'in', (%(fieldservice.fsm_stage_completed)d, %(fieldservice.fsm_stage_cancelled)d))]}"/>
+ domain="[('stage_type', '=', 'order'),
+ ('team_ids', 'in', (team_id, False))]"/>
@@ -32,7 +32,7 @@