Skip to content
Permalink
Browse files

⬆️1️⃣2️⃣ project_timelog

  • Loading branch information...
GabbasovDinar committed May 21, 2019
1 parent c663e73 commit f5e9ca71b5914b3eff3efc1d39854df9be87ffaf
@@ -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,7 +14,7 @@

"depends": [
"hr_timesheet",
"base_action_rule",
"base_automation",
],
"external_dependencies": {"python": [], "bin": []},
"data": [
@@ -23,9 +23,9 @@
"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": [
],
@@ -1,6 +1,6 @@
import datetime
from openerp import http
from openerp.http import request
from odoo import http
from odoo.http import request


class TimelogController(http.Controller):
@@ -33,16 +33,14 @@ def init_timelog(self, **kwargs):
# 1. get common time of current work (current day)
log_timer = 0
if timelogs and timelogs[0].start_datetime is not False:
date_object = datetime.datetime.strptime(timelogs[0].start_datetime, "%Y-%m-%d %H:%M:%S")
if date_object.day == datetime.datetime.now().day:
if timelogs[0].start_datetime.day == datetime.datetime.now().day:
log_timer = int(round(subtask.unit_amount * 3600, 0))

timer_status = False
if timelogs and timelogs[-1].end_datetime is False:
timer_status = True
start_datetime = datetime.datetime.strptime(timelogs[-1].start_datetime, "%Y-%m-%d %H:%M:%S")
end_datetime = datetime.datetime.now()
current_time = (end_datetime - start_datetime).total_seconds()
current_time = (end_datetime - timelogs[-1].start_datetime).total_seconds()
log_timer = int(round(current_time, 0)) + log_timer

# 2. All time in current task for current user
@@ -79,15 +77,13 @@ 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")
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))

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 = []
@@ -128,19 +124,17 @@ def init_timelog(self, **kwargs):

timer_stopline = False
if task.datetime_stopline:
stopline_date = datetime.datetime.strptime(task.datetime_stopline, "%Y-%m-%d %H:%M:%S")
if stopline_date <= datetime.datetime.today():
if task.datetime_stopline <= datetime.datetime.today():
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:
end_datetime_status = False

This file was deleted.

@@ -1,63 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<odoo>
<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>
</odoo>

0 comments on commit f5e9ca7

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