-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD][8.0] fleet_work_order_multiple_route
- Loading branch information
Showing
16 changed files
with
732 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
=================================== | ||
MULTIPLE ROUTE FOR FLEET WORK ORDER | ||
=================================== | ||
|
||
This module add feature to manage multiple route for fleet work order | ||
|
||
Installation | ||
============ | ||
|
||
To install this module, you need to: | ||
|
||
1. Clone the branch 8.0 of the repository https://github.com/open-synergy/opensynid-fleet | ||
2. Add the path to this repository in your configuration (addons-path) | ||
3. Update the module list | ||
4. Go to menu *Setting -> Modules -> Local Modules* | ||
5. Search For *Fleet Work Order* | ||
6. Install the module | ||
|
||
Configuration | ||
============= | ||
|
||
|
||
Usage | ||
===== | ||
|
||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/open-synergy/opnsynid-fleet/issues>`_. In case of trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smashing it by providing a detailed and welcomed `feedback | ||
<https://github.com/open-synergy/ | ||
opnsynid-fleet/issues/new?body=module:%20 | ||
fleet_work_order_multiple_route%0Aversion:%20 | ||
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Credits | ||
======= | ||
|
||
|
||
Contributors | ||
------------ | ||
|
||
* Andhitia Rama <andhitia.r@gmail.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://opensynergy-indonesia.com/logo.png | ||
:alt: OpenSynergy Indonesia | ||
:target: https://opensynergy-indonesia.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# © # © 2016 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import models, tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Multiple Route on Fleet Work Order", | ||
"version": "8.0.1.0.0", | ||
"category": "Fleet", | ||
"website": "https://opensynergy-indonesia.com/", | ||
"author": "Andhitia Rama, OpenSynergy Indonesia", | ||
"license": "AGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"depends": [ | ||
"fleet_work_order", | ||
], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"views/fleet_route_template_views.xml", | ||
"views/fleet_work_order_views.xml", | ||
"views/fleet_work_order_type_views.xml", | ||
], | ||
"demo": [ | ||
"demo/fleet_route_template_demo.xml", | ||
], | ||
} |
36 changes: 36 additions & 0 deletions
36
fleet_work_order_multiple_route/demo/fleet_route_template_demo.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- © 2016 OpenSynergy Indonesia | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). --> | ||
|
||
<openerp> | ||
<data> | ||
|
||
<record id="route_template_1" model="fleet.route.template"> | ||
<field name="name">Brisbane - Hervey Bay</field> | ||
<field name="start_location_id" ref="fleet_work_order.point3"/> | ||
<field name="end_location_id" ref="fleet_work_order.point4"/> | ||
<field name="distance">297</field> | ||
</record> | ||
|
||
<record id="route_template_2" model="fleet.route.template"> | ||
<field name="name">Hervey Bay - Brisbance</field> | ||
<field name="start_location_id" ref="fleet_work_order.point4"/> | ||
<field name="end_location_id" ref="fleet_work_order.point3"/> | ||
<field name="distance">297</field> | ||
</record> | ||
|
||
<record id="route_template_3" model="fleet.route.template"> | ||
<field name="name">Airlie Beach - Agnes Water</field> | ||
<field name="start_location_id" ref="fleet_work_order.point1"/> | ||
<field name="end_location_id" ref="fleet_work_order.point2"/> | ||
<field name="distance">708</field> | ||
</record> | ||
|
||
<record id="route_template_4" model="fleet.route.template"> | ||
<field name="name">Agnes Water - Airlie Beach</field> | ||
<field name="start_location_id" ref="fleet_work_order.point2"/> | ||
<field name="end_location_id" ref="fleet_work_order.point1"/> | ||
<field name="distance">708</field> | ||
</record> | ||
</data> | ||
</openerp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
# © # © 2016 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import ( | ||
fleet_route_template, fleet_route, | ||
fleet_work_order, fleet_work_order_type_route) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# -*- coding: utf-8 -*- | ||
# © © 2016 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openerp import models, fields, api | ||
|
||
|
||
class FleetRoute(models.Model): | ||
_name = "fleet.route" | ||
_description = "Fleet Route" | ||
_order = "sequence" | ||
|
||
name = fields.Char( | ||
string="Route", | ||
required=True, | ||
) | ||
order_id = fields.Many2one( | ||
string="# Order", | ||
comodel_name="fleet.work.order", | ||
required=True, | ||
) | ||
sequence = fields.Integer( | ||
string="Sequence", | ||
default=5, | ||
) | ||
route_template_id = fields.Many2one( | ||
string="Route Template", | ||
comodel_name="fleet.route.template", | ||
required=False, | ||
) | ||
start_location_id = fields.Many2one( | ||
string="From", | ||
comodel_name="res.partner", | ||
required=True, | ||
) | ||
end_location_id = fields.Many2one( | ||
string="To", | ||
comodel_name="res.partner", | ||
required=True, | ||
) | ||
distance = fields.Float( | ||
string="Distance", | ||
) | ||
|
||
@api.onchange("route_template_id") | ||
def onchange_route_template_id(self): | ||
if self.route_template_id: | ||
route_template = self.route_template_id | ||
self.start_location_id = route_template.start_location_id.id | ||
self.end_location_id = route_template.end_location_id.id | ||
self.distance = route_template.distance | ||
self.name = route_template.name | ||
else: | ||
self.start_location_id = False | ||
self.end_location_id = False | ||
self.distance = 0.0 |
33 changes: 33 additions & 0 deletions
33
fleet_work_order_multiple_route/models/fleet_route_template.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
# © © 2016 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openerp import models, fields | ||
|
||
|
||
class FleetRouteTemplate(models.Model): | ||
_name = "fleet.route.template" | ||
_description = "Fleet's Route Template" | ||
|
||
name = fields.Char( | ||
string="Name", | ||
required=True, | ||
readonly=False, | ||
) | ||
start_location_id = fields.Many2one( | ||
string="From", | ||
comodel_name="res.partner", | ||
required=True, | ||
) | ||
end_location_id = fields.Many2one( | ||
string="To", | ||
comodel_name="res.partner", | ||
required=True, | ||
) | ||
distance = fields.Float( | ||
string="Distance", | ||
) | ||
active = fields.Boolean( | ||
string="Active", | ||
default=True, | ||
) |
99 changes: 99 additions & 0 deletions
99
fleet_work_order_multiple_route/models/fleet_work_order.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# -*- coding: utf-8 -*- | ||
# © © 2016 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openerp import models, fields, api | ||
|
||
|
||
class FleetWorkOrder(models.Model): | ||
_inherit = "fleet.work.order" | ||
|
||
@api.one | ||
@api.depends('multiple_route', 'route_ids') | ||
def _compute_route(self): | ||
if self.multiple_route and len(self.route_ids) > 0: | ||
self.function_start_location_id = self.route_ids[ | ||
0].start_location_id.id | ||
self.function_end_location_id = self.route_ids[ | ||
-1].end_location_id.id | ||
for route in self.route_ids: | ||
self.function_distance += route.distance | ||
else: | ||
self.function_start_location_id = self.start_location_id.id | ||
self.function_end_location_id = self.end_location_id.id | ||
self.function_distance = self.distance | ||
|
||
route_ids = fields.One2many( | ||
string="Routes", | ||
comodel_name="fleet.route", | ||
inverse_name="order_id", | ||
readonly=True, | ||
states={ | ||
'draft': [('readonly', False)], | ||
}, | ||
) | ||
|
||
multiple_route = fields.Boolean( | ||
string='Multiple Routes', | ||
readonly=True, | ||
states={ | ||
'draft': [('readonly', False)], | ||
}, | ||
) | ||
|
||
function_start_location_id = fields.Many2one( | ||
string='Start Location', | ||
comodel_name='res.partner', | ||
compute='_compute_route', | ||
store=True, | ||
readonly=True, | ||
) | ||
|
||
function_end_location_id = fields.Many2one( | ||
string='End Location', | ||
comodel_name='res.partner', | ||
compute='_compute_route', | ||
store=True, | ||
readonly=True, | ||
) | ||
|
||
function_distance = fields.Float( | ||
string='End Location', | ||
compute='_compute_route', | ||
store=True, | ||
readonly=True, | ||
) | ||
|
||
@api.onchange('type_id') | ||
def onchange_type_id(self): | ||
self.vehicle_id = False | ||
self.driver_id = False | ||
self.co_driver_id = False | ||
self.route_ids.unlink() | ||
if self.type_id: | ||
wo_type = self.type_id | ||
self.vehicle_id = wo_type.vehicle_id and \ | ||
wo_type.vehicle_id.id or False | ||
self.driver_id = wo_type.driver_id and \ | ||
wo_type.driver_id.id or False | ||
self.co_driver_id = wo_type.co_driver_id and \ | ||
wo_type.co_driver_id.id or False | ||
self.start_location_id = wo_type.start_location_id and \ | ||
wo_type.start_location_id.id or False | ||
self.end_location_id = wo_type.end_location_id and \ | ||
wo_type.end_location_id.id or False | ||
self.distance = wo_type.distance | ||
self.multiple_route = wo_type.multiple_route | ||
if wo_type.route_ids: | ||
routes = [] | ||
for route in wo_type.route_ids: | ||
res = { | ||
'name': route.name, | ||
'sequence': route.sequence, | ||
'route_template_id': route.route_template_id.id, | ||
'start_location_id': route.start_location_id.id, | ||
'end_location_id': route.end_location_id.id, | ||
'distance': route.distance, | ||
} | ||
routes.append((0, 0, res)) | ||
self.route_ids = routes |
Oops, something went wrong.