Skip to content

Commit 66c6a21

Browse files
authored
Merge pull request #1 from solvosci/12.0-add-maintenance_request_time_performance
[12.0][ADD] maintenance_request_time_performance
2 parents 787400d + aadbd14 commit 66c6a21

12 files changed

Lines changed: 644 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .hooks import post_init_hook
2+
from . import models
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# © 2020 Solvos Consultoría Informática (<http://www.solvos.es>)
2+
# License LGPL-3 - See http://www.gnu.org/licenses/lgpl-3.0.html
3+
{
4+
"name": "Maintenance Request time performance",
5+
"summary": """
6+
Adds start and end date and time of maintenance request completion.
7+
Adds the difference between real and theoretical completion time.
8+
""",
9+
"author": "Solvos",
10+
"license": "LGPL-3",
11+
"version": "12.0.1.0.0",
12+
"category": "Maintenance",
13+
"website": "https://github.com/solvosci/slv-maintenance",
14+
"depends": [
15+
'maintenance'
16+
],
17+
"data": [
18+
"data/maintenance_data.xml",
19+
"views/maintenance_views.xml",
20+
],
21+
"post_init_hook": "post_init_hook",
22+
'installable': True,
23+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
<data noupdate="1">
4+
<record id="maintenance.stage_1" model="maintenance.stage">
5+
<field name="in_progress" eval="True" />
6+
</record>
7+
</data>
8+
</odoo>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from odoo import _, api, SUPERUSER_ID
2+
from datetime import datetime, timedelta
3+
4+
5+
def post_init_hook(cr, registry):
6+
with api.Environment.manage():
7+
env = api.Environment(cr, SUPERUSER_ID, {})
8+
MaintenanceRequest = env['maintenance.request']
9+
rec_in_progress = MaintenanceRequest.search([
10+
('stage_id.in_progress', '=', True)])
11+
rec_done = MaintenanceRequest.search([
12+
('stage_id.done', '=', True)])
13+
for req in (rec_in_progress | rec_done):
14+
# compute start_request_datetime
15+
start_dt = (req.schedule_date
16+
or (datetime.combine(req.request_date,
17+
req.create_date.time())
18+
if req.request_date else None)
19+
or req.create_date)
20+
if start_dt.hour == 0 \
21+
and start_dt.minute == 0 \
22+
and start_dt.second == 0 \
23+
and req.create_date:
24+
# if has no time we put the create_date time
25+
start_dt = start_dt.replace(
26+
hour=req.create_date.hour,
27+
minute=req.create_date.minute,
28+
second=req.create_date.second)
29+
# compute end_request_datetime
30+
end_dt = None
31+
if req.stage_id.done:
32+
theo_end_dt = (start_dt + timedelta(hours=req.duration)) \
33+
if req.duration else req.write_date
34+
end_dt = datetime.combine(req.close_date,
35+
theo_end_dt.time())\
36+
if req.close_date else theo_end_dt
37+
# End dt cannot be prior to Start dt
38+
if end_dt < start_dt:
39+
end_dt = (start_dt + timedelta(hours=req.duration)) \
40+
if req.duration else start_dt
41+
req.write({
42+
'start_request_datetime': start_dt,
43+
'end_request_datetime': end_dt,
44+
})
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * maintenance_request_time_performance
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 12.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2020-04-19 10:50+0000\n"
10+
"PO-Revision-Date: 2020-04-19 10:50+0000\n"
11+
"Last-Translator: <>\n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: maintenance_request_time_performance
19+
#: model_terms:ir.ui.view,arch_db:maintenance_request_time_performance.hr_equipment_request_view_form
20+
msgid "<span class=\"ml8\">hours</span>"
21+
msgstr "<span class=\"ml8\">horas</span>"
22+
23+
#. module: maintenance_request_time_performance
24+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_request__completion_delay
25+
msgid "Completion Delay"
26+
msgstr "Retardo en la Finalización"
27+
28+
#. module: maintenance_request_time_performance
29+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_request__duration_difference
30+
msgid "Difference Duration"
31+
msgstr "Diferencia de duración"
32+
33+
#. module: maintenance_request_time_performance
34+
#: model_terms:ir.ui.view,arch_db:maintenance_request_time_performance.hr_equipment_request_view_search
35+
msgid "Done Today"
36+
msgstr "Finalizada Hoy"
37+
38+
#. module: maintenance_request_time_performance
39+
#: model:ir.model.fields,help:maintenance_request_time_performance.field_maintenance_request__end_request_datetime
40+
msgid "End Date and time of maintenance request completion"
41+
msgstr "Finalización de petición"
42+
43+
#. module: maintenance_request_time_performance
44+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_request__end_request_date
45+
msgid "End Date of maintenance request completion"
46+
msgstr "Finalización de petición"
47+
48+
#. module: maintenance_request_time_performance
49+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_request__end_request_datetime_required
50+
msgid "End Request Datetime Required"
51+
msgstr "Es obligatoria la Fecha de Finalización de la petición"
52+
53+
#. module: maintenance_request_time_performance
54+
#: code:addons/maintenance_request_time_performance/models/maintenance.py:130
55+
#, python-format
56+
msgid "End task completion cannot be prior to Start task completion"
57+
msgstr "No se puede finalizar una petición antes de comenzarla"
58+
59+
#. module: maintenance_request_time_performance
60+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_request__end_request_datetime
61+
msgid "Finished at"
62+
msgstr "Finalizada en"
63+
64+
#. module: maintenance_request_time_performance
65+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_stage__in_progress
66+
msgid "In Progress"
67+
msgstr "En Proceso"
68+
69+
#. module: maintenance_request_time_performance
70+
#: code:addons/maintenance_request_time_performance/models/maintenance.py:124
71+
#, python-format
72+
msgid "It can´t be End task completion without Start task completion"
73+
msgstr "No se puede Finalizar una petición sin Fecha Arranque"
74+
75+
#. module: maintenance_request_time_performance
76+
#: code:addons/maintenance_request_time_performance/models/maintenance.py:17
77+
#, python-format
78+
msgid "It can´t be in progress and done at the same time"
79+
msgstr "No puede estar en estado En proceso y Hecho al mismo tiempo"
80+
81+
#. module: maintenance_request_time_performance
82+
#: model:ir.model,name:maintenance_request_time_performance.model_maintenance_request
83+
msgid "Maintenance Request"
84+
msgstr "Petición de mantenimiento"
85+
86+
#. module: maintenance_request_time_performance
87+
#: model:ir.model,name:maintenance_request_time_performance.model_maintenance_stage
88+
msgid "Maintenance Stage"
89+
msgstr "Etapa de mantenimiento"
90+
91+
#. module: maintenance_request_time_performance
92+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_request__real_request_duration
93+
msgid "Real Duration"
94+
msgstr "Duración Real"
95+
96+
#. module: maintenance_request_time_performance
97+
#: model:ir.model.fields,help:maintenance_request_time_performance.field_maintenance_request__start_request_datetime
98+
msgid "Start Date and time of maintenance request completion"
99+
msgstr "Arranque petición"
100+
101+
#. module: maintenance_request_time_performance
102+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_request__start_request_date
103+
msgid "Start Date of maintenance request completion"
104+
msgstr "Arranque petición"
105+
106+
#. module: maintenance_request_time_performance
107+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_request__start_request_datetime_required
108+
msgid "Start Request Datetime Required"
109+
msgstr "La Fecha de Arranque de la petición es obligatoria"
110+
111+
#. module: maintenance_request_time_performance
112+
#: model_terms:ir.ui.view,arch_db:maintenance_request_time_performance.hr_equipment_request_view_search
113+
msgid "Started Today"
114+
msgstr "Iniciada Hoy"
115+
116+
#. module: maintenance_request_time_performance
117+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_request__start_request_datetime
118+
msgid "Started at"
119+
msgstr "Iniciada en"
120+
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * maintenance_request_time_performance
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 12.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2020-04-19 10:50+0000\n"
10+
"PO-Revision-Date: 2020-04-19 10:50+0000\n"
11+
"Last-Translator: <>\n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: maintenance_request_time_performance
19+
#: model_terms:ir.ui.view,arch_db:maintenance_request_time_performance.hr_equipment_request_view_form
20+
msgid "<span class=\"ml8\">hours</span>"
21+
msgstr ""
22+
23+
#. module: maintenance_request_time_performance
24+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_request__completion_delay
25+
msgid "Completion Delay"
26+
msgstr ""
27+
28+
#. module: maintenance_request_time_performance
29+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_request__duration_difference
30+
msgid "Difference Duration"
31+
msgstr ""
32+
33+
#. module: maintenance_request_time_performance
34+
#: model_terms:ir.ui.view,arch_db:maintenance_request_time_performance.hr_equipment_request_view_search
35+
msgid "Done Today"
36+
msgstr ""
37+
38+
#. module: maintenance_request_time_performance
39+
#: model:ir.model.fields,help:maintenance_request_time_performance.field_maintenance_request__end_request_datetime
40+
msgid "End Date and time of maintenance request completion"
41+
msgstr ""
42+
43+
#. module: maintenance_request_time_performance
44+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_request__end_request_date
45+
msgid "End Date of maintenance request completion"
46+
msgstr ""
47+
48+
#. module: maintenance_request_time_performance
49+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_request__end_request_datetime_required
50+
msgid "End Request Datetime Required"
51+
msgstr ""
52+
53+
#. module: maintenance_request_time_performance
54+
#: code:addons/maintenance_request_time_performance/models/maintenance.py:130
55+
#, python-format
56+
msgid "End task completion cannot be prior to Start task completion"
57+
msgstr ""
58+
59+
#. module: maintenance_request_time_performance
60+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_request__end_request_datetime
61+
msgid "Finished at"
62+
msgstr ""
63+
64+
#. module: maintenance_request_time_performance
65+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_stage__in_progress
66+
msgid "In Progress"
67+
msgstr ""
68+
69+
#. module: maintenance_request_time_performance
70+
#: code:addons/maintenance_request_time_performance/models/maintenance.py:124
71+
#, python-format
72+
msgid "It can´t be End task completion without Start task completion"
73+
msgstr ""
74+
75+
#. module: maintenance_request_time_performance
76+
#: code:addons/maintenance_request_time_performance/models/maintenance.py:17
77+
#, python-format
78+
msgid "It can´t be in progress and done at the same time"
79+
msgstr ""
80+
81+
#. module: maintenance_request_time_performance
82+
#: model:ir.model,name:maintenance_request_time_performance.model_maintenance_request
83+
msgid "Maintenance Request"
84+
msgstr ""
85+
86+
#. module: maintenance_request_time_performance
87+
#: model:ir.model,name:maintenance_request_time_performance.model_maintenance_stage
88+
msgid "Maintenance Stage"
89+
msgstr ""
90+
91+
#. module: maintenance_request_time_performance
92+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_request__real_request_duration
93+
msgid "Real Duration"
94+
msgstr ""
95+
96+
#. module: maintenance_request_time_performance
97+
#: model:ir.model.fields,help:maintenance_request_time_performance.field_maintenance_request__start_request_datetime
98+
msgid "Start Date and time of maintenance request completion"
99+
msgstr ""
100+
101+
#. module: maintenance_request_time_performance
102+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_request__start_request_date
103+
msgid "Start Date of maintenance request completion"
104+
msgstr ""
105+
106+
#. module: maintenance_request_time_performance
107+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_request__start_request_datetime_required
108+
msgid "Start Request Datetime Required"
109+
msgstr ""
110+
111+
#. module: maintenance_request_time_performance
112+
#: model_terms:ir.ui.view,arch_db:maintenance_request_time_performance.hr_equipment_request_view_search
113+
msgid "Started Today"
114+
msgstr ""
115+
116+
#. module: maintenance_request_time_performance
117+
#: model:ir.model.fields,field_description:maintenance_request_time_performance.field_maintenance_request__start_request_datetime
118+
msgid "Started at"
119+
msgstr ""
120+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
from . import maintenance

0 commit comments

Comments
 (0)