From 59342dce858888b76494c0c1a33670304d8d7a3c Mon Sep 17 00:00:00 2001 From: "uspallek@Lisa.dsl" Date: Thu, 2 Oct 2008 16:09:11 +0200 Subject: [PATCH 1/7] Added more information to AttributeError for better locating the errors source. --- trytond/osv/orm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trytond/osv/orm.py b/trytond/osv/orm.py index d57504d1b6..19f65c9e15 100644 --- a/trytond/osv/orm.py +++ b/trytond/osv/orm.py @@ -2142,7 +2142,7 @@ class ORM(object): raise AttributeError('Unknown position ' \ 'in inherited view %s!' % pos) else: - raise AttributeError('Couldn\'t find tag in parent view!') + raise AttributeError('Couldn\'t find tag (%s: %s) in parent view!' % (element2.tag, element2.get('expr'))) return etree.tostring(tree_src, encoding='utf-8') result = {'type': view_type, 'model': self._name} From 6d9e09ac3e2421cbab74c6d966d224e770d283f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 3 Oct 2008 00:59:51 +0200 Subject: [PATCH 2/7] Allow empty type for inherit view --- trytond/ir/ui/view.py | 1 + 1 file changed, 1 insertion(+) diff --git a/trytond/ir/ui/view.py b/trytond/ir/ui/view.py index 6a9bf270f0..0482ea82a5 100644 --- a/trytond/ir/ui/view.py +++ b/trytond/ir/ui/view.py @@ -15,6 +15,7 @@ class View(OSV): model = fields.Char('Model', required=True, select=1) priority = fields.Integer('Priority', required=True, select=1) type = fields.Selection([ + (False, ''), ('tree','Tree'), ('form','Form'), ('graph', 'Graph'), From 1a1e5baa9e3e02ba26f3034f7816d3fbc1a3e3f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 3 Oct 2008 01:00:13 +0200 Subject: [PATCH 3/7] Improve error message --- trytond/ir/ui/view.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trytond/ir/ui/view.py b/trytond/ir/ui/view.py index 0482ea82a5..9ddf7480e3 100644 --- a/trytond/ir/ui/view.py +++ b/trytond/ir/ui/view.py @@ -34,7 +34,7 @@ class View(OSV): ('check_xml', 'invalid_xml'), ] self._error_messages.update({ - 'invalid_xml': 'Invalid XML for View Architecture!', + 'invalid_xml': 'Invalid XML for View!', }) self._order.insert(0, ('priority', 'ASC')) From 8939fe0587fc7dc44259656c41b3a79b73260121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 3 Oct 2008 01:00:40 +0200 Subject: [PATCH 4/7] Add test for inherit view to have the same model than the inherited one --- trytond/ir/ui/view.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/trytond/ir/ui/view.py b/trytond/ir/ui/view.py index 9ddf7480e3..bf7f2e1c5f 100644 --- a/trytond/ir/ui/view.py +++ b/trytond/ir/ui/view.py @@ -64,6 +64,14 @@ class View(OSV): xml = view.arch.strip() tree = etree.fromstring(xml) + if view.inherit: + if view.model != view.inherit.model: + logger = logging.getLogger('ir') + logger.error('Invalid model "%s" ' \ + 'with inherited model "%"' % \ + (view.model, view.inherit.model)) + return False + # validate the tree using RelaxNG rng_name = os.path.join(os.path.dirname(__file__), (view.inherit and view.inherit.type or view.type) + '.rng') From 9e2f8b888cc79c8c15364e240f4f67b6b1042d1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 3 Oct 2008 01:02:02 +0200 Subject: [PATCH 5/7] Fix indent --- trytond/ir/ui/view.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/trytond/ir/ui/view.py b/trytond/ir/ui/view.py index bf7f2e1c5f..7519aba7ac 100644 --- a/trytond/ir/ui/view.py +++ b/trytond/ir/ui/view.py @@ -16,12 +16,12 @@ class View(OSV): priority = fields.Integer('Priority', required=True, select=1) type = fields.Selection([ (False, ''), - ('tree','Tree'), - ('form','Form'), - ('graph', 'Graph'), - ('calendar', 'Calendar'), - ('board', 'Board'), - ], 'View Type', select=1) + ('tree','Tree'), + ('form','Form'), + ('graph', 'Graph'), + ('calendar', 'Calendar'), + ('board', 'Board'), + ], 'View Type', select=1) arch = fields.Text('View Architecture', required=True) inherit = fields.Many2One('ir.ui.view', 'Inherited View', select=1, ondelete='CASCADE') From 734a9af2be4f146f15fedf2669c0a96c6ad9c4f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 3 Oct 2008 15:11:32 +0200 Subject: [PATCH 6/7] Catch exception when sending exception --- trytond/netsvc.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/trytond/netsvc.py b/trytond/netsvc.py index d24911343e..c4fd3e2074 100644 --- a/trytond/netsvc.py +++ b/trytond/netsvc.py @@ -295,7 +295,12 @@ class TinySocketClientThread(threading.Thread): import pdb tback = sys.exc_info()[2] pdb.post_mortem(tback) - pysocket.send(exception.args, exception=True, traceback=tb_s) + try: + pysocket.send(exception.args, exception=True, traceback=tb_s) + except: + pysocket.disconnect() + self.threads.remove(self) + return False pysocket.disconnect() self.threads.remove(self) return True From 076446573ea42e36e8def1e86639b4abec96df7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 5 Oct 2008 23:24:23 +0200 Subject: [PATCH 7/7] Use raise_user_error for exception about deleteing workflow record for issue413 --- trytond/ir/translation.xml | 9 +++++++++ trytond/osv/orm.py | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/trytond/ir/translation.xml b/trytond/ir/translation.xml index edde03c466..42cf666ddb 100644 --- a/trytond/ir/translation.xml +++ b/trytond/ir/translation.xml @@ -95,6 +95,15 @@ ir + + delete_workflow_record + en_US + error + You cannot delete a record with a running workflow. + You cannot delete a record with a running workflow. + ir + + ir.translation.set_report.init diff --git a/trytond/osv/orm.py b/trytond/osv/orm.py index 19f65c9e15..e40dba42f6 100644 --- a/trytond/osv/orm.py +++ b/trytond/osv/orm.py @@ -1406,8 +1406,8 @@ class ORM(object): "AND res_type = %s AND state != 'complete'", ids + [self._name]) if cursor.rowcount != 0: - raise Exception('UserError', - 'You cannot delete a record with a running workflow.') + self.raise_user_error(cursor, 'delete_workflow_record', + context=context) wf_service = LocalService("workflow") for obj_id in ids: