From ccb8e533211109281e1d651683d80eed5010bc27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 5 Dec 2008 17:14:51 +0100 Subject: [PATCH] Call first check_root with all ids and if there is an error search for the wrong line --- purchase.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/purchase.py b/purchase.py index 25ed396801..ce28904769 100644 --- a/purchase.py +++ b/purchase.py @@ -24,13 +24,15 @@ class Purchase(OSV): purchase_id, context=context) purchase = self.browse(cursor, user, purchase_id, context=context) - for line in purchase.lines: - if not account_selection_obj.check_root(cursor, user, - [line.analytic_accounts.id]): - line_name = purchase_line_obj.name_get(cursor, user, - line.id, context=context)[0][1] - self.raise_user_error(cursor, 'analytic_account_required', - (line_name, line.id), context=context) + if not account_selection_obj.check_root(cursor, user, + [x.analytic_accounts.id for x in purchase.lines]): + for line in purchase.lines: + if not account_selection_obj.check_root(cursor, user, + [line.analytic_accounts.id]): + line_name = purchase_line_obj.name_get(cursor, user, + line.id, context=context)[0][1] + self.raise_user_error(cursor, 'analytic_account_required', + (line_name, line.id), context=context) return res Purchase()