Skip to content
Permalink
Browse files

Merge branch '12.0' into 12.0-web_debranding-docs

  • Loading branch information...
Mirgalimova committed Aug 1, 2019
2 parents 41a951d + c38099e commit f7d7911e09e9087e3f2ca322e0eb9c56e59b0ea9
@@ -27,7 +27,7 @@ env:

matrix:
- LINT_CHECK="1"
- TESTS="1" ODOO_REPO="odoo/odoo"
- TESTS="1" ODOO_REPO="odoo/odoo" MAKEPOT="1"
- TESTS="1" ODOO_REPO="OCA/OCB"

install:
@@ -44,3 +44,7 @@ after_success:

notifications:
email: false
webhooks:
on_failure: change
urls:
- "https://ci.it-projects.info/travis/on_failure/change"
@@ -0,0 +1,61 @@
From dd3337079ddf96b6ae9ab7545ed5f2af1422d834 Mon Sep 17 00:00:00 2001
From: GabbasovDinar <gabbasov@it-projects.info>
Date: Thu, 21 Jun 2018 14:22:54 +0500
Subject: [PATCH] [IMP] support grouping by weeks starting with Sunday

---
odoo/models.py | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/odoo/models.py b/odoo/models.py
index d04e664..f85ba18 100644
--- a/odoo/models.py
+++ b/odoo/models.py
@@ -1794,6 +1794,7 @@ class BaseModel(object):
# Cfr: http://babel.pocoo.org/docs/dates/#date-fields
'day': 'dd MMM yyyy', # yyyy = normal year
'week': "'W'w YYYY", # w YYYY = ISO week-year
+ 'week_sunday': "'W'w'(s)' YYYY", # w YYYY = ISO week-year
'month': 'MMMM yyyy',
'quarter': 'QQQ yyyy',
'year': 'yyyy',
@@ -1801,13 +1802,24 @@ class BaseModel(object):
time_intervals = {
'day': dateutil.relativedelta.relativedelta(days=1),
'week': datetime.timedelta(days=7),
+ 'week_sunday': datetime.timedelta(days=7),
'month': dateutil.relativedelta.relativedelta(months=1),
'quarter': dateutil.relativedelta.relativedelta(months=3),
'year': dateutil.relativedelta.relativedelta(years=1)
}
if tz_convert:
qualified_field = "timezone('%s', timezone('UTC',%s))" % (self._context.get('tz', 'UTC'), qualified_field)
- qualified_field = "date_trunc('%s', %s)" % (gb_function or 'month', qualified_field)
+ if gb_function == 'week_sunday':
+ # postgres's date_trunc supports only weeks starting with Monday
+ # So, make this hack to support weeks starting with Sunday
+ if field_type == 'date':
+ # interger must be used to don't convert DATE to TIMESTAMP
+ interval_day = "integer '1'"
+ else:
+ interval_day = "interval '1 day'"
+ qualified_field = "date_trunc('week', %s + %s)" % (qualified_field, interval_day)
+ else:
+ qualified_field = "date_trunc('%s', %s)" % (gb_function or 'month', qualified_field)
if field_type == 'boolean':
qualified_field = "coalesce(%s,false)" % qualified_field
return {
@@ -1861,6 +1873,10 @@ class BaseModel(object):
if ftype == 'many2one':
value = value[0]
elif ftype in ('date', 'datetime'):
+ if ':week_sunday' in gb['groupby']:
+ # postgres's date_trunc supports only weeks starting with Monday
+ # So, make this hack to support weeks starting with Sunday
+ value -= dateutil.relativedelta.relativedelta(days=1)
locale = self._context.get('lang') or 'en_US'
fmt = DEFAULT_SERVER_DATETIME_FORMAT if ftype == 'datetime' else DEFAULT_SERVER_DATE_FORMAT
tzinfo = None
--
1.9.1

@@ -1,3 +1,7 @@
.. image:: https://img.shields.io/badge/license-LGPL--3-blue.png
:target: https://www.gnu.org/licenses/lgpl
:alt: License: LGPL-3

==============
Time Tracker
==============
@@ -15,21 +19,36 @@ Credits

Contributors
------------
* Dinar Gabbasov <gabbasov@it-projects.info>
* `Dinar Gabbasov <https://it-projects.info/team/GabbasovDinar>`__
* `Eugene Molotov <https://it-projects.info/team/molotov>`__

Sponsors
--------
* `IT-Projects LLC <https://it-projects.info>`_
* `IT-Projects LLC <https://it-projects.info>`__

Maintainers
-----------
* `IT-Projects LLC <https://it-projects.info>`__

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

Thank you for understanding!

`IT-Projects Team <https://www.it-projects.info/team>`__

Further information
===================

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

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

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

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

Tested on Odoo 8.0 6a1ecef7759dd72d30d23fe1c55966e1a97bac01
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 12.0 530f364547af1cc4ccfa9baa66cd70e564bc62cb
@@ -3,19 +3,18 @@
"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": "9.0.1.0.0",
"version": "12.0.1.0.0",
"application": False,

"author": "IT-Projects LLC, Dinar Gabbasov",
"website": "https://twitter.com/gabbasov_dinar",
"author": "IT-Projects LLC",
"website": "https://www.it-projects.info/",
"license": "LGPL-3",
"price": 390.00,
"currency": "EUR",

"depends": [
"project_issue_sheet",
"base_action_rule",
"bus",
"hr_timesheet",
"base_automation",
],
"external_dependencies": {"python": [], "bin": []},
"data": [
@@ -24,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": [
],
@@ -36,5 +35,5 @@
"post_init_hook": None,

"auto_install": False,
"installable": False,
"installable": True,
}
@@ -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
@@ -73,12 +71,20 @@ def init_timelog(self, **kwargs):
if timer_status:
day_timer = day_timer + current_time

config = request.env["ir.config_parameter"]

# 4. All time this week
week_timer = 0
today = datetime.datetime.today()
monday = today - datetime.timedelta(datetime.datetime.weekday(today))
sunday = today + datetime.timedelta(6 - datetime.datetime.weekday(today))
timelog_this_week = timelog_obj.search([("user_id", "=", user.id), ("start_datetime", ">=", monday.strftime('%Y-%m-%d 00:00:00')), ("start_datetime", "<=", sunday.strftime('%Y-%m-%d 23:59:59'))])

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 = []
for r in timelog_this_week:
@@ -99,41 +105,36 @@ def init_timelog(self, **kwargs):
if timelogs_other_users:
another_users = []
for u in timelogs_other_users:
another_users.append({
'id': u.user_id.id,
'name': u.user_id.name
})
another_users.append(u.user_id.id)
another_users = list(set(another_users))
for u in another_users:
res = timelog_obj.search([("user_id", "=", u['id']), ("work_id.task_id", "=", task.id)])
for user_id in another_users:
res = timelog_obj.search([("user_id", "=", user_id), ("work_id.task_id", "=", task.id)])
sum_another_timelog = 0
for i in res:
sum_another_timelog = sum_another_timelog + i.corrected_duration
sum_another_timelog = 3600 * sum_another_timelog
sum_another_timelog = datetime.timedelta(seconds=round(sum_another_timelog, 0))
second_timer_info.append(u['name'] + ": " + str(sum_another_timelog) + "\n")
current_user = request.env['res.users'].browse(user_id)
second_timer_info.append(current_user.name + ": " + str(sum_another_timelog) + "\n")

for r in second_timer_info:
desctiption_timer = desctiption_timer + r

config = request.env["ir.config_parameter"]
convert_sec = 3600

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
@@ -164,7 +165,9 @@ def init_timelog(self, **kwargs):
"task_name": task_name,

"timelog_id": last_timelog,
"end_datetime_status": end_datetime_status
"end_datetime_status": end_datetime_status,

"first_weekday": first_weekday,
}

@http.route('/timelog/connection', type='http', auth="public")

This file was deleted.

0 comments on commit f7d7911

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