Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8.0_timelog_webhooks_v1
  • Loading branch information
n1nka committed Jul 29, 2019
1 parent 6e75252 commit f1c74d5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
14 changes: 14 additions & 0 deletions project_timelog/README.rst
Expand Up @@ -22,6 +22,20 @@ Sponsors
--------
* `IT-Projects LLC <https://it-projects.info>`_

Script
======

.. code-block:: python
base_url = obj.env['ir.config_parameter'].get_param('web.base.url')
url_task = base_url + '/web#id=%s&' % obj.user_id.id + 'model=project.task'
value1 = url_task
value2 = obj.create_date
value3 = obj.task_name
data = {'value1': value1, 'value2': value2, 'value3': value3}
url_request = 'https://maker.ifttt.com/trigger/%s/with/key/cCTNCS_cSDRVWPdMoYXPPQ' % event
obj.get_requests(url_request, data)
Further information
===================

Expand Down
18 changes: 18 additions & 0 deletions project_timelog/models/project_timelog.py
@@ -1,5 +1,9 @@
# -*- coding: utf-8 -*-
import datetime
import json
import re
import requests
import urllib3
from openerp import models, fields, api
from openerp.exceptions import Warning as UserError
from openerp.tools.translate import _
Expand Down Expand Up @@ -94,6 +98,12 @@ class Task(models.Model):
},
}

def get_requests(self, url_request, data):
res = requests.post(url_request, data)
return res



@api.model
def clear_stopline_datetime(self):
tasks = self.env["project.task"].search(["datetime_stopline", "!=", False])
Expand Down Expand Up @@ -204,6 +214,7 @@ class ProjectWork(models.Model):
related='task_id.project_id.analytic_account_id',
readonly=True)
combined_name = fields.Char('Task and Summary', compute="_compute_combined_name")
create_date = fields.Datetime(string='Creation Date', required=True, default=fields.Datetime.now)

@api.multi
def _compute_combined_name(self):
Expand All @@ -226,6 +237,7 @@ def _compute_hours(self):
return False
sum_timelog = 0.00
timelog = r.env.user.active_work_id.timelog_ids

if not timelog:
return False
if timelog[-1].end_datetime is False:
Expand Down Expand Up @@ -330,6 +342,7 @@ def play_timer(self):

if first_timelog and first_timelog[0].end_datetime is not False:
date_object = datetime.datetime.strptime(first_timelog[0].end_datetime, "%Y-%m-%d %H:%M:%S")

if date_object is not False and date_object.day != current_date.day:
# there are timelogs yesterday
return {
Expand All @@ -343,6 +356,11 @@ def play_timer(self):
}
}

# date_object = datetime.datetime.strptime(first_timelog[0].start_datetime, "%Y-%m-%d %H:%M:%S")
# if date_object.day == current_date.day:
# print('|----------------date_object------------|')
# print(date_object)
# print('|----------------date_object------------|')
self.write({'status': 'play'})

# record data for current user (last active timer)
Expand Down

0 comments on commit f1c74d5

Please sign in to comment.