From 1a826e07fe61b8e55291f207da81eddf55baf14b Mon Sep 17 00:00:00 2001 From: Samus CTO Date: Thu, 13 Nov 2014 16:23:08 +0100 Subject: [PATCH] [IMP] Speedup test account_assert_test.xml in account --- addons/account/account.py | 13 +++++++++++++ addons/account/account_assert_test.xml | 4 +--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index a12b5bd1052..c1aca3ee8ec 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1157,6 +1157,19 @@ class account_move(osv.osv): _description = "Account Entry" _order = 'id desc' + def account_assert_balanced(self, cr, uid, context=None): + cr.execute("""\ + SELECT move_id + FROM account_move_line + WHERE state = 'valid' + GROUP BY move_id + HAVING abs(sum(debit) - sum(credit)) > 0.00001 + """) + assert len(cr.fetchall()) == 0, \ + "For all Journal Items, the state is valid implies that the sum " \ + "of credits equals the sum of debits" + return True + def account_move_prepare(self, cr, uid, journal_id, date=False, ref='', company_id=False, context=None): ''' Prepares and returns a dictionary of values, ready to be passed to create() based on the parameters received. diff --git a/addons/account/account_assert_test.xml b/addons/account/account_assert_test.xml index 88025514763..32e8afb1b50 100644 --- a/addons/account/account_assert_test.xml +++ b/addons/account/account_assert_test.xml @@ -1,8 +1,6 @@ - - - +