From 7736b371d04d0ca36d91cd61ce83d815406d1f92 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 14 Dec 2010 17:33:20 +0200 Subject: [PATCH 1/4] users_ldap: replace tools.debug() with logging.debug() bzr revid: p_christ@hol.gr-20101214153320-5cz87zmxpfb6rntv --- addons/users_ldap/users_ldap.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/addons/users_ldap/users_ldap.py b/addons/users_ldap/users_ldap.py index df4528107cc..bf59b1b62e9 100644 --- a/addons/users_ldap/users_ldap.py +++ b/addons/users_ldap/users_ldap.py @@ -21,6 +21,7 @@ from osv import fields, osv import pooler import tools +import logging from service import security import ldap from ldap.filter import filter_format @@ -66,9 +67,9 @@ class users(osv.osv): _inherit = "res.users" def login(self, db, login, password): ret = super(users,self).login(db, login, password) - tools.debug(ret) if ret: return ret + logger = logging.getLogger('orm.ldap') pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() action_obj = pool.get('ir.actions.actions') @@ -78,7 +79,7 @@ class users(osv.osv): FROM res_company_ldap WHERE ldap_server != '' and ldap_binddn != '' ORDER BY sequence""") for res_company_ldap in cr.dictfetchall(): - tools.debug(res_company_ldap) + logger.debug(res_company_ldap) try: l = ldap.open(res_company_ldap['ldap_server'], res_company_ldap['ldap_server_port']) if l.simple_bind_s(res_company_ldap['ldap_binddn'], res_company_ldap['ldap_password']): @@ -93,13 +94,13 @@ class users(osv.osv): continue if result_type == ldap.RES_SEARCH_RESULT and len(result_data) == 1: dn = result_data[0][0] - tools.debug(dn) + logger.debug(dn) name = result_data[0][1]['cn'][0] if l.bind_s(dn, password): l.unbind() cr.execute("SELECT id FROM res_users WHERE login=%s",(tools.ustr(login),)) res = cr.fetchone() - tools.debug(res) + logger.debug(res) if res: cr.close() return res[0] @@ -127,7 +128,7 @@ class users(osv.osv): return res l.unbind() except Exception, e: - tools.debug(e) + logger.warning("Cannot auth", exc_info=True) continue cr.close() return False @@ -135,10 +136,11 @@ class users(osv.osv): def check(self, db, uid, passwd): try: return super(users,self).check(db, uid, passwd) - except: # AccessDenied + except ExceptionNoTb: # AccessDenied pass cr = pooler.get_db(db).cursor() user = self.browse(cr, 1, uid) + logger = logging.getLogger('orm.ldap') if user and user.company_id.ldaps: for res_company_ldap in user.company_id.ldaps: try: @@ -161,7 +163,7 @@ class users(osv.osv): return True l.unbind() except Exception, e: - tools.debug(e) + logger.warning('cannot check', exc_info=True) pass cr.close() raise security.ExceptionNoTb('AccessDenied') From bb8533edc6ed45ecb4996f1f7951b5ccbaccd9c0 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 14 Dec 2010 17:33:48 +0200 Subject: [PATCH 2/4] users_ldap: trivial fix in referenced exception. bzr revid: p_christ@hol.gr-20101214153348-2s3zpv7v710z5h13 --- addons/users_ldap/users_ldap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/users_ldap/users_ldap.py b/addons/users_ldap/users_ldap.py index bf59b1b62e9..2c590242889 100644 --- a/addons/users_ldap/users_ldap.py +++ b/addons/users_ldap/users_ldap.py @@ -136,7 +136,7 @@ class users(osv.osv): def check(self, db, uid, passwd): try: return super(users,self).check(db, uid, passwd) - except ExceptionNoTb: # AccessDenied + except security.ExceptionNoTb: # AccessDenied pass cr = pooler.get_db(db).cursor() user = self.browse(cr, 1, uid) From 56d65e54feb930e7bc90576c0b65e668fe6d1ced Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 14 Dec 2010 17:35:58 +0200 Subject: [PATCH 3/4] account: fix invoice report, second page header must be in partner's lang The PTO header for the second+ pages was rendered before the setting of partner's language, which meant that it would be translated to the user's lang. Move the xml block to fix that. bzr revid: p_christ@hol.gr-20101214153558-b93h81ys6fhad5w1 --- .../account/report/account_print_invoice.rml | 36 +++++++------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/addons/account/report/account_print_invoice.rml b/addons/account/report/account_print_invoice.rml index 6e67879d81c..80ccd2aabae 100644 --- a/addons/account/report/account_print_invoice.rml +++ b/addons/account/report/account_print_invoice.rml @@ -131,32 +131,20 @@ - - - - - Description - - - Taxes - - - Quantity - - - Unit Price - - - Disc.(%) - - - Price - - - - [[ repeatIn(objects,'o') ]] [[ setLang(o.partner_id.lang) ]] + + + + Description + Taxes + Quantity + Unit Price + Disc.(%) + Price + + + From 7583a7da0435dfddcf8cf2c81b9046ecd3688783 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 14 Dec 2010 17:36:08 +0200 Subject: [PATCH 4/4] account report: fix read_group() API mismatch read_group() of account entries and followup reports didn't match that of server. We'd better use generic references to positional and keyword arguments instead. bzr revid: p_christ@hol.gr-20101214153608-mbcjfzu26wolyip9 --- addons/account/report/account_entries_report.py | 4 ++-- addons/account_followup/report/account_followup_report.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/report/account_entries_report.py b/addons/account/report/account_entries_report.py index 80065880ad9..e80cb290889 100644 --- a/addons/account/report/account_entries_report.py +++ b/addons/account/report/account_entries_report.py @@ -94,7 +94,7 @@ class account_entries_report(osv.osv): return super(account_entries_report, self).search(cr, uid, args=args, offset=offset, limit=limit, order=order, context=context, count=count) - def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): + def read_group(self, cr, uid, domain, *args, **kwargs): todel=[] fiscalyear_obj = self.pool.get('account.fiscalyear') period_obj = self.pool.get('account.period') @@ -112,7 +112,7 @@ class account_entries_report(osv.osv): for a in [['period_id','in','current_year'], ['period_id','in','current_period']]: if a in domain: domain.remove(a) - return super(account_entries_report, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context) + return super(account_entries_report, self).read_group(cr, uid, domain, *args, **kwargs) def init(self, cr): tools.drop_view_if_exists(cr, 'account_entries_report') diff --git a/addons/account_followup/report/account_followup_report.py b/addons/account_followup/report/account_followup_report.py index ba0756f5c49..878f44ced30 100644 --- a/addons/account_followup/report/account_followup_report.py +++ b/addons/account_followup/report/account_followup_report.py @@ -55,14 +55,14 @@ class account_followup_stat(osv.osv): return super(account_followup_stat, self).search(cr, uid, args=args, offset=offset, limit=limit, order=order, context=context, count=count) - def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): + def read_group(self, cr, uid, domain, *args, **kwargs): for arg in domain: if arg[0] == 'period_id' and arg[2] == 'current_year': current_year = self.pool.get('account.fiscalyear').find(cr, uid) ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids'] domain.append(['period_id','in',ids]) domain.remove(arg) - return super(account_followup_stat, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context) + return super(account_followup_stat, self).read_group(cr, uid, domain, *args, **kwargs) def init(self, cr): tools.drop_view_if_exists(cr, 'account_followup_stat')