From 542b15e5b856cf4258badcd35715924d0fcdf37c Mon Sep 17 00:00:00 2001 From: "qdp-launchpad@tinyerp.com" <> Date: Thu, 9 Dec 2010 13:14:57 +0100 Subject: [PATCH 1/5] [FIX] l10n_uk: set a valid certificate number (second try) bzr revid: qdp-launchpad@tinyerp.com-20101209121457-iokquzx4bzwsgzgh --- addons/l10n_uk/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/l10n_uk/__openerp__.py b/addons/l10n_uk/__openerp__.py index c84385ba1d3..e39f620e1f3 100644 --- a/addons/l10n_uk/__openerp__.py +++ b/addons/l10n_uk/__openerp__.py @@ -75,6 +75,6 @@ 'demo_xml': [], 'installable': True, 'active': False, - 'certificate': '18956603329629', + 'certificate': '008956603329629', } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From aa27cd5b1c9343b25e6397b07994026dd4ee4caf Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 8 Dec 2010 18:53:48 +0100 Subject: [PATCH 2/5] [REVERT] project/board_project_manager_view.xml: reverted previous incorrect patch (incorrect view_id) bzr revid: odo@openerp.com-20101208175348-rfp94f9w4js0nbrd --- addons/project/board_project_manager_view.xml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/addons/project/board_project_manager_view.xml b/addons/project/board_project_manager_view.xml index 6a563bd2910..f9db634d51d 100644 --- a/addons/project/board_project_manager_view.xml +++ b/addons/project/board_project_manager_view.xml @@ -15,14 +15,7 @@ res_model="project.project" view_mode="tree,form" view_type="form"/> - + From eb25611f004e8cd33e9beb9766bc475aaf7de4ba Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 9 Dec 2010 16:04:42 +0100 Subject: [PATCH 3/5] [FIX] res.lang.unlink: renamed local variable that shadowed the enclosing type, preventing call to super() bzr revid: odo@openerp.com-20101209150442-f47eucdfylpokagt --- bin/addons/base/res/res_lang.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/addons/base/res/res_lang.py b/bin/addons/base/res/res_lang.py index 48c583c54cd..64bdb948d14 100644 --- a/bin/addons/base/res/res_lang.py +++ b/bin/addons/base/res/res_lang.py @@ -81,10 +81,10 @@ class lang(osv.osv): context = {} languages = self.read(cr, uid, ids, ['code','active'], context=context) for language in languages: - lang = context.get('lang') + ctx_lang = context.get('lang') if language['code']=='en_US': raise osv.except_osv(_('User Error'), _("Base Language 'en_US' can not be deleted !")) - if lang and (language['code']==lang): + if ctx_lang and (language['code']==ctx_lang): raise osv.except_osv(_('User Error'), _("You cannot delete the language which is User's Preferred Language !")) if language['active']: raise osv.except_osv(_('User Error'), _("You cannot delete the language which is Active !\nPlease de-activate the language first.")) From bb82904ba3b4f63f6c099c4a0c7b6b1814c61a33 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 10 Dec 2010 00:07:42 +0100 Subject: [PATCH 4/5] [FIX] fields.function: make sure all binary values can always be serialized as valid XML Nnormally, binary fields should be 7-bit ASCII base64-encoded data, but sometimes it's not the case, so we do additional sanity checks to make sure the binary values can pass safely via xmlrpc as strings. As a last resort we coerce the binary values to unicode to make sure they can be safely serialized as utf-8-encoded values, always valid XML characters. When this happens, decoding on the other endpoint is not likely to produce the expected output, but this isjust a safety mechanism(in these cases base64 data or xmlrpc. Binary values should be returned instead by the function field. In a future version we should probably switch to using XMLRPC Binary types always for passing fields.binary values, but this requires more refactoring. lp bug: https://launchpad.net/bugs/670778 fixed bzr revid: odo@openerp.com-20101209230742-gwf8e4zvmk43k6ln --- bin/osv/fields.py | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/bin/osv/fields.py b/bin/osv/fields.py index 135296779b1..423bd9cf1d1 100644 --- a/bin/osv/fields.py +++ b/bin/osv/fields.py @@ -33,12 +33,12 @@ # import datetime as DT import string -import netsvc import sys import warnings - +import xmlrpclib from psycopg2 import Binary +import netsvc import tools from tools.translate import _ @@ -673,6 +673,37 @@ def get_nice_size(a): size = 0 return (x, tools.human_size(size)) +def sanitize_binary_value(dict_item): + # binary fields should be 7-bit ASCII base64-encoded data, + # but we do additional sanity checks to make sure the values + # will are not something else that won't pass via xmlrpc + index, value = dict_item + if isinstance(value, (xmlrpclib.Binary, tuple, list, dict)): + # these builtin types are meant to pass untouched + return index, value + + # For all other cases, handle the value as a binary string: + # it could be a 7-bit ASCII string (e.g base64 data), but also + # any 8-bit content from files, with byte values that cannot + # be passed inside XML! + # See for more info: + # - http://bugs.python.org/issue10066 + # - http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char + # + # One solution is to convert the byte-string to unicode, + # so it gets serialized as utf-8 encoded data (always valid XML) + # If invalid XML byte values were present, tools.ustr() uses + # the Latin-1 codec as fallback, which converts any 8-bit + # byte value, resulting in valid utf-8-encoded bytes + # in the end: + # >>> unicode('\xe1','latin1').encode('utf8') == '\xc3\xa1' + # Note: when this happens, decoding on the other endpoint + # is not likely to produce the expected output, but this is + # just a safety mechanism (in these cases base64 data or + # xmlrpc.Binary values should be used instead + return index, tools.ustr(value) + + # --------------------------------------------------------- # Function fields # --------------------------------------------------------- @@ -763,9 +794,13 @@ class function(_column): if res[r] and res[r] in dict_names: res[r] = (res[r], dict_names[res[r]]) - if self._type == 'binary' and context.get('bin_size', False): - # convert the data returned by the function with the size of that data... - res = dict(map( get_nice_size, res.items())) + if self._type == 'binary': + if context.get('bin_size', False): + # client requests only the size of binary fields + res = dict(map(get_nice_size, res.items())) + else: + res = dict(map(sanitize_binary_value, res.items())) + if self._type == "integer": for r in res.keys(): # Converting value into string so that it does not affect XML-RPC Limits From ff1d7c720968ad4b006e3a6eed7c32d7084cc454 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 10 Dec 2010 01:35:57 +0100 Subject: [PATCH 5/5] [FIX] account: P&L and BS reports should properly compute the IDs passed to set_context() Now that the server uses the objects passed to the report to determine the company, these reports were failing, due to the peculiar way they pass IDs between the wizard and report. Hopefully there are no other reports that need the same fix. bzr revid: odo@openerp.com-20101210003557-pbaj9s1607zuof3j --- addons/account/report/account_balance_sheet.py | 7 +++++++ addons/account/report/account_profit_loss.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/addons/account/report/account_balance_sheet.py b/addons/account/report/account_balance_sheet.py index b6f39fbbebd..db75eff0dcf 100644 --- a/addons/account/report/account_balance_sheet.py +++ b/addons/account/report/account_balance_sheet.py @@ -60,6 +60,13 @@ class report_balancesheet_horizontal(report_sxw.rml_parse, common_report_header) }) self.context = context + def set_context(self, objects, data, ids, report_type=None): + new_ids = ids + if (data['model'] == 'ir.ui.menu'): + new_ids = 'chart_account_id' in data['form'] and [data['form']['chart_account_id']] or [] + objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) + return super(report_balancesheet_horizontal, self).set_context(objects, data, new_ids, report_type=report_type) + def sum_dr(self): if self.res_bl['type'] == _('Net Profit'): self.result_sum_dr += self.res_bl['balance']*-1 diff --git a/addons/account/report/account_profit_loss.py b/addons/account/report/account_profit_loss.py index 117f9e351fb..9198edf7105 100644 --- a/addons/account/report/account_profit_loss.py +++ b/addons/account/report/account_profit_loss.py @@ -56,6 +56,13 @@ class report_pl_account_horizontal(report_sxw.rml_parse, common_report_header): }) self.context = context + def set_context(self, objects, data, ids, report_type=None): + new_ids = ids + if (data['model'] == 'ir.ui.menu'): + new_ids = 'chart_account_id' in data['form'] and [data['form']['chart_account_id']] or [] + objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) + return super(report_pl_account_horizontal, self).set_context(objects, data, new_ids, report_type=report_type) + def final_result(self): return self.res_pl