Skip to content

Commit

Permalink
[ADD] Vehicle (OCA#23)
Browse files Browse the repository at this point in the history
* [ADD] Vehicle
  • Loading branch information
brian10048 authored and robertrottermann committed Oct 16, 2018
1 parent 3bd8771 commit 81ee319
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions fieldservice/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions fieldservice/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
fsm_tag,
fsm_location,
fsm_person,
fsm_vehicle,
fsm_order,
fsm_route,
)
5 changes: 5 additions & 0 deletions fieldservice/models/fsm_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions fieldservice/models/fsm_vehicle.py
Original file line number Diff line number Diff line change
@@ -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 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!"),
]
2 changes: 2 additions & 0 deletions fieldservice/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions fieldservice/views/fsm_route.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<group>
<group>
<field name="fsm_person_id"/>
<field name="fsm_vehicle_id" groups="fieldservice.group_fsm_vehicle"/>
</group>
<group>
<field name="date"/>
Expand Down
48 changes: 48 additions & 0 deletions fieldservice/views/fsm_vehicle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<!-- Field Service Vehicle -->
<record id="fsm_vehicle_tree_view" model="ir.ui.view">
<field name="name">fsm.vehicle.tree</field>
<field name="model">fsm.vehicle</field>
<field name="arch" type="xml">
<tree string="Vehicles">
<field name="name"/>
<field name="fsm_person_id"/>
</tree>
</field>
</record>

<record id="fsm_vehicle_form_view" model="ir.ui.view">
<field name="name">fsm.vehicle.form</field>
<field name="model">fsm.vehicle</field>
<field name="arch" type="xml">
<form string="Vehicle">
<sheet>
<group>
<group>
<field name="name"/>
</group>
<group>
<field name="fsm_person_id"/>
</group>
</group>
</sheet>
</form>
</field>
</record>

<!-- Field Service Vehicles -->
<record id="action_fsm_vehicle" model="ir.actions.act_window">
<field name="name">Field Service Vehicles</field>
<field name="res_model">fsm.vehicle</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Add a Field Service Vehicle here.
</p>
</field>
</record>

</odoo>
7 changes: 7 additions & 0 deletions fieldservice/views/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@
parent="data"
sequence="30"/>

<menuitem id="menu_fsm_vehicle"
name="Vehicles"
action="action_fsm_vehicle"
parent="data"
sequence="40"
groups="group_fsm_vehicle"/>

<!-- Reporting Menu -->
<menuitem id="menu_fsm_report_order"
name="Orders"
Expand Down

0 comments on commit 81ee319

Please sign in to comment.