From 82f780e948444cd9938613e99b3a77f32056f3ba Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Thu, 19 Jan 2012 20:16:54 +0100 Subject: [PATCH 001/526] [REM] unused imports. bzr revid: florent.xicluna@gmail.com-20120119191654-scm8c3o07icyz5b1 --- openerp/osv/fields.py | 3 --- openerp/tests/common.py | 1 - openerp/tests/test_orm.py | 1 - openerp/tiny_socket.py | 1 - 4 files changed, 6 deletions(-) diff --git a/openerp/osv/fields.py b/openerp/osv/fields.py index 871fc32f884..ff02a8c89f9 100644 --- a/openerp/osv/fields.py +++ b/openerp/osv/fields.py @@ -35,14 +35,11 @@ import base64 import datetime as DT import re -import string -import sys import warnings import xmlrpclib from psycopg2 import Binary import openerp -import openerp.netsvc as netsvc import openerp.tools as tools from openerp.tools.translate import _ from openerp.tools import float_round, float_repr diff --git a/openerp/tests/common.py b/openerp/tests/common.py index 44696384ce7..93e5f6d5bc2 100644 --- a/openerp/tests/common.py +++ b/openerp/tests/common.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -import os import time import xmlrpclib diff --git a/openerp/tests/test_orm.py b/openerp/tests/test_orm.py index c11d4cd19d2..cf880933fe5 100644 --- a/openerp/tests/test_orm.py +++ b/openerp/tests/test_orm.py @@ -1,4 +1,3 @@ -import os import unittest2 import openerp diff --git a/openerp/tiny_socket.py b/openerp/tiny_socket.py index b4bed83a4c0..f86797f0f67 100644 --- a/openerp/tiny_socket.py +++ b/openerp/tiny_socket.py @@ -22,7 +22,6 @@ import socket import cPickle import cStringIO -import marshal import netsvc From e7838dfbc44472a444b1f58dd7869febbc5984b7 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Thu, 19 Jan 2012 20:17:56 +0100 Subject: [PATCH 002/526] [REF] fix weird indentation, not multiple of four. bzr revid: florent.xicluna@gmail.com-20120119191756-niny262vp1nvmpp8 --- openerp/netsvc.py | 16 ++++++++-------- openerp/osv/orm.py | 12 ++++++------ openerp/service/netrpc_server.py | 6 +++--- openerp/service/web_services.py | 10 +++++----- openerp/tests/test_xmlrpc.py | 4 ++-- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/openerp/netsvc.py b/openerp/netsvc.py index ca08a362771..53750ed84da 100644 --- a/openerp/netsvc.py +++ b/openerp/netsvc.py @@ -84,12 +84,12 @@ class Service(object): cls._services.pop(name) def LocalService(name): - # Special case for addons support, will be removed in a few days when addons - # are updated to directly use openerp.osv.osv.service. - if name == 'object_proxy': - return openerp.osv.osv.service + # Special case for addons support, will be removed in a few days when addons + # are updated to directly use openerp.osv.osv.service. + if name == 'object_proxy': + return openerp.osv.osv.service - return Service._services[name] + return Service._services[name] class ExportService(object): """ Proxy for exported services. @@ -198,9 +198,9 @@ def init_logger(): # server intended to test it. def init_alternative_logger(): class H(logging.Handler): - def emit(self, record): - if record.levelno > 20: - print record.levelno, record.pathname, record.msg + def emit(self, record): + if record.levelno > 20: + print record.levelno, record.pathname, record.msg handler = H() logger = logging.getLogger() logger.handlers = [] diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 1c12fab27c9..f2686708436 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -98,10 +98,10 @@ def transfer_node_to_modifiers(node, modifiers, context=None, in_tree_view=False if node.get('states'): if 'invisible' in modifiers and isinstance(modifiers['invisible'], list): - # TODO combine with AND or OR, use implicit AND for now. - modifiers['invisible'].append(('state', 'not in', node.get('states').split(','))) + # TODO combine with AND or OR, use implicit AND for now. + modifiers['invisible'].append(('state', 'not in', node.get('states').split(','))) else: - modifiers['invisible'] = [('state', 'not in', node.get('states').split(','))] + modifiers['invisible'] = [('state', 'not in', node.get('states').split(','))] for a in ('invisible', 'readonly', 'required'): if node.get(a): @@ -894,8 +894,8 @@ class BaseModel(object): for c in cls.__dict__.get(s, []): exist = False for c2 in range(len(new)): - #For _constraints, we should check field and methods as well - if new[c2][2]==c[2] and (new[c2][0] == c[0] \ + #For _constraints, we should check field and methods as well + if new[c2][2]==c[2] and (new[c2][0] == c[0] \ or getattr(new[c2][0],'__name__', True) == \ getattr(c[0],'__name__', False)): # If new class defines a constraint with @@ -2690,7 +2690,7 @@ class BaseModel(object): elif val in dict(self._columns[field].selection(self, cr, uid, context=context)): return raise except_orm(_('ValidateError'), - _('The value "%s" for the field "%s.%s" is not in the selection') % (value, self._table, field)) + _('The value "%s" for the field "%s.%s" is not in the selection') % (value, self._table, field)) def _check_removed_columns(self, cr, log=False): # iterate on the database columns to drop the NOT NULL constraints diff --git a/openerp/service/netrpc_server.py b/openerp/service/netrpc_server.py index f86d6d21273..efe26906720 100644 --- a/openerp/service/netrpc_server.py +++ b/openerp/service/netrpc_server.py @@ -125,9 +125,9 @@ class TinySocketServerThread(threading.Thread,netsvc.Server): ct.start() lt = len(self.threads) if (lt > 10) and (lt % 10 == 0): - # Not many threads should be serving at the same time, so log - # their abuse. - netsvc.Logger().notifyChannel("web-services", netsvc.LOG_DEBUG, + # Not many threads should be serving at the same time, so log + # their abuse. + netsvc.Logger().notifyChannel("web-services", netsvc.LOG_DEBUG, "Netrpc: %d threads" % len(self.threads)) self.socket.close() except Exception, e: diff --git a/openerp/service/web_services.py b/openerp/service/web_services.py index 1bda0230c89..8c3db0e88af 100644 --- a/openerp/service/web_services.py +++ b/openerp/service/web_services.py @@ -521,11 +521,11 @@ GNU Public Licence. 'OS Name : %s\n' \ %(platform.platform(), platform.os.name) if os.name == 'posix': - if platform.system() == 'Linux': - lsbinfo = os.popen('lsb_release -a').read() - environment += '%s'%(lsbinfo) - else: - environment += 'Your System is not lsb compliant\n' + if platform.system() == 'Linux': + lsbinfo = os.popen('lsb_release -a').read() + environment += '%s'%(lsbinfo) + else: + environment += 'Your System is not lsb compliant\n' environment += 'Operating System Release : %s\n' \ 'Operating System Version : %s\n' \ 'Operating System Architecture : %s\n' \ diff --git a/openerp/tests/test_xmlrpc.py b/openerp/tests/test_xmlrpc.py index 954d3447360..ca0ae454437 100644 --- a/openerp/tests/test_xmlrpc.py +++ b/openerp/tests/test_xmlrpc.py @@ -19,8 +19,8 @@ ADMIN_USER_ID = common.ADMIN_USER_ID ADMIN_PASSWORD = common.ADMIN_PASSWORD def setUpModule(): - common.start_openerp() - common.create_xmlrpc_proxies() + common.start_openerp() + common.create_xmlrpc_proxies() tearDownModule = common.tearDownModule From efef81654b90e70a24d1a330c0ef8d9942e05444 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Thu, 19 Jan 2012 20:18:38 +0100 Subject: [PATCH 003/526] [REF] replace deprecated <> symbol. bzr revid: florent.xicluna@gmail.com-20120119191838-r07oybyiqbkfehsz --- openerp/osv/orm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index f2686708436..dceb14a2710 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -1303,7 +1303,7 @@ class BaseModel(object): if not line[i]: continue - if field[:len(prefix)] <> prefix: + if field[:len(prefix)] != prefix: if line[i] and skip: return False continue @@ -2666,7 +2666,7 @@ class BaseModel(object): # if val is a many2one, just write the ID if type(val) == tuple: val = val[0] - if (val<>False) or (type(val)<>bool): + if val is not False: cr.execute(update_query, (ss[1](val), key)) def _check_selection_field_value(self, cr, uid, field, value, context=None): From c749cd8fcc864e6103f55bcf7b12e0910f2ffa14 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Mon, 23 Jan 2012 15:29:32 +0100 Subject: [PATCH 004/526] =?UTF-8?q?[IMP]=C2=A0upgrade=20the=20Pickle=20pro?= =?UTF-8?q?tocol=20to=20consume=20less=20bandwidth.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bzr revid: florent.xicluna@gmail.com-20120123142932-idcqz4p46gvbvhfh --- openerp/tiny_socket.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openerp/tiny_socket.py b/openerp/tiny_socket.py index b4bed83a4c0..c3960afd054 100644 --- a/openerp/tiny_socket.py +++ b/openerp/tiny_socket.py @@ -28,6 +28,10 @@ import netsvc #.apidoc title: Net-RPC classes +# Pickle protocol version 2 is optimized compared to default (version 0) +PICKLE_PROTOCOL = 2 + + class Myexception(Exception): """ custom exception object store @@ -63,8 +67,8 @@ class mysocket: netsvc.close_socket(self.sock) def mysend(self, msg, exception=False, traceback=None): - msg = cPickle.dumps([msg,traceback]) - self.sock.sendall('%8d%s%s' % (len(msg), exception and "1" or "0", msg)) + msg = cPickle.dumps([msg, traceback], PICKLE_PROTOCOL) + self.sock.sendall('%8d%d%s' % (len(msg), bool(exception), msg)) def myreceive(self): buf='' From bac1a957193c5b76fc944d268d2b711809e34d19 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Mon, 23 Jan 2012 15:30:15 +0100 Subject: [PATCH 005/526] =?UTF-8?q?[IMP]=C2=A0merge=20two=20socket.recv=20?= =?UTF-8?q?into=20one.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bzr revid: florent.xicluna@gmail.com-20120123143015-gz22l5qre6ria8f4 --- openerp/tiny_socket.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/openerp/tiny_socket.py b/openerp/tiny_socket.py index c3960afd054..87db82f6d91 100644 --- a/openerp/tiny_socket.py +++ b/openerp/tiny_socket.py @@ -72,15 +72,14 @@ class mysocket: def myreceive(self): buf='' - while len(buf) < 8: - chunk = self.sock.recv(8 - len(buf)) + while len(buf) < 9: + chunk = self.sock.recv(9 - len(buf)) if not chunk: raise socket.timeout buf += chunk - size = int(buf) - buf = self.sock.recv(1) - if buf != "0": - exception = buf + size = int(buf[:8]) + if buf[8] != "0": + exception = buf[8] else: exception = False msg = '' From 111d8b76f7e384a3b1a77d802b52eedbb7ae04c7 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Wed, 1 Feb 2012 13:33:11 +0100 Subject: [PATCH 006/526] [REF] one unused import and one redundant import. bzr revid: florent.xicluna@gmail.com-20120201123311-yvljvcj0luly77qt --- openerp-server | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/openerp-server b/openerp-server index 334c1790526..5868b4f33d5 100755 --- a/openerp-server +++ b/openerp-server @@ -42,9 +42,6 @@ import openerp __author__ = openerp.release.author __version__ = openerp.release.version -import sys -import imp - def check_root_user(): """ Exit if the process's user is 'root' (on POSIX system).""" if os.name == 'posix': @@ -200,7 +197,7 @@ def quit_on_signals(): try: while quit_signals_received == 0: time.sleep(60) - except KeyboardInterrupt, e: + except KeyboardInterrupt: pass if config['pidfile']: From 1ef81548ba5dd463adaf20433b7bc4b39ebb8e78 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Wed, 8 Feb 2012 15:22:48 +0100 Subject: [PATCH 007/526] [REF] additional cleanup after vmt's logging refactoring. bzr revid: florent.xicluna@gmail.com-20120208142248-p63odfqo673yqqml --- openerp/service/netrpc_server.py | 2 +- openerp/service/web_services.py | 17 ++++++++--------- openerp/wizard/__init__.py | 6 +----- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/openerp/service/netrpc_server.py b/openerp/service/netrpc_server.py index 327ebc5bbdc..fcbfaf0ba82 100644 --- a/openerp/service/netrpc_server.py +++ b/openerp/service/netrpc_server.py @@ -131,7 +131,7 @@ class TinySocketServerThread(threading.Thread,netsvc.Server): _logger.debug("Netrpc: %d threads", len(self.threads)) self.socket.close() except Exception, e: - _logger.warning("Netrpc: closing because of exception %s" % str(e)) + _logger.warning("Netrpc: closing because of exception %s", e) self.socket.close() return False diff --git a/openerp/service/web_services.py b/openerp/service/web_services.py index 43f4d1af639..661b74a6995 100644 --- a/openerp/service/web_services.py +++ b/openerp/service/web_services.py @@ -224,9 +224,9 @@ class db(netsvc.ExportService): if not data or res: _logger.error( - 'DUMP DB: %s failed! Please verify the configuration of the database password on the server. '\ - 'It should be provided as a -w command-line option, or as `db_password` in the '\ - 'server configuration file.\n %s' % (db_name, data)) + 'DUMP DB: %s failed! Please verify the configuration of the database password on the server. ' + 'It should be provided as a -w command-line option, or as `db_password` in the ' + 'server configuration file.\n %s', db_name, data) raise Exception, "Couldn't dump database" _logger.info('DUMP DB successful: %s', db_name) @@ -239,7 +239,7 @@ class db(netsvc.ExportService): self._set_pg_psw_env_var() if self.exp_db_exist(db_name): - _logger.warning('RESTORE DB: %s already exists' % (db_name,)) + _logger.warning('RESTORE DB: %s already exists', db_name) raise Exception, "Database already exists" self._create_empty_database(db_name) @@ -268,7 +268,7 @@ class db(netsvc.ExportService): res = stdout.close() if res: raise Exception, "Couldn't restore database" - _logger.info('RESTORE DB: %s' % (db_name)) + _logger.info('RESTORE DB: %s', db_name) return True finally: @@ -451,8 +451,7 @@ GNU Public Licence. backup_directory = os.path.join(tools.config['root_path'], 'backup', time.strftime('%Y-%m-%d-%H-%M')) if zips and not os.path.isdir(backup_directory): - _logger.info('create a new backup directory to \ - store the old modules: %s', backup_directory) + _logger.info('create a new backup directory to store the old modules: %s', backup_directory) os.makedirs(backup_directory) for module in zips: @@ -678,7 +677,7 @@ class report_spool(netsvc.ExportService): self._reports[id]['state'] = True except Exception, exception: - _logger.exception('Exception: %s\n', str(exception)) + _logger.exception('Exception: %s\n', exception) if hasattr(exception, 'name') and hasattr(exception, 'value'): self._reports[id]['exception'] = openerp.exceptions.DeferredException(tools.ustr(exception.name), tools.ustr(exception.value)) else: @@ -715,7 +714,7 @@ class report_spool(netsvc.ExportService): self._reports[id]['format'] = format self._reports[id]['state'] = True except Exception, exception: - _logger.exception('Exception: %s\n', str(exception)) + _logger.exception('Exception: %s\n', exception) if hasattr(exception, 'name') and hasattr(exception, 'value'): self._reports[id]['exception'] = openerp.exceptions.DeferredException(tools.ustr(exception.name), tools.ustr(exception.value)) else: diff --git a/openerp/wizard/__init__.py b/openerp/wizard/__init__.py index 7354a43498d..debf0f1e74f 100644 --- a/openerp/wizard/__init__.py +++ b/openerp/wizard/__init__.py @@ -31,7 +31,6 @@ import openerp.pooler as pooler from openerp.osv.osv import except_osv from openerp.osv.orm import except_orm -import sys _logger = logging.getLogger(__name__) @@ -168,10 +167,7 @@ class interface(netsvc.Service): or isinstance(e, except_orm): netsvc.abort_response(2, e.name, 'warning', e.value) else: - import traceback - tb_s = reduce(lambda x, y: x+y, traceback.format_exception( - sys.exc_type, sys.exc_value, sys.exc_traceback)) - _logger.error('Exception in call: ' + tb_s) + _logger.exception('Exception in call:') raise return res From 57ca8e47975101c57991cf89efe86c033ff8a6de Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Wed, 8 Feb 2012 18:00:34 +0100 Subject: [PATCH 008/526] [REF] openerp.report: better use of isinstance. bzr revid: florent.xicluna@gmail.com-20120208170034-2w8szxy350qpwas6 --- openerp/report/custom.py | 2 +- openerp/report/render/rml2txt/utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openerp/report/custom.py b/openerp/report/custom.py index 051d1f29862..d06f2d721f7 100644 --- a/openerp/report/custom.py +++ b/openerp/report/custom.py @@ -108,7 +108,7 @@ class report_custom(report_int): key = levels.keys() for l in key: objs = eval('obj.'+l,{'obj': obj}) - if not isinstance(objs, browse_record_list) and type(objs) <> type([]): + if not isinstance(objs, (browse_record_list, list)): objs = [objs] field_new = [] cond_new = [] diff --git a/openerp/report/render/rml2txt/utils.py b/openerp/report/render/rml2txt/utils.py index 122411afb2d..c08210ecc79 100644 --- a/openerp/report/render/rml2txt/utils.py +++ b/openerp/report/render/rml2txt/utils.py @@ -75,9 +75,9 @@ def _process_text(self, txt): txt2 = eval(sps.pop(0),self.localcontext) except: txt2 = '' - if type(txt2) == type(0) or type(txt2) == type(0.0): + if isinstance(txt2, (int, float)): txt2 = str(txt2) - if type(txt2)==type('') or type(txt2)==type(u''): + if isinstance(txt2, basestring): result += txt2 return result From b5fa51f4a691b840e588bc33e4e960958860fd12 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Wed, 8 Feb 2012 18:02:17 +0100 Subject: [PATCH 009/526] =?UTF-8?q?[REF]=C2=A0openerp.report:=20use=20the?= =?UTF-8?q?=20recommended=20syntax=20to=20raise=20error=20and=20never=20us?= =?UTF-8?q?e=20empty=20except:.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bzr revid: florent.xicluna@gmail.com-20120208170217-xsa5odzlhite0nda --- openerp/report/custom.py | 2 +- openerp/report/interface.py | 4 ++-- openerp/report/preprocess.py | 2 +- openerp/report/printscreen/ps_list.py | 2 +- openerp/report/render/rml2html/rml2html.py | 2 +- openerp/report/render/rml2pdf/trml2pdf.py | 2 +- openerp/report/render/rml2txt/utils.py | 8 ++++---- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/openerp/report/custom.py b/openerp/report/custom.py index d06f2d721f7..a03ae0b8a53 100644 --- a/openerp/report/custom.py +++ b/openerp/report/custom.py @@ -267,7 +267,7 @@ class report_custom(report_int): else: try: row.append(float(r[j])) - except: + except Exception: row.append(r[j]) results2.append(row) if report['type']=='pie': diff --git a/openerp/report/interface.py b/openerp/report/interface.py index 9a97c445671..69474a18433 100644 --- a/openerp/report/interface.py +++ b/openerp/report/interface.py @@ -44,8 +44,8 @@ class report_int(netsvc.Service): def __init__(self, name): assert not self.exists(name), 'The report "%s" already exists!' % name super(report_int, self).__init__(name) - if name[0:7]<>'report.': - raise Exception, 'ConceptionError, bad report name, should start with "report."' + if not name.startswith('report.'): + raise Exception('ConceptionError, bad report name, should start with "report."') self.name = name self.id = 0 self.name2 = '.'.join(name.split('.')[1:]) diff --git a/openerp/report/preprocess.py b/openerp/report/preprocess.py index e681860d7a2..93b6b4d1bc9 100644 --- a/openerp/report/preprocess.py +++ b/openerp/report/preprocess.py @@ -48,7 +48,7 @@ class report(object): try: while n.tag != txt.group(3): n = n.getparent() - except: + except Exception: n = node else: n = node.getparent() diff --git a/openerp/report/printscreen/ps_list.py b/openerp/report/printscreen/ps_list.py index dc280a53e3e..8f0629462f8 100644 --- a/openerp/report/printscreen/ps_list.py +++ b/openerp/report/printscreen/ps_list.py @@ -56,7 +56,7 @@ class report_printscreen_list(report_int): def _parse_string(self, view): try: dom = etree.XML(view.encode('utf-8')) - except: + except Exception: dom = etree.XML(view) return self._parse_node(dom) diff --git a/openerp/report/render/rml2html/rml2html.py b/openerp/report/render/rml2html/rml2html.py index 504492772df..a26f6eadaa6 100644 --- a/openerp/report/render/rml2html/rml2html.py +++ b/openerp/report/render/rml2html/rml2html.py @@ -98,7 +98,7 @@ class _flowable(object): try: if new_child.get('style').find('terp_tblheader')!= -1: new_node.tag = 'th' - except: + except Exception: pass process(node,new_node) if new_node.get('colWidths',False): diff --git a/openerp/report/render/rml2pdf/trml2pdf.py b/openerp/report/render/rml2pdf/trml2pdf.py index 96287166074..58457993142 100644 --- a/openerp/report/render/rml2pdf/trml2pdf.py +++ b/openerp/report/render/rml2pdf/trml2pdf.py @@ -424,7 +424,7 @@ class _rml_canvas(object): flow.drawOn(self.canvas,infos['x'],infos['y']) infos['height']-=h else: - raise ValueError, "Not enough space" + raise ValueError("Not enough space") def _line_mode(self, node): ljoin = {'round':1, 'mitered':0, 'bevelled':2} diff --git a/openerp/report/render/rml2txt/utils.py b/openerp/report/render/rml2txt/utils.py index c08210ecc79..95e99c32ce1 100644 --- a/openerp/report/render/rml2txt/utils.py +++ b/openerp/report/render/rml2txt/utils.py @@ -37,7 +37,7 @@ def _child_get(node, self=None, tagname=None): if n.get('rml_except', False): try: eval(n.get('rml_except'), {}, self.localcontext) - except: + except Exception: continue if n.get('rml_tag'): try: @@ -46,7 +46,7 @@ def _child_get(node, self=None, tagname=None): n2.tag = tag n2.attrib.update(attr) yield n2 - except: + except Exception: yield n else: yield n @@ -55,7 +55,7 @@ def _child_get(node, self=None, tagname=None): if self and self.localcontext and n.get('rml_except', False): try: eval(n.get('rml_except'), {}, self.localcontext) - except: + except Exception: continue if (tagname is None) or (n.tag==tagname): yield n @@ -73,7 +73,7 @@ def _process_text(self, txt): if sps: try: txt2 = eval(sps.pop(0),self.localcontext) - except: + except Exception: txt2 = '' if isinstance(txt2, (int, float)): txt2 = str(txt2) From 9621008df12a65730a123e389d84ef8b21e5941d Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Wed, 8 Feb 2012 18:03:51 +0100 Subject: [PATCH 010/526] =?UTF-8?q?[REF]=C2=A0openerp.report:=20replace=20?= =?UTF-8?q?deprecated=20has=5Fkey.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bzr revid: florent.xicluna@gmail.com-20120208170351-1vmewmuufmxn7x52 --- openerp/report/custom.py | 14 +++++++------- openerp/report/print_xml.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/openerp/report/custom.py b/openerp/report/custom.py index a03ae0b8a53..b33065fcdee 100644 --- a/openerp/report/custom.py +++ b/openerp/report/custom.py @@ -221,7 +221,7 @@ class report_custom(report_int): res_dic[prev].append(line) else: prev = line[groupby] - if res_dic.has_key(line[groupby]): + if line[groupby] in res_dic: res_dic[line[groupby]].append(line) else: res_dic[line[groupby]] = [] @@ -389,7 +389,7 @@ class report_custom(report_int): if date_idx != None: for r in results: key = process_date['Y'](r[date_idx]) - if not data_by_year.has_key(key): + if key not in data_by_year: data_by_year[key] = [] for i in range(len(r)): r[i] = fct[i](r[i]) @@ -407,14 +407,14 @@ class report_custom(report_int): for d in data_by_year[line]: for idx in range(len(fields)-1): fields_bar.append({}) - if fields_bar[idx].has_key(d[0]): + if d[0] in fields_bar[idx]: fields_bar[idx][d[0]] += d[idx+1] else: fields_bar[idx][d[0]] = d[idx+1] for idx in range(len(fields)-1): data = {} for k in fields_bar[idx].keys(): - if data.has_key(k): + if k in data: data[k] += fields_bar[idx][k] else: data[k] = fields_bar[idx][k] @@ -488,7 +488,7 @@ class report_custom(report_int): if date_idx != None: for r in results: key = process_date['Y'](r[date_idx]) - if not data_by_year.has_key(key): + if key not in data_by_year: data_by_year[key] = [] for i in range(len(r)): r[i] = fct[i](r[i]) @@ -507,14 +507,14 @@ class report_custom(report_int): for d in data_by_year[line]: for idx in range(len(fields)-1): fields_bar.append({}) - if fields_bar[idx].has_key(d[0]): + if d[0] in fields_bar[idx]: fields_bar[idx][d[0]] += d[idx+1] else: fields_bar[idx][d[0]] = d[idx+1] for idx in range(len(fields)-1): data = {} for k in fields_bar[idx].keys(): - if data.has_key(k): + if k in data: data[k] += fields_bar[idx][k] else: data[k] = fields_bar[idx][k] diff --git a/openerp/report/print_xml.py b/openerp/report/print_xml.py index ee1b9a316b3..2137eabee79 100644 --- a/openerp/report/print_xml.py +++ b/openerp/report/print_xml.py @@ -200,7 +200,7 @@ class document(object): else: args = [] # get the object - if attrs.has_key('model'): + if 'model' in attrs: obj = self.pool.get(attrs['model']) else: if isinstance(browser, list): @@ -209,7 +209,7 @@ class document(object): obj = browser._table # get the ids - if attrs.has_key('ids'): + if 'ids' in attrs: ids = self.eval(browser, attrs['ids']) else: if isinstance(browser, list): From 7675d45c2c10e833bc5d5f0b3f905f1cca652a3d Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Wed, 8 Feb 2012 18:04:56 +0100 Subject: [PATCH 011/526] [REF] openerp.report: fix weird indentation, not multiple of four. bzr revid: florent.xicluna@gmail.com-20120208170456-ak1ykpy6yel71ylc --- openerp/report/interface.py | 2 +- openerp/report/print_xml.py | 2 +- openerp/report/printscreen/ps_form.py | 2 +- openerp/report/render/rml2html/rml2html.py | 16 ++++++++-------- openerp/report/render/rml2pdf/trml2pdf.py | 2 +- openerp/report/render/rml2txt/rml2txt.py | 4 ++-- openerp/report/render/simple.py | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/openerp/report/interface.py b/openerp/report/interface.py index 69474a18433..17dc0973d7e 100644 --- a/openerp/report/interface.py +++ b/openerp/report/interface.py @@ -181,7 +181,7 @@ class report_rml(report_int): def create_pdf(self, rml, localcontext = None, logo=None, title=None): if not localcontext: - localcontext={} + localcontext = {} localcontext.update({'internal_header':self.internal_header}) if logo: self.bin_datas['logo'] = logo diff --git a/openerp/report/print_xml.py b/openerp/report/print_xml.py index 2137eabee79..c2af0984c2e 100644 --- a/openerp/report/print_xml.py +++ b/openerp/report/print_xml.py @@ -228,7 +228,7 @@ class document(object): if not isinstance(datas[atr['value']], (str, unicode)): txt = str(datas[atr['value']]) else: - txt = datas[atr['value']] + txt = datas[atr['value']] el.text = txt else: for el_cld in node: diff --git a/openerp/report/printscreen/ps_form.py b/openerp/report/printscreen/ps_form.py index 8e3823e6b03..cf6d77cbe26 100644 --- a/openerp/report/printscreen/ps_form.py +++ b/openerp/report/printscreen/ps_form.py @@ -120,7 +120,7 @@ class report_printscreen_list(report_int): line[f]=round(line[f],precision) col = etree.SubElement(node_line, 'col', tree='no') if line[f] != None: - col.text = tools.ustr(line[f] or '') + col.text = tools.ustr(line[f] or '') else: col.text = '/' diff --git a/openerp/report/render/rml2html/rml2html.py b/openerp/report/render/rml2html/rml2html.py index a26f6eadaa6..17ed2e3103e 100644 --- a/openerp/report/render/rml2html/rml2html.py +++ b/openerp/report/render/rml2html/rml2html.py @@ -232,7 +232,7 @@ class _rml_stylesheet(object): attr = {} attrs = ps.attrib for key, val in attrs.items(): - attr[key] = val + attr[key] = val attrs = [] for a in attr: if a in self._tags: @@ -296,13 +296,13 @@ class _rml_template(object): frames[(posy,posx,tmpl.get('id'))] = _rml_tmpl_frame(posx, utils.unit_get(tmpl.get('width'))) for tmpl in pt.findall('pageGraphics'): for n in tmpl: - if n.tag == 'image': - self.data = rc + utils._process_text(self, n.text) - if n.tag in self._tags: - t = self._tags[n.tag](n, self.style,self.localcontext) - frames[(t.posy,t.posx,n.tag)] = t - else: - self.style.update(n) + if n.tag == 'image': + self.data = rc + utils._process_text(self, n.text) + if n.tag in self._tags: + t = self._tags[n.tag](n, self.style,self.localcontext) + frames[(t.posy,t.posx,n.tag)] = t + else: + self.style.update(n) keys = frames.keys() keys.sort() keys.reverse() diff --git a/openerp/report/render/rml2pdf/trml2pdf.py b/openerp/report/render/rml2pdf/trml2pdf.py index 58457993142..a17c03b40cb 100644 --- a/openerp/report/render/rml2pdf/trml2pdf.py +++ b/openerp/report/render/rml2pdf/trml2pdf.py @@ -82,7 +82,7 @@ class NumberedCanvas(canvas.Canvas): def showPage(self): self._currentPage +=1 if not self._flag: - self._pageCount += 1 + self._pageCount += 1 else: self.pages.update({self._currentPage:self._pageCount}) self._codes.append({'code': self._code, 'stack': self._codeStack}) diff --git a/openerp/report/render/rml2txt/rml2txt.py b/openerp/report/render/rml2txt/rml2txt.py index 4a30e0d2345..8a8c1b7f3c7 100755 --- a/openerp/report/render/rml2txt/rml2txt.py +++ b/openerp/report/render/rml2txt/rml2txt.py @@ -336,8 +336,8 @@ class _rml_stylesheet(object): attr = {} attrs = ps.attributes for i in range(attrs.length): - name = attrs.item(i).localName - attr[name] = ps.get(name) + name = attrs.item(i).localName + attr[name] = ps.get(name) attrs = [] for a in attr: if a in self._tags: diff --git a/openerp/report/render/simple.py b/openerp/report/render/simple.py index 4ce10991924..49d1adf148e 100644 --- a/openerp/report/render/simple.py +++ b/openerp/report/render/simple.py @@ -82,7 +82,7 @@ if __name__=='__main__': ''' if s.render(): - print s.get() + print s.get() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 6312fd9426d6ccdbbfdada88763961f4b29d5c06 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Wed, 8 Feb 2012 18:07:00 +0100 Subject: [PATCH 012/526] [REF] openerp.report: remove unused imports and vars, simplify logging. bzr revid: florent.xicluna@gmail.com-20120208170700-csx9jb3nwmvq3dzj --- openerp/report/custom.py | 3 --- openerp/report/render/html2html/html2html.py | 2 -- openerp/report/render/makohtml2html/makohtml2html.py | 8 +++----- openerp/report/render/odt2odt/odt2odt.py | 1 - openerp/report/render/rml2html/rml2html.py | 2 +- openerp/report/render/rml2txt/rml2txt.py | 2 -- openerp/report/render/rml2txt/utils.py | 1 - openerp/report/render/simple.py | 1 - 8 files changed, 4 insertions(+), 16 deletions(-) diff --git a/openerp/report/custom.py b/openerp/report/custom.py index b33065fcdee..80dd9462175 100644 --- a/openerp/report/custom.py +++ b/openerp/report/custom.py @@ -21,7 +21,6 @@ import os import time -import openerp.netsvc as netsvc import openerp.tools as tools from openerp.tools.safe_eval import safe_eval as eval @@ -67,7 +66,6 @@ class report_custom(report_int): # def _row_get(self, cr, uid, objs, fields, conditions, row_canvas=None, group_by=None): result = [] - tmp = [] for obj in objs: tobreak = False for cond in conditions: @@ -365,7 +363,6 @@ class report_custom(report_int): order_date['Y'] = lambda x : x abscissa = [] - tmp = {} idx = 0 date_idx = None diff --git a/openerp/report/render/html2html/html2html.py b/openerp/report/render/html2html/html2html.py index 181c7f7ba67..09d7ad5e825 100644 --- a/openerp/report/render/html2html/html2html.py +++ b/openerp/report/render/html2html/html2html.py @@ -20,9 +20,7 @@ ############################################################################## from openerp.report.render.rml2pdf import utils -from lxml import etree import copy -import openerp.pooler as pooler import base64 import cStringIO import re diff --git a/openerp/report/render/makohtml2html/makohtml2html.py b/openerp/report/render/makohtml2html/makohtml2html.py index 57e57bd8d63..dbb3327a105 100644 --- a/openerp/report/render/makohtml2html/makohtml2html.py +++ b/openerp/report/render/makohtml2html/makohtml2html.py @@ -23,8 +23,7 @@ import mako from lxml import etree from mako.template import Template from mako.lookup import TemplateLookup -import openerp.netsvc as netsvc -import traceback, sys, os +import os _logger = logging.getLogger(__name__) @@ -126,9 +125,8 @@ class makohtml2html(object): final_html += self.format_header(etree_obj) final_html += self.format_body(etree_obj) return final_html - except Exception,e: - tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) - _logger.error('report :\n%s\n%s\n', tb_s, str(e)) + except Exception: + _logger.exception('report :') def parseNode(html, localcontext = {}): r = makohtml2html(html, localcontext) diff --git a/openerp/report/render/odt2odt/odt2odt.py b/openerp/report/render/odt2odt/odt2odt.py index d077207f4d7..b9713943dc8 100644 --- a/openerp/report/render/odt2odt/odt2odt.py +++ b/openerp/report/render/odt2odt/odt2odt.py @@ -20,7 +20,6 @@ ############################################################################## from openerp.report.render.rml2pdf import utils -from lxml import etree import copy class odt2odt(object): diff --git a/openerp/report/render/rml2html/rml2html.py b/openerp/report/render/rml2html/rml2html.py index 17ed2e3103e..90bd58af99a 100644 --- a/openerp/report/render/rml2html/rml2html.py +++ b/openerp/report/render/rml2html/rml2html.py @@ -39,7 +39,7 @@ import sys import cStringIO from lxml import etree import copy -import utils + from openerp.report.render.rml2pdf import utils class _flowable(object): diff --git a/openerp/report/render/rml2txt/rml2txt.py b/openerp/report/render/rml2txt/rml2txt.py index 8a8c1b7f3c7..ab1930d81ba 100755 --- a/openerp/report/render/rml2txt/rml2txt.py +++ b/openerp/report/render/rml2txt/rml2txt.py @@ -22,9 +22,7 @@ import sys import StringIO -import copy from lxml import etree -import base64 import utils diff --git a/openerp/report/render/rml2txt/utils.py b/openerp/report/render/rml2txt/utils.py index 95e99c32ce1..2bf66925527 100644 --- a/openerp/report/render/rml2txt/utils.py +++ b/openerp/report/render/rml2txt/utils.py @@ -22,7 +22,6 @@ import re import reportlab import reportlab.lib.units -from lxml import etree from openerp.tools.safe_eval import safe_eval as eval _regex = re.compile('\[\[(.+?)\]\]') diff --git a/openerp/report/render/simple.py b/openerp/report/render/simple.py index 49d1adf148e..cb3831c141f 100644 --- a/openerp/report/render/simple.py +++ b/openerp/report/render/simple.py @@ -66,7 +66,6 @@ class simple(render.render): return self.result.getvalue() if __name__=='__main__': - import time s = simple() s.xml = ''' From ab9db3f6227789fabf3fdfcd2eda016b996bfd28 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Wed, 8 Feb 2012 22:33:13 +0100 Subject: [PATCH 013/526] [REM] more unused imports. bzr revid: florent.xicluna@gmail.com-20120208213313-1v0dugc59ch1fnnu --- openerp/service/http_server.py | 2 -- openerp/tests/addons/test_limits/models.py | 1 - 2 files changed, 3 deletions(-) diff --git a/openerp/service/http_server.py b/openerp/service/http_server.py index 07e31ea9c7d..63e0d08fc92 100644 --- a/openerp/service/http_server.py +++ b/openerp/service/http_server.py @@ -44,10 +44,8 @@ import posixpath import urllib import os import logging -from SimpleXMLRPCServer import SimpleXMLRPCDispatcher from websrv_lib import * -import openerp.netsvc as netsvc import openerp.tools as tools try: diff --git a/openerp/tests/addons/test_limits/models.py b/openerp/tests/addons/test_limits/models.py index 5240acd23ab..32e2a9a16f4 100644 --- a/openerp/tests/addons/test_limits/models.py +++ b/openerp/tests/addons/test_limits/models.py @@ -27,7 +27,6 @@ class m(openerp.osv.osv.Model): return True def consume_cpu_time(self, cr, uid, seconds, context=None): - import os t0 = time.clock() t1 = time.clock() while t1 - t0 < seconds: From 55e7b8167e9705ddaabf388e8c95d15666a81827 Mon Sep 17 00:00:00 2001 From: "Vaibhav (OpenERP)" Date: Fri, 6 Apr 2012 11:43:30 +0530 Subject: [PATCH 014/526] [IMP] Web addon for SignIn/Out. bzr revid: vda@tinyerp.com-20120406061330-n80vyxgkr309ykba --- addons/hr_attendance/__openerp__.py | 4 + .../static/src/img/emp-in-disable.png | Bin 0 -> 1135 bytes .../hr_attendance/static/src/img/emp-in.png | Bin 0 -> 2153 bytes .../static/src/img/emp-out-disable.png | Bin 0 -> 1110 bytes .../hr_attendance/static/src/img/emp-out.png | Bin 0 -> 2062 bytes addons/hr_attendance/static/src/img/icon.png | Bin 0 -> 5938 bytes .../static/src/js/sign_in_out.js | 82 ++++++++++++++++++ .../static/src/xml/sign_in_out.xml | 28 ++++++ .../wizard/hr_attendance_sign_in_out.py | 1 + .../wizard/hr_attendance_sign_in_out_view.xml | 11 +-- 10 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 addons/hr_attendance/static/src/img/emp-in-disable.png create mode 100644 addons/hr_attendance/static/src/img/emp-in.png create mode 100644 addons/hr_attendance/static/src/img/emp-out-disable.png create mode 100644 addons/hr_attendance/static/src/img/emp-out.png create mode 100644 addons/hr_attendance/static/src/img/icon.png create mode 100644 addons/hr_attendance/static/src/js/sign_in_out.js create mode 100644 addons/hr_attendance/static/src/xml/sign_in_out.xml diff --git a/addons/hr_attendance/__openerp__.py b/addons/hr_attendance/__openerp__.py index c903a87abc4..b25047638c8 100644 --- a/addons/hr_attendance/__openerp__.py +++ b/addons/hr_attendance/__openerp__.py @@ -54,5 +54,9 @@ actions(Sign in/Sign out) performed by them. 'installable': True, 'auto_install': False, 'certificate': '0063495605613', + + #web + "js": ["static/src/js/sign_in_out.js"], + 'qweb' : ["static/src/xml/sign_in_out.xml"], } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_attendance/static/src/img/emp-in-disable.png b/addons/hr_attendance/static/src/img/emp-in-disable.png new file mode 100644 index 0000000000000000000000000000000000000000..1968e0de46434949ddb12393f4f21895270a334c GIT binary patch literal 1135 zcmV-#1d#iQP)kdg00001b5ch_0Itp) z=>Px#0%A)?L;(MXkIcUS000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iyb&2sa_Q z3&GR?00Z+$L_t(Y$BmR*Y*b|s$A5Fq>Dk@ZQkF#u6eyrrg9t^agh&iZ;K55`)F3_( zUwsf`AjlK77^_l~#=GH35^rGS#XuiSj3(Zt2oDqqAxgypEiK({yW8Ef=ljNoJ-yh{ zmYJO7!vitH6I{_{Z0XG;RM}XoG zqXLHvedJKJl0I2zEPl7Y@GM`9HSv44eXyfpI1-OfCFPV;Nfk+wWVuK;Llg)kz^(C~ zh*hsXc_>#l{t9inUX8dojC`Pga*1|=(l%fL2gR}G^Q*fKrXvPlvhwLI+Ytw_xCkH! z4nmrCvXMGd)MFUHQ5sry#e=M40ftZv)^m57 zg`-lA&k<3s<70493?LW+x+C&Q9$+!;v@wK>i=*CM+&>DC@3lDm!&(%J0~iD$OBThD zU=vFTFl@#nPX~R1_@z^*C4p0tz@1%o+jkT7TL| zEh!9cB;gVRmpm7^M#%4Mz;cRS;)D#4#A>F0L4f@}AN4GM0_FCn#`XyC_=%|A*$OVKrAy=tl5y~*LsnmoN{Xo(e+r}0} zNYuoibgE;TkP5AmBq>cvMR4ieLro{L#RZAZ;Jo`002ovPDHLkV1o9X B3oQTu literal 0 HcmV?d00001 diff --git a/addons/hr_attendance/static/src/img/emp-in.png b/addons/hr_attendance/static/src/img/emp-in.png new file mode 100644 index 0000000000000000000000000000000000000000..26e3c01556b290949b104240e73fe43dc27b1229 GIT binary patch literal 2153 zcmV-v2$uJWP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iyb& z2sbNP-YCid00-$wL_t(o!?jjxY*fb;{$}pI`!ZfX)(?yg=3ySj2~Pu|YSU6vRJEv) zC?#!GRJE$qRs|K&qzDMX7+hKsSxQuuKYfs@q{RxfjT;bZQV4H#5l*MM1r z*ZaD=d*^ZbW0y4q2#=^Ejpk}J_ndFObIx}Lc+9b_ZCn1kbw|tit*u)cTYuF$;r8D4 z?b{#Ap82={Oerh3Y}@qO@p_R?XYl7eyV2Ko{w;912EbMPKSp!Qrd4~| z-=x8tHz*#D=~ygA$z+@oi8$GILPsJ)^w!>XYHoSy#YeSiJnF&CTQ>f@>5Gfo7C!SC zFfee=m}#0Y3=^Ci&{{JhLfynkR8(BDq-NY0cKFbd!w<8|9(G{+D_cQ|X3lte*6DeT z^9W$f<+5O!7Az~f5)q^nkW#>L1OQDZPM%;VyG|{P#iJkna@#8pw9g*~VEv1m;PrZU zHO_5>5P~sAAj(dy30f-<>D*rSA1M`^JEsw&3JP|8lJiFjLF+GCCf3(CY%dFx5$B9C z#*v*2j4==ql+w^zLF?PAg5wC%n#!iuPu_dzy~E)rVxYOX8JhIcn(AsOC0W)%)`?OI zQVIwma`a0mC81Onh*FAGSJ!|vef5)kJQRRbYP8qup*wFl;#}rqFQv?ZPr&huV&zq?@m!d?EtBI-SRhJ9)A z5;%^NqZxTE007Q8TrM}>``5du8eL7@y=QuA3(IGQ;4IX$XtN zm38YjV8@Qu$75hq^M`*r8E;lARG=O5{V$xAHv|^4Oo^5%jJe}90(y% zQBjH7v9%~G3!t#n4@WyhAhfsd>0ZBP;|u_J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gC@i-uVse-;Y zHfGS49{*S?@ff7nbiqNXiO*W&IgHoqpeB)g?f_{7?d`152!(t{Z&NtFi4xnMfAEtc znNY{E(SSk#13%wWA>-qvha&pz`~YpQK7FB%}o}VB7%h<8;5d&M3`Y#Y@*Y%uM7>W18B$b9Z5c7*q9jDL|Gz^jbLDM z1D7b%%n~LcO8KrQntvU;?G)MxTxc?~DhX0aHPzHmLlqJ3rw9`Z6BDIemg|hs`X_Qq z7?1{Wm5D+213@tWSVWj%4nM=hNux=NKV49*!`?CWv#+_S1!Vvl69p&~24Q~0W|>76 zXygTIxRmjxvQ4AzO21b^3;J-0fFg|Lox8>bMu-q1#4HQ^fWzaQC1ZAQP8}^??LnYK zDPayjE+F0=pt(wj8A7<2r04;T)8naQFFP7my^xG(4F2XYg2n(`6pDYC!{QV#d7{;5 z9;1~m_Ok`2aus0ZYJ?cu5cH}|6fO=+C`Nb~fE4wZ*o;$;9|Ka^60CEBSI}(3_4F^E z|0_sgGfE51oa86`xO8$I3j-g~$*h_DR9fm-;}#K>sZTt@0sf?jVoE6GSzgDclL;&= zOz}th-^?-)^ygpq4%%v~*TU@FPX&Gg1n{9*;$1J@AgE&9Ywc`t*U)Ha(cLWpjYS#< zn-mUZOp*{3{J~euGk*KI%2U2wtx41B1_@|nK#M`h&yE|mP^?&4z&g_V+uPJTNE cRo-L$A96_I2bkv;asU7T07*qoM6N<$f|Dll%>V!Z literal 0 HcmV?d00001 diff --git a/addons/hr_attendance/static/src/img/emp-out.png b/addons/hr_attendance/static/src/img/emp-out.png new file mode 100644 index 0000000000000000000000000000000000000000..d2a6cbb50137c404d3f188151bb64024c082b75a GIT binary patch literal 2062 zcmV+p2=VucP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iyb& z2ssF4I&?Mw00)jqL_t(o!?l)aY+c0_$A2^T-nTjNvtws-UhLR01rq`#aY8|rT1WsD zXe*J3N=T?dNG+9sR?rj?NaL6Uw?wj9K2+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T0+z90yY@;@x*202OQ2Fu$XNLJ5Qb z*DYR5CX;FY27qGG9h}g1Z*MQ@bb7MJPrQ64TCQ(GVuyN=zCP5kW5_MHpk8|odH;R% z?%l*YI}xqH7^>Hs0q8%dbY=l2c_4lKH%q#ji`7WEQ`PxSA9!&ocBuS zOWC^GMO0Q+5Rb>PEDNPnq<5u(C<&G0P`v*E{O5OIl_V1Y9^eAA)~_e?+ zojZ|O3}xF$c{%&P{POCrH=`I(W7%5$^e5M^C@V{eh^VOEPe_qc6ai!K%2H(Zd`4>K zOcLodGty~hRaP?ho_na+wr!eoY#Ze`h-HbJOb*s`bv^X;91y^~^g_qKp5O88hpy+V z88c>1zJj9I2h*lnxsub18;Cm&sbrE=B0=1?(P4-T4`e^x?<5`i^H$g(kd2L=r{}w&UP?0e%qRdp@ok_5Q(zdaD2PDQbLN6es~ycQ@+k zr%_*h6*+dC2t*>mIDA;ObLVe2ouwHifH}ZiAO(1JbqnVL%#eB6l=M1j_kQ>_u(7L`h=F=IYDc;LY5dBtKOQz)FZ8#+L;loRTF-VG>a zev?kmYt3ZZDsB6=SV?}^HWG_bwC%x>@$n}X?Ai0TV~K>+6^rNhAi0?F9Hf8T)YM#_ sOxA?p4h|0=y!`0VE`UwI<}>#G5B|MNh_viC#{d8T07*qoM6N<$f(9txod5s; literal 0 HcmV?d00001 diff --git a/addons/hr_attendance/static/src/img/icon.png b/addons/hr_attendance/static/src/img/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..297dc71c85c5fdd8deafabfbb46093e04adc32d1 GIT binary patch literal 5938 zcmZ{oWmFXI^Y&S~Q@W%NlQZ+2a^I50RaI=RYgJPA7%a%I_ke%>+HSx52!Zk$_fat|3z_c zRp!46hL?)5??0;iPfBC1QvVhGy<{E#QRaU-zJ^;NAdm>DD#+>uuAb#%d@$Y59w{n} zV@#J(iOk|Fp-kV&k~3Y^QH$!(b+Vq~dGD0q{}wxo1QD4Ps4`oh%BjA|XuNqJw)KbU zmpavmsg3xhhiZ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uYK?S`G+ECwenaSJ^Yf?T3E1pL`42z?_cH$B1^Uy`R%FUR#geTc;oQU4v5O zDWGtLejeaw9f<(a^=oi+1*;)Np4onst25!+{sHy+FbRRd zPn{b1<`{#;i4{Pd-v>#1N^|3=j~2yNm1MJzAOMP%14VIuUuBixf~dO?jso!wj36qN#&u}7i( z(&mmB*QfBxJUKMh_Wbz~@Oh@10!Aik%d(Qjwj{icpZ#2S^1pDcuy{pM!1qsjWuJci zcS>gZplI~L&iaGBn5~cfKOpe&@Q8B$d%XO5yaHmp{9-&j>^yw`@*g!m+W*Jk?rG=j z5cK~yWRfPA{WFmNH$m6a;X{D6k3B*_KmeDshpVrxwU<4Yr;lU)xdg?(CInSQ4TVNI HtLXm&e3x`` literal 0 HcmV?d00001 diff --git a/addons/hr_attendance/static/src/js/sign_in_out.js b/addons/hr_attendance/static/src/js/sign_in_out.js new file mode 100644 index 00000000000..0a0174d0a89 --- /dev/null +++ b/addons/hr_attendance/static/src/js/sign_in_out.js @@ -0,0 +1,82 @@ +openerp.hr_attendance = function(openerp) { + + openerp.hr_attendance.SignIn = openerp.web.Widget.extend({ + template: 'SignInNotifier', + start: function() { + this.$element.on('click', '.sign_in', this.getParent().on_sign_in_out); + } + }); + + openerp.hr_attendance.SignOut = openerp.web.Widget.extend({ + template: 'SignOutNotifier', + + start: function() { + this.$element.on('click', '.sign_out', this.getParent().on_sign_in_out); + } + }); + + openerp.hr_attendance.SignInOut = openerp.web.Widget.extend({ + template: "SignInOutNotifier", + init: function() { + this._super.apply(this, arguments); + this.dataset = new openerp.web.DataSetSearch( + this, + 'hr.employee', + this.session.user_context, + [['user_id','=', this.session.uid]]); + }, + + start: function() { + return this.dataset.read_slice(['state']).done(this.do_sign_in_out); + }, + + do_sign_in_out: function(user) { + if(_.isEmpty(user)) return; + if(user[0]['state'] === 'present') { + this.sign_out = new openerp.hr_attendance.SignOut(this); + this.sign_out.appendTo(this.$element); + } else { + this.sign_in = new openerp.hr_attendance.SignIn(this); + this.sign_in.appendTo(this.$element); + } + }, + + on_sign_in_out: function(evt) { + var self = this; + new openerp.web.DataSetSearch( + this, + 'ir.actions.act_window', + {}, + [['res_model', '=', 'hr.sign.in.out']]) + .read_slice().done(function(action) { + action = action[0]; + action.context = JSON.parse(action.context); + var action_manager = new openerp.web.ActionManager(self); + action_manager.do_action(action, self.on_close); + }); + }, + + on_close: function() { + if(this.sign_in) { + this.sign_in.destroy(); + this.sign_out = new openerp.hr_attendance.SignOut(this); + this.sign_out.appendTo(this.$element); + } else if(this.sign_out) { + this.sign_out.destroy(); + this.sign_in = new openerp.hr_attendance.SignIn(this); + this.sign_in.appendTo(this.$element); + } + } + }); + + openerp.web.UserMenu.include({ + do_update: function() { + var self = this; + this._super(); + this.update_promise.then(function() { + self.hr_sign_in_out = new openerp.hr_attendance.SignInOut(self); + self.hr_sign_in_out.appendTo(openerp.webclient.$element.find('.oe_systray')) + }); + } + }); +} diff --git a/addons/hr_attendance/static/src/xml/sign_in_out.xml b/addons/hr_attendance/static/src/xml/sign_in_out.xml new file mode 100644 index 00000000000..e28b93dfa6c --- /dev/null +++ b/addons/hr_attendance/static/src/xml/sign_in_out.xml @@ -0,0 +1,28 @@ + \ No newline at end of file diff --git a/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py b/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py index 55edb1406e8..15e8783d660 100644 --- a/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py +++ b/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py @@ -69,6 +69,7 @@ class hr_sign_in_out(osv.osv_memory): _columns = { 'name': fields.char('Employees name', size=32, required=True, readonly=True), 'state': fields.char('Current state', size=32, required=True, readonly=True), + 'date': fields.datetime('Date'), 'emp_id': fields.many2one('hr.employee', 'Empoyee ID', readonly=True), } diff --git a/addons/hr_attendance/wizard/hr_attendance_sign_in_out_view.xml b/addons/hr_attendance/wizard/hr_attendance_sign_in_out_view.xml index 5121a2d18a0..b729dd85e5b 100644 --- a/addons/hr_attendance/wizard/hr_attendance_sign_in_out_view.xml +++ b/addons/hr_attendance/wizard/hr_attendance_sign_in_out_view.xml @@ -10,15 +10,16 @@