From f110a5382c9ed203c83497e810dafcfedea8b4c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 10 Apr 2008 15:48:35 +0200 Subject: [PATCH 1/4] Add missing field to allow to use Function with type one2many --- trytond/osv/fields.py | 1 + 1 file changed, 1 insertion(+) diff --git a/trytond/osv/fields.py b/trytond/osv/fields.py index 65f1af8578..92bbe76a16 100644 --- a/trytond/osv/fields.py +++ b/trytond/osv/fields.py @@ -563,6 +563,7 @@ class Function(Column): self._fnct = fnct self._fnct_inv = fnct_inv self._arg = arg + self._field = '' self._obj = '' if 'relation' in args: self._obj = args['relation'] From 332efe2357f6303af3127b2cf7d9de5c11c11128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 10 Apr 2008 15:49:03 +0200 Subject: [PATCH 2/4] Add traceback on programming error --- trytond/osv/orm.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/trytond/osv/orm.py b/trytond/osv/orm.py index ddd776c93c..a56d5d5dc4 100644 --- a/trytond/osv/orm.py +++ b/trytond/osv/orm.py @@ -7,6 +7,7 @@ import fields from trytond.tools import Cache import md5 import time +import traceback ID_MAX = 1000 @@ -75,10 +76,11 @@ class BrowseRecord(object): return getattr(self._table, name) else: logger = Logger() + stack = ''.join(traceback.format_stack()) logger.notify_channel('orm', LOG_ERROR, "Programming error: field '%s' " \ - "does not exist in object '%s'!" % \ - (name, self._table._name)) + "does not exist in object '%s'!\n%s" % \ + (name, self._table._name, stack)) return False # if the field is a classic one or a many2one, From cd21270d385f4c9b75b180e0a55539b2a68c53b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 10 Apr 2008 15:49:21 +0200 Subject: [PATCH 3/4] Add traceback on workflow exception --- trytond/osv/osv.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/trytond/osv/osv.py b/trytond/osv/osv.py index 9cdb54795e..04f6fb0d49 100644 --- a/trytond/osv/osv.py +++ b/trytond/osv/osv.py @@ -7,6 +7,7 @@ import copy import sys from psycopg2 import IntegrityError from trytond.tools import UpdateableDict +import traceback MODULE_LIST = [] MODULE_CLASS_LIST = {} @@ -61,7 +62,6 @@ class OSVService(Service): self._sql_error[key]) self.abort_response('Integrity Error', 'warning', inst[0]) except: - import traceback tb_s = reduce(lambda x, y: x+y, traceback.format_exception( sys.exc_type, sys.exc_value, sys.exc_traceback)) logger = Logger() @@ -87,7 +87,26 @@ class OSVService(Service): def exec_workflow_cr(self, cursor, user, object_name, method, *args): wf_service = LocalService("workflow") - wf_service.trg_validate(user, object_name, args[0], method, cursor) + try: + wf_service.trg_validate(user, object_name, args[0], method, cursor) + except ExceptORM, inst: + self.abort_response(inst.name, 'warning', inst.value) + except ExceptOSV, inst: + self.abort_response(inst.name, inst.exc_type, inst.value) + except IntegrityError, inst: + for key in self._sql_error.keys(): + if key in inst[0]: + self.abort_response('Constraint Error', 'warning', + self._sql_error[key]) + self.abort_response('Integrity Error', 'warning', inst[0]) + + except: + tb_s = reduce(lambda x, y: x+y, traceback.format_exception( + sys.exc_type, sys.exc_value, sys.exc_traceback)) + logger = Logger() + logger.notify_channel("web-services", LOG_ERROR, + 'Exception in call: \n' + tb_s) + raise return True def exec_workflow(self, dbname, user, object_name, method, *args): From 13efc50e708a2e22dae084a5e78e5558b07e3b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 10 Apr 2008 16:02:09 +0200 Subject: [PATCH 4/4] Fix non-ascii string in report --- trytond/report/report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trytond/report/report.py b/trytond/report/report.py index b509f077c3..c5bd7ee415 100644 --- a/trytond/report/report.py +++ b/trytond/report/report.py @@ -287,7 +287,7 @@ class Report(object): if hasattr(res, '__str__'): res = res.__str__() if isinstance(res, basestring): - node.nodeValue = res + node.nodeValue = res.decode('utf-8') node.parentNode.parentNode.replaceChild(node, node.parentNode) return res if 'language' in localcontext: