-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd6a8dc
commit bf6d3b6
Showing
9 changed files
with
435 additions
and
1 deletion.
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
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
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 @@ | ||
# Copyright 2024 OpenSynergy Indonesia | ||
# Copyright 2024 PT. Simetri Sinergi Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import ( | ||
fleet_work_order_analysis, | ||
) |
115 changes: 115 additions & 0 deletions
115
ssi_fleet_work_order/reports/fleet_work_order_analysis.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,115 @@ | ||
# Copyright 2024 OpenSynergy Indonesia | ||
# Copyright 2024 PT. Simetri Sinergi Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class FleetWorkOrderAnalysis(models.Model): | ||
_name = "fleet_work_order_analysis" | ||
_description = "Fleet Work Order Analysis" | ||
_order = "vehicle_id, driver_id" | ||
_auto = False | ||
_rec_name = "vehicle_id" | ||
|
||
type_id = fields.Many2one( | ||
string="Type", | ||
comodel_name="fleet_work_order_type", | ||
) | ||
vehicle_id = fields.Many2one( | ||
string="Vehicle", | ||
comodel_name="fleet.vehicle", | ||
) | ||
driver_id = fields.Many2one( | ||
string="Driver", | ||
comodel_name="res.partner", | ||
) | ||
co_driver_id = fields.Many2one( | ||
string="Co-Driver", | ||
comodel_name="res.partner", | ||
) | ||
date_start = fields.Datetime( | ||
string="ETD", | ||
) | ||
date_end = fields.Datetime( | ||
string="ETA", | ||
) | ||
real_date_depart = fields.Datetime( | ||
string="RTD", | ||
) | ||
real_date_arrive = fields.Datetime( | ||
string="RTA", | ||
) | ||
odometer = fields.Float( | ||
string="Odoometer", | ||
) | ||
state = fields.Selection( | ||
string="State", | ||
selection=[ | ||
("draft", "Draft"), | ||
("confirm", "Waiting for Approval"), | ||
("reject", "Rejected"), | ||
("ready", "Ready to Start"), | ||
("open", "On Progress"), | ||
("done", "Done"), | ||
("cancel", "Cancelled"), | ||
], | ||
) | ||
|
||
@property | ||
def _table_query(self): | ||
return "%s %s %s %s" % ( | ||
self._select(), | ||
self._from(), | ||
self._where(), | ||
self._group_by(), | ||
) | ||
|
||
@api.model | ||
def _select(self): | ||
select_str = """ | ||
SELECT | ||
row_number() OVER() as id, | ||
w.type_id AS type_id, | ||
w.vehicle_id AS vehicle_id, | ||
w.driver_id AS driver_id, | ||
w.co_driver_id AS co_driver_id, | ||
w.date_start AS date_start, | ||
w.date_end AS date_end, | ||
w.real_date_depart AS real_date_depart, | ||
w.real_date_arrive AS real_date_arrive, | ||
w.state AS state, | ||
SUM(w.end_odometer - w.start_odometer) AS odometer | ||
""" | ||
return select_str | ||
|
||
@api.model | ||
def _from(self): | ||
from_str = """ | ||
FROM | ||
fleet_work_order AS w | ||
""" | ||
return from_str | ||
|
||
@api.model | ||
def _where(self): | ||
where_str = """ | ||
""" | ||
return where_str | ||
|
||
@api.model | ||
def _group_by(self): | ||
group_by_str = """ | ||
GROUP BY | ||
w.type_id, | ||
w.vehicle_id, | ||
w.driver_id, | ||
w.co_driver_id, | ||
w.date_start, | ||
w.date_end, | ||
w.real_date_depart, | ||
w.real_date_arrive, | ||
w.state | ||
""" | ||
return group_by_str |
210 changes: 210 additions & 0 deletions
210
ssi_fleet_work_order/reports/fleet_work_order_analysis.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,210 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2024 OpenSynergy Indonesia | ||
Copyright 2024 PT. Simetri Sinergi Indonesia | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
|
||
<record id="view_fleet_work_order_analysis_pivot" model="ir.ui.view"> | ||
<field name="name">fleet_work_order_analysis.pivot</field> | ||
<field name="model">fleet_work_order_analysis</field> | ||
<field name="arch" type="xml"> | ||
<pivot | ||
string="Fleet Work Order Analysis" | ||
display_quantity="true" | ||
disable_linking="True" | ||
sample="1" | ||
> | ||
<field name="odometer" type="measure" /> | ||
</pivot> | ||
</field> | ||
</record> | ||
|
||
<record id="view_fleet_work_order_analysis_graph" model="ir.ui.view"> | ||
<field name="name">fleet_work_order_analysis.graph</field> | ||
<field name="model">fleet_work_order_analysis</field> | ||
<field name="arch" type="xml"> | ||
<graph | ||
string="Fleet Work Order Analysis" | ||
type="bar" | ||
sample="1" | ||
disable_linking="1" | ||
> | ||
<field name="odometer" type="measure" /> | ||
</graph> | ||
</field> | ||
</record> | ||
|
||
<record id="view_fleet_work_order_analysis_search" model="ir.ui.view"> | ||
<field name="name">fleet_work_order_analysis.search</field> | ||
<field name="model">fleet_work_order_analysis</field> | ||
<field name="arch" type="xml"> | ||
<search string="Fleet Work Order Analysis"> | ||
<field name="type_id" /> | ||
<field name="vehicle_id" /> | ||
<field name="driver_id" /> | ||
<field name="co_driver_id" /> | ||
<field name="date_start" /> | ||
<field name="date_end" /> | ||
<field name="real_date_depart" /> | ||
<field name="real_date_arrive" /> | ||
<field name="odometer" /> | ||
<field name="state" /> | ||
<separator /> | ||
<filter name="filter_empty" string="Empty" domain="[('id','=',0)]" /> | ||
<group expand="1" string="Group By"> | ||
<group name="row_group" string="Row Grouping"> | ||
<filter | ||
name="row_group_type" | ||
string="Type" | ||
context="{'group_by':'type_id'}" | ||
/> | ||
<filter | ||
name="row_group_vehicle" | ||
string="Vehicle" | ||
context="{'group_by':'vehicle_id'}" | ||
/> | ||
<filter | ||
name="row_group_driver" | ||
string="Driver" | ||
context="{'group_by':'driver_id'}" | ||
/> | ||
<filter | ||
name="row_group_codriver" | ||
string="Co-Driver" | ||
context="{'group_by':'co_driver_id'}" | ||
/> | ||
<filter | ||
name="row_group_state" | ||
string="State" | ||
context="{'group_by':'state'}" | ||
/> | ||
<filter | ||
name="row_group_eta_year" | ||
string="ETA by Year" | ||
context="{'group_by':'date_start:year'}" | ||
/> | ||
<filter | ||
name="row_group_eta_month" | ||
string="ETA by Month" | ||
context="{'group_by':'date_start:month'}" | ||
/> | ||
<filter | ||
name="row_group_eta_week" | ||
string="ETA by Week" | ||
context="{'group_by':'date_start:week'}" | ||
/> | ||
<filter | ||
name="row_group_eta_day" | ||
string="ETA by Day" | ||
context="{'group_by':'date_start:day'}" | ||
/> | ||
<filter | ||
name="row_group_etd_year" | ||
string="ETD by Year" | ||
context="{'group_by':'date_end:year'}" | ||
/> | ||
<filter | ||
name="row_group_etd_month" | ||
string="ETD by Month" | ||
context="{'group_by':'date_end:month'}" | ||
/> | ||
<filter | ||
name="row_group_etd_week" | ||
string="ETD by Week" | ||
context="{'group_by':'date_end:week'}" | ||
/> | ||
<filter | ||
name="row_group_etd_day" | ||
string="ETD by Day" | ||
context="{'group_by':'date_end:day'}" | ||
/> | ||
</group> | ||
<group name="col_group" string="Col Grouping"> | ||
<filter | ||
name="col_group_type" | ||
string="Type" | ||
context="{'col_group_by':'type_id'}" | ||
/> | ||
<filter | ||
name="col_group_vehicle" | ||
string="Vehicle" | ||
context="{'col_group_by':'vehicle_id'}" | ||
/> | ||
<filter | ||
name="col_group_driver" | ||
string="Driver" | ||
context="{'col_group_by':'driver_id'}" | ||
/> | ||
<filter | ||
name="col_group_codriver" | ||
string="Co-Driver" | ||
context="{'col_group_by':'co_driver_id'}" | ||
/> | ||
<filter | ||
name="col_group_state" | ||
string="State" | ||
context="{'col_group_by':'state'}" | ||
/> | ||
<filter | ||
name="col_group_eta_year" | ||
string="ETA by Year" | ||
context="{'col_group_by':'date_start:year'}" | ||
/> | ||
<filter | ||
name="col_group_eta_month" | ||
string="ETA by Month" | ||
context="{'col_group_by':'date_start:month'}" | ||
/> | ||
<filter | ||
name="col_group_eta_week" | ||
string="ETA by Week" | ||
context="{'col_group_by':'date_start:week'}" | ||
/> | ||
<filter | ||
name="col_group_eta_day" | ||
string="ETA by Day" | ||
context="{'col_group_by':'date_start:day'}" | ||
/> | ||
<filter | ||
name="col_group_etd_year" | ||
string="ETD by Year" | ||
context="{'col_group_by':'date_end:year'}" | ||
/> | ||
<filter | ||
name="col_group_etd_month" | ||
string="ETD by Month" | ||
context="{'col_group_by':'date_end:month'}" | ||
/> | ||
<filter | ||
name="col_group_etd_week" | ||
string="ETD by Week" | ||
context="{'col_group_by':'date_end:week'}" | ||
/> | ||
<filter | ||
name="col_group_etd_day" | ||
string="ETD by Day" | ||
context="{'col_group_by':'date_end:day'}" | ||
/> | ||
</group> | ||
</group> | ||
</search> | ||
</field> | ||
</record> | ||
|
||
<record id="action_fleet_work_order_analysis" model="ir.actions.act_window"> | ||
<field name="name">Fleet Work Order Analysis</field> | ||
<field name="res_model">fleet_work_order_analysis</field> | ||
<field name="view_mode">pivot,graph</field> | ||
<field name="search_view_id" ref="view_fleet_work_order_analysis_search" /> | ||
<field name="context">{"search_default_filter_empty": True}</field> | ||
</record> | ||
|
||
<menuitem | ||
id="menu_fleet_work_order_analysis" | ||
parent="ssi_timesheet.reporting_menu" | ||
action="action_fleet_work_order_analysis" | ||
sequence="10" | ||
groups="fleet_work_order_analysis_group" | ||
/> | ||
|
||
</odoo> |
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
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
Oops, something went wrong.