From a7255c25cf0c178eb3b3a0182d39133ffd02e729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 12 Mar 2013 10:41:05 +0100 Subject: [PATCH] Fix check_for_quotation as check_root always returns None issue3052 review705003 --- purchase.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/purchase.py b/purchase.py index 6dc1ad963a..08d7f65336 100644 --- a/purchase.py +++ b/purchase.py @@ -4,6 +4,7 @@ from trytond.model import fields from trytond.pyson import Eval from trytond.transaction import Transaction from trytond.pool import Pool, PoolMeta +from trytond.exceptions import UserError __all__ = ['Purchase', 'PurchaseLine', 'Account'] __metaclass__ = PoolMeta @@ -25,15 +26,20 @@ class Purchase: super(Purchase, self).check_for_quotation() - if not AccountSelection.check_root( + try: + AccountSelection.check_root( [x.analytic_accounts for x in self.lines - if x.analytic_accounts]): + if x.analytic_accounts]) + except UserError: for line in self.lines: if line.type != 'line': continue - if not AccountSelection.check_root([line.analytic_accounts]): + try: + AccountSelection.check_root([line.analytic_accounts]) + except UserError: self.raise_user_error('analytic_account_required', (line.rec_name,)) + raise class PurchaseLine: