Skip to content
Permalink
Browse files

⬆️1️⃣2️⃣ project_timelog

  • Loading branch information...
GabbasovDinar committed May 21, 2019
1 parent c663e73 commit 229f3aeca76465044880cc7ca8256bffe25ee564
@@ -31,7 +31,7 @@ Maintainers

To get a guaranteed support
you are kindly requested to purchase the module
at `odoo apps store <https://apps.odoo.com/apps/modules/10.0/project_timelog/>`__.
at `odoo apps store <https://apps.odoo.com/apps/modules/12.0/project_timelog/>`__.

Thank you for understanding!

@@ -40,14 +40,14 @@ Maintainers
Further information
===================

Demo: http://runbot.it-projects.info/demo/misc-addons/10.0
Demo: http://runbot.it-projects.info/demo/misc-addons/12.0

HTML Description: https://apps.odoo.com/apps/modules/10.0/project_timelog/
HTML Description: https://apps.odoo.com/apps/modules/12.0/project_timelog/

Usage instructions: `<doc/index.rst>`_

Changelog: `<doc/changelog.rst>`_

Notifications on updates: `via Atom <https://github.com/it-projects-llc/misc-addons/commits/10.0/project_timelog.atom>`_, `by Email <https://blogtrottr.com/?subscribe=https://github.com/it-projects-llc/misc-addons/commits/10.0/project_timelog.atom>`_
Notifications on updates: `via Atom <https://github.com/it-projects-llc/misc-addons/commits/12.0/project_timelog.atom>`_, `by Email <https://blogtrottr.com/?subscribe=https://github.com/it-projects-llc/misc-addons/commits/12.0/project_timelog.atom>`_

Tested on Odoo 10.0 d89f4d6ec26806389922351eb8e575754b3f60e0
Tested on Odoo 12.0 530f364547af1cc4ccfa9baa66cd70e564bc62cb
@@ -3,7 +3,7 @@
"summary": """Adds Start/Stop buttons to task work lines. Allows to see statistics on Calendar, Graph, Tree views and more""",
"category": "Project",
"images": ["images/timelog.png"],
"version": "10.0.1.0.0",
"version": "12.0.1.0.0",
"application": False,

"author": "IT-Projects LLC, Dinar Gabbasov",
@@ -14,18 +14,18 @@

"depends": [
"hr_timesheet",
"base_action_rule",
"base_automation",
],
"external_dependencies": {"python": [], "bin": []},
"data": [
"security/ir.model.access.csv",
"views/project_timelog_views.xml",
"views/res_config_view.xml",
# "views/project_timelog_views.xml",
# "views/res_config_view.xml",
"views/project_timelog_templates.xml",
"data/project_timelog_data.xml",
"data/pre_install.yml",
],
"qweb": [
"static/src/xml/menu.xml",
],
"demo": [
],
@@ -79,15 +79,15 @@ def init_timelog(self, **kwargs):
week_timer = 0
today = datetime.datetime.today()

first_weekday = config.get_param("project_timelog.first_weekday")

first_weekday = config.sudo().get_param("project_timelog.first_weekday")
print ("========================", first_weekday)
if first_weekday == 'monday':
first_day_of_week = today - datetime.timedelta(datetime.datetime.weekday(today))
last_day_of_week = today + datetime.timedelta(6 - datetime.datetime.weekday(today))
elif first_weekday == 'sunday':
first_day_of_week = today - datetime.timedelta(1 + datetime.datetime.weekday(today))
last_day_of_week = today + datetime.timedelta(5 - datetime.datetime.weekday(today))

print("===============", first_day_of_week)
timelog_this_week = timelog_obj.search([("user_id", "=", user.id), ("start_datetime", ">=", first_day_of_week.strftime('%Y-%m-%d 00:00:00')), ("start_datetime", "<=", last_day_of_week.strftime('%Y-%m-%d 23:59:59'))])
if timelog_this_week:
week_work_ids = []
@@ -133,13 +133,13 @@ def init_timelog(self, **kwargs):
timer_stopline = True

# get configs for timer
time_subtasks = int(round(float(config.get_param("project_timelog.time_subtasks"))*convert_sec, 0))
time_subtasks = int(round(float(config.sudo().get_param("project_timelog.time_subtasks"))*convert_sec, 0))
time_warning_subtasks = time_subtasks - int(
round(float(config.get_param("project_timelog.time_warning_subtasks")) * convert_sec, 0))
normal_time_day = int(round(float(config.get_param("project_timelog.normal_time_day")) * convert_sec, 0))
good_time_day = int(round(float(config.get_param("project_timelog.good_time_day")) * convert_sec, 0))
normal_time_week = int(round(float(config.get_param("project_timelog.normal_time_week")) * convert_sec, 0))
good_time_week = int(round(float(config.get_param("project_timelog.good_time_week")) * convert_sec, 0))
round(float(config.sudo().get_param("project_timelog.time_warning_subtasks")) * convert_sec, 0))
normal_time_day = int(round(float(config.sudo().get_param("project_timelog.normal_time_day")) * convert_sec, 0))
good_time_day = int(round(float(config.sudo().get_param("project_timelog.good_time_day")) * convert_sec, 0))
normal_time_week = int(round(float(config.sudo().get_param("project_timelog.normal_time_week")) * convert_sec, 0))
good_time_week = int(round(float(config.sudo().get_param("project_timelog.good_time_week")) * convert_sec, 0))

end_datetime_status = True
if timelogs and timelogs[-1].end_datetime is False:

This file was deleted.

@@ -1,63 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<data noupdate="0">
<!--<data>-->
<!--if user offline then timer will stop-->
<record id="ir_cron_check_stop_timer" model="ir.cron">
<field name="name">Offline stop timer</field>
<field name="active" eval="True" />
<field name="user_id" ref="base.user_root" />
<field name="interval_number">5</field>
<field name="interval_type">minutes</field>
<field name="model_id" ref="model_res_users"/>
<field name="state">code</field>
<field name="code">model.check_stop_timer()</field>
<field name="user_id" ref="base.user_root"/>
<field name='interval_number'>5</field>
<field name='interval_type'>minutes</field>
<field name="numbercall">-1</field>
<field name="model" eval="'res.users'" />
<field name="function" eval="'check_stop_timer'" />
<field name="args" eval="" />
<field name="priority" eval="4" />
</record>

<!--new status for yesterday's timelogs-->
<record id="ir_cron_nonactive_new_timer_status" model="ir.cron">
<field name="name">Nonactive new status</field>
<field name="active" eval="True" />
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="model_id" ref="model_account_analytic_line"/>
<field name="state">code</field>
<field name="code">model.subtask_new_status()</field>
<field name="user_id" ref="base.user_root"/>
<field name='interval_number'>1</field>
<field name='interval_type'>days</field>
<field name="numbercall">-1</field>
<field name="nextcall" eval="(DateTime.now() + timedelta(days=1)).strftime('%Y-%m-%d 00:00:00')" />
<field name="model" eval="'account.analytic.line'" />
<field name="function" eval="'subtask_new_status'" />
<field name="args" eval="" />
<field name="priority" eval="5" />
</record>

<!--clear stopline for yesterday's date-->
<record id="ir_cron_clear_stopline_datetime" model="ir.cron">
<field name="name">Clear stopline datetime</field>
<field name="active" eval="True" />
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="model_id" ref="model_project_task"/>
<field name="state">code</field>
<field name="code">model.clear_stopline_datetime()</field>
<field name="user_id" ref="base.user_root"/>
<field name='interval_number'>1</field>
<field name='interval_type'>days</field>
<field name="numbercall">-1</field>
<field name="nextcall" eval="(DateTime.now() + timedelta(days=1)).strftime('%Y-%m-%d 00:00:00')" />
<field name="model" eval="'project.task'" />
<field name="function" eval="'clear_stopline_datetime'" />
<field name="args" eval="" />
<field name="priority" eval="5" />
</record>

<!--if stopline is not false. If date/time in stopline is current date/time then timer will stop-->
<record id="ir_cron_stopline" model="ir.cron">
<field name="name">Stopline</field>
<field name="active" eval="True" />
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">minutes</field>
<field name="model_id" ref="model_project_task"/>
<field name="state">code</field>
<field name="code">model.stopline_timer()</field>
<field name="user_id" ref="base.user_root"/>
<field name='interval_number'>1</field>
<field name='interval_type'>minutes</field>
<field name="numbercall">-1</field>
<field name="model">project.task</field>
<field name="function">stopline_timer</field>
<field name="args">()</field>
<field name="priority" eval="4" />
<field name="nextcall" eval="(DateTime.now() + timedelta(days=1)).strftime('%Y-%m-%d 00:00:00')" />
</record>

<record id="mt_timelog_stopline" model="mail.message.subtype">
@@ -75,24 +72,18 @@
<field name="relation_field">project_id</field>
</record>

<record id="action_auto_stop_timer" model="ir.actions.server">
<field name="name">Auto stop timer for user</field>
<field name="condition">True</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="model_project_task"/>
<record id="rule_auto_stop_timer" model="base.automation">
<field name="name">Set timer info</field>
<field name="model_id" ref="project_timelog.model_project_task"/>
<field name="state">code</field>
<field name="code">
obj.set_stage_timer()
record.set_stage_timer()
</field>
<field name="trigger">on_write</field>
<field name="active" eval="True"/>
</record>

<record id="rule_auto_stop_timer" model="base.action.rule">
<field name="name">Set timer info</field>
<field eval="True" name="active" />
<field name="model_id" ref="model_project_task"/>
<field name="kind">on_write</field>
<field name="server_action_ids"
eval="[(4, ref('action_auto_stop_timer'))]"/>
</record>
<function model="timelog.config.settings" name="init_timer_parametrs"/>

</data>
</openerp>
@@ -211,7 +211,7 @@ def check_stop_timer(self):
for r in status:
r.active_work_id.sudo(r).stop_timer(play_a_sound=False)
user = self.search([("active_work_id.status", "=", "play")])
time_subtask = int(round(float(self.env["ir.config_parameter"].get_param('project_timelog.time_subtasks'))*3600, 0))
time_subtask = int(round(float(self.env["ir.config_parameter"].sudo().get_param('project_timelog.time_subtasks'))*3600, 0))
for u in user:
all_timelog = u.active_work_id.timelog_ids
sum_time = datetime.timedelta(0)
@@ -325,7 +325,7 @@ def play_timer(self):
message=_("Unable to create logs until it is modified or deleted stopline."))
stage = project_task.stage_id.id
corrected_duration = self.env["project.timelog"].search([("work_id", "=", self.id), ("user_id", "=", self.env.user.id)])
config = self.env["ir.config_parameter"].get_param("project_timelog.time_subtasks")
config = self.env["ir.config_parameter"].sudo().get_param("project_timelog.time_subtasks")

sum_timelog = 0.0
if corrected_duration and config:
@@ -20,34 +20,35 @@ def set_custom_parameters(self):
self.ensure_one()
config_parameters = self.env['ir.config_parameter']
for record in self:
config_parameters.set_param(key="project_timelog.time_subtasks", value=record.time_subtasks)
config_parameters.set_param(key="project_timelog.time_warning_subtasks", value=record.time_warning_subtasks)
config_parameters.set_param(key="project_timelog.normal_time_day", value=record.normal_time_day)
config_parameters.set_param(key="project_timelog.good_time_day", value=record.good_time_day)
config_parameters.set_param(key="project_timelog.normal_time_week", value=record.normal_time_week)
config_parameters.set_param(key="project_timelog.good_time_week", value=record.good_time_week)
config_parameters.set_param(key="project_timelog.first_weekday", value=record.first_weekday)
config_parameters.sudo().set_param(key="project_timelog.time_subtasks", value=record.time_subtasks)
config_parameters.sudo().set_param(key="project_timelog.time_warning_subtasks", value=record.time_warning_subtasks)
config_parameters.sudo().set_param(key="project_timelog.normal_time_day", value=record.normal_time_day)
config_parameters.sudo().set_param(key="project_timelog.good_time_day", value=record.good_time_day)
config_parameters.sudo().set_param(key="project_timelog.normal_time_week", value=record.normal_time_week)
config_parameters.sudo().set_param(key="project_timelog.good_time_week", value=record.good_time_week)
config_parameters.sudo().set_param(key="project_timelog.first_weekday", value=record.first_weekday)

@api.multi
def get_default_custom_parameters(self, fields=None):
icp = self.env['ir.config_parameter']
return {
'time_subtasks': icp.get_param('project_timelog.time_subtasks'),
'time_warning_subtasks': icp.get_param('project_timelog.time_warning_subtasks'),
'normal_time_day': icp.get_param('project_timelog.normal_time_day'),
'good_time_day': icp.get_param('project_timelog.good_time_day'),
'normal_time_week': icp.get_param('project_timelog.normal_time_week'),
'good_time_week': icp.get_param('project_timelog.good_time_week'),
'first_weekday': icp.get_param('project_timelog.first_weekday'),
'time_subtasks': icp.sudo().get_param('project_timelog.time_subtasks'),
'time_warning_subtasks': icp.sudo().get_param('project_timelog.time_warning_subtasks'),
'normal_time_day': icp.sudo().get_param('project_timelog.normal_time_day'),
'good_time_day': icp.sudo().get_param('project_timelog.good_time_day'),
'normal_time_week': icp.sudo().get_param('project_timelog.normal_time_week'),
'good_time_week': icp.sudo().get_param('project_timelog.good_time_week'),
'first_weekday': icp.sudo().get_param('project_timelog.first_weekday'),
}

@api.model
def init_timer_parametrs(self):
print("============================ init_timer_parametrs")
icp = self.env["ir.config_parameter"]
icp.set_param(key="project_timelog.time_subtasks", value=2)
icp.set_param(key="project_timelog.time_warning_subtasks", value=0.33)
icp.set_param(key="project_timelog.normal_time_day", value=5)
icp.set_param(key="project_timelog.good_time_day", value=6)
icp.set_param(key="project_timelog.normal_time_week", value=30)
icp.set_param(key="project_timelog.good_time_week", value=40)
icp.set_param(key="project_timelog.first_weekday", value='monday')
icp.sudo().set_param(key="project_timelog.time_subtasks", value=2)
icp.sudo().set_param(key="project_timelog.time_warning_subtasks", value=0.33)
icp.sudo().set_param(key="project_timelog.normal_time_day", value=5)
icp.sudo().set_param(key="project_timelog.good_time_day", value=6)
icp.sudo().set_param(key="project_timelog.normal_time_week", value=30)
icp.sudo().set_param(key="project_timelog.good_time_week", value=40)
icp.sudo().set_param(key="project_timelog.first_weekday", value='monday')
@@ -219,7 +219,7 @@ <h2>Need our service?</h2>
-o-transform: rotate(12deg);
-moz-transform: rotate(12deg);
-ms-transform: rotate(12deg);">
Tested on Odoo<br/>10.0 community
Tested on Odoo<br/>12.0 community
</div>
</div>
</div>

0 comments on commit 229f3ae

Please sign in to comment.
You can’t perform that action at this time.