[IMP] improved description of consistency test, code help and removed unused function...
authorBharat Devnani (OpenERP) <bde@tinyerp.com>
Tue, 27 Nov 2012 09:49:11 +0000 (15:19 +0530)
committerBharat Devnani (OpenERP) <bde@tinyerp.com>
Tue, 27 Nov 2012 09:49:11 +0000 (15:19 +0530)
bzr revid: bde@tinyerp.com-20121127094911-rnidlbk1obfc48tm

addons/account_test/account_test_data.xml
addons/account_test/account_test_demo.xml
addons/account_test/account_test_view.xml
addons/account_test/report/account_test_report.py

index 415664b..2a23c11 100644 (file)
@@ -22,8 +22,7 @@ if res[0]['balance']!=0.0 and res[0]['balance'] is not None:
     <record model="accounting.assert.test" id="account_test_02">
         <field name="sequence">2</field>
         <field name="name">Test 2: Opening a fiscal year</field>
-        <!--TODO : bad description of the test, does not really match what the SQL querry does, should adapt description name -->
-        <field name="desc">Check if the balance of the new opened fiscal year matches with last year's balance</field>
+        <field name="desc">Displays the debit and credit amount, of closed and newly created fiscal year, if the balance of current and newly created fiscal year mismatch</field>
         <field name="code_exec"><![CDATA[result = []
 cr.execute("select coalesce(sum(debit),0) as debit_new_fyear,coalesce(sum(credit),0) as credit_new_fyear from account_move_line where period_id in (select id from account_period where state='draft' and special order by id desc limit 1);")
 rec =  cr.dictfetchall()
index a342040..7dd5c0f 100644 (file)
@@ -3,9 +3,9 @@
 <data>
 
     <record model="accounting.assert.test" id="account_test_demo_01">
-      <!-- TODO : change name and desc -->
-        <field name="name">Test 1</field>
-        <field name="desc">Test 1</field>
+        <field name="sequence">11</field>
+        <field name="name">Test 11: Consistency check between Account Move and Account Move Line</field>
+        <field name="desc">Checks id of 'account_move' = move_id of 'account_move_line', and state of 'account_move_line' is valid, and having sum(debit-credit) != 0</field>
         <field name="domain_exec"></field>
         <field name="code_exec"><![CDATA[sql="""SELECT
     sum(debit) as sum_debit,
index 848d04c..46f02d8 100644 (file)
                                     <field colspan="4" name="code_exec" nolabel="1"/>
                                 </group>
                                 <group string="Code Help">
-                                    <!--TODO : better explanation on how to write those test, especially on variable result that must be present or
-                                    we won't see the result of the tests good or bad, give detail on function that can be used, like 
-                                    'group(a,b)' 'reconciled_inv()' 'get_parent(a)' 'now()' ... -->
                                     <pre>
+You can write a query in order to create Consistency Test and you will get the result of the test 
+in PDF format which can be accessed by Menu Reporting -> Accounting Tests, then select the test 
+and print the report from Print button in header area.
+
+You can also use the following functions:
+
+get_parent(acc_id) : return parent id of analytic account(acc_id)
+reconciled_inv() : returns ids of records which are reconciled
+    
 Example: 
 sql = 'select id, name, ref, date from account_move_line where account_id in 
 (select id from account_account where type = 'view')'
index 5c27477..f8ba7a4 100644 (file)
@@ -43,16 +43,6 @@ class report_assert_account(report_sxw.rml_parse):
         def group(lst, col):
             return dict((k, [v for v in itr]) for k, itr in groupby(sorted(lst, key=lambda x: x[col]), itemgetter(col)))
 
-        #TODO what is this method used for, name unclear and doesn't seem to be used
-        def sort_by_intified_num(a, b):
-            if a is None:
-                return -1
-            elif b is None:
-                return 1
-            else:
-                #if a is not None and b is not None:
-                return cmp(int(a), int(b))
-
         def reconciled_inv():
             reconciled_inv_ids = self.pool.get('account.invoice').search(self.cr, self.uid, [('reconciled','=',True)])
             return reconciled_inv_ids
@@ -86,12 +76,8 @@ class report_assert_account(report_sxw.rml_parse):
 
         if not isinstance(result, (tuple, list, set)):
             result = [result]
-
         if not result:
             result = [_('The test was passed successfully')]
-        #TODO: not sure this condition is needed, it is only a subcategory of the final else
-        elif all([isinstance(x, dict) for x in result]):
-            result = [', '.join(["%s: %s" % (k, v) for k, v in order_columns(rec, column_order)]) for rec in result]
         else:
             def _format(a):
                 if isinstance(a, dict):