From 348472e876c1cbb29e7e55b0640d289046f5c250 Mon Sep 17 00:00:00 2001 From: brian10048 Date: Wed, 10 Oct 2018 21:05:38 -0400 Subject: [PATCH 1/2] [ADD] Vehicle --- fieldservice/__manifest__.py | 1 + fieldservice/models/__init__.py | 1 + fieldservice/models/fsm_route.py | 5 ++++ fieldservice/models/fsm_vehicle.py | 16 ++++++++++ fieldservice/views/fsm_route.xml | 1 + fieldservice/views/fsm_vehicle.xml | 48 ++++++++++++++++++++++++++++++ fieldservice/views/menu.xml | 7 +++++ 7 files changed, 79 insertions(+) create mode 100644 fieldservice/models/fsm_vehicle.py create mode 100644 fieldservice/views/fsm_vehicle.xml diff --git a/fieldservice/__manifest__.py b/fieldservice/__manifest__.py index beee4c86e6..cf03364090 100644 --- a/fieldservice/__manifest__.py +++ b/fieldservice/__manifest__.py @@ -25,6 +25,7 @@ 'views/res_partner.xml', 'views/fsm_location.xml', 'views/fsm_person.xml', + 'views/fsm_vehicle.xml', 'views/fsm_order.xml', 'views/fsm_route.xml', 'views/menu.xml', diff --git a/fieldservice/models/__init__.py b/fieldservice/models/__init__.py index acb7632eb0..0dfc2aea9e 100644 --- a/fieldservice/models/__init__.py +++ b/fieldservice/models/__init__.py @@ -8,6 +8,7 @@ fsm_tag, fsm_location, fsm_person, + fsm_vehicle, fsm_order, fsm_route, ) diff --git a/fieldservice/models/fsm_route.py b/fieldservice/models/fsm_route.py index b1f4e8ab83..d4732a716c 100644 --- a/fieldservice/models/fsm_route.py +++ b/fieldservice/models/fsm_route.py @@ -16,12 +16,17 @@ class FSMRoute(models.Model): fsm_person_id = fields.Many2one('fsm.person', string='Assigned To', required=True) + fsm_vehicle_id = fields.Many2one('fsm.vehicle', + string='Assigned Vehicle') date = fields.Date(string='Date', required=True) _sql_constraints = [ ('fsm_route_person_date_uniq', 'unique (fsm_person_id, date)', "You cannot create 2 routes for the same person on the same day!"), + ('fsm_route_vehicle_date_uniq', + 'unique (fsm_vehicle_id, date)', + "You cannot create 2 routes for the same vehicle on the same day!"), ] @api.model diff --git a/fieldservice/models/fsm_vehicle.py b/fieldservice/models/fsm_vehicle.py new file mode 100644 index 0000000000..cfd4c9425f --- /dev/null +++ b/fieldservice/models/fsm_vehicle.py @@ -0,0 +1,16 @@ +# Copyright (C) 2018 - TODAY, Brian McMaster +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class FSMVehicle(models.Model): + _name = 'fsm.vehicle' + _description = 'Field Service Vehicle' + + name = fields.Char(string='Name', required='True') + fsm_person_id = fields.Many2one('fsm.person', string='Assigned Driver') + + _sql_constraints = [ + ('name_uniq', 'unique (name)', "Vehicle name already exists!"), + ] \ No newline at end of file diff --git a/fieldservice/views/fsm_route.xml b/fieldservice/views/fsm_route.xml index 0b09429c2f..8654c58254 100644 --- a/fieldservice/views/fsm_route.xml +++ b/fieldservice/views/fsm_route.xml @@ -28,6 +28,7 @@ + diff --git a/fieldservice/views/fsm_vehicle.xml b/fieldservice/views/fsm_vehicle.xml new file mode 100644 index 0000000000..beac8a8092 --- /dev/null +++ b/fieldservice/views/fsm_vehicle.xml @@ -0,0 +1,48 @@ + + + + + + fsm.vehicle.tree + fsm.vehicle + + + + + + + + + + fsm.vehicle.form + fsm.vehicle + +
+ + + + + + + + + + +
+
+
+ + + + Field Service Vehicles + fsm.vehicle + form + tree,form + +

+ Add a Field Service Vehicle here. +

+
+
+ +
diff --git a/fieldservice/views/menu.xml b/fieldservice/views/menu.xml index 859d68fbc7..64423725c8 100644 --- a/fieldservice/views/menu.xml +++ b/fieldservice/views/menu.xml @@ -66,6 +66,13 @@ parent="data" sequence="30"/> + + Date: Thu, 11 Oct 2018 20:40:07 -0400 Subject: [PATCH 2/2] [FIX] vehicle access rights for Vehicle, other Travis errors --- fieldservice/models/fsm_route.py | 2 +- fieldservice/models/fsm_vehicle.py | 4 ++-- fieldservice/security/ir.model.access.csv | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fieldservice/models/fsm_route.py b/fieldservice/models/fsm_route.py index d4732a716c..8bfddb688b 100644 --- a/fieldservice/models/fsm_route.py +++ b/fieldservice/models/fsm_route.py @@ -17,7 +17,7 @@ class FSMRoute(models.Model): string='Assigned To', required=True) fsm_vehicle_id = fields.Many2one('fsm.vehicle', - string='Assigned Vehicle') + string='Assigned Vehicle') date = fields.Date(string='Date', required=True) _sql_constraints = [ diff --git a/fieldservice/models/fsm_vehicle.py b/fieldservice/models/fsm_vehicle.py index cfd4c9425f..28b8b1b1fe 100644 --- a/fieldservice/models/fsm_vehicle.py +++ b/fieldservice/models/fsm_vehicle.py @@ -1,7 +1,7 @@ # Copyright (C) 2018 - TODAY, Brian McMaster # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models +from odoo import fields, models class FSMVehicle(models.Model): @@ -13,4 +13,4 @@ class FSMVehicle(models.Model): _sql_constraints = [ ('name_uniq', 'unique (name)', "Vehicle name already exists!"), - ] \ No newline at end of file + ] diff --git a/fieldservice/security/ir.model.access.csv b/fieldservice/security/ir.model.access.csv index b334a0c41c..0ae52da434 100644 --- a/fieldservice/security/ir.model.access.csv +++ b/fieldservice/security/ir.model.access.csv @@ -11,3 +11,5 @@ access_fsm_order_user,fsm.order.user,model_fsm_order,fieldservice.group_fsm_user 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_vehicle_fsm_user,fsm.vehicle.user,model_fsm_vehicle,fieldservice.group_fsm_user,1,0,0,0 +access_fsm_vehicle_fsm_manager,fsm.vehicle.manager,model_fsm_vehicle,fieldservice.group_fsm_manager,1,1,1,1