[IMP][ADD] account: added leveling and calculating balance of view type of account...
authorvra <vra@tinyerp.com>
Tue, 21 Sep 2010 09:38:57 +0000 (15:08 +0530)
committervra <vra@tinyerp.com>
Tue, 21 Sep 2010 09:38:57 +0000 (15:08 +0530)
bzr revid: vra@tinyerp.com-20100921093857-e2k9aiywzl2sr0zb

addons/account/report/account_general_ledger.py
addons/account/report/account_general_ledger.rml
addons/account/report/account_general_ledger_landscape.rml

index f313704..d8ab573 100644 (file)
@@ -44,6 +44,15 @@ class general_ledger(rml_parse.rml_parse, common_report_header):
         self.init_balance = data['form']['initial_balance']
         self.display_account = data['form']['display_account']
         self.target_move = data['form'].get('target_move', 'all')
+        ctx = self.context.copy()
+        ctx['fiscalyear'] = data['form']['fiscalyear_id']
+        if data['form']['filter'] == 'filter_period':
+            ctx['periods'] = data['form']['periods']
+        elif data['form']['filter'] == 'filter_date':
+            ctx['date_from'] = data['form']['date_from']
+            ctx['date_to'] =  data['form']['date_to']
+        ctx['state'] = data['form']['target_move']
+        self.context.update(ctx)
         if (data['model'] == 'ir.ui.menu'):
             new_ids = [data['form']['chart_account_id']]
             objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids)
@@ -93,7 +102,7 @@ class general_ledger(rml_parse.rml_parse, common_report_header):
     def get_children_accounts(self, account):
         res = []
         ids_acc = self.pool.get('account.account')._get_children_and_consol(self.cr, self.uid, account.id)
-        for child_account in self.pool.get('account.account').browse(self.cr, self.uid, ids_acc):
+        for child_account in self.pool.get('account.account').browse(self.cr, self.uid, ids_acc, context=self.context):
             sql = """
                 SELECT count(id)
                 FROM account_move_line AS l
@@ -203,6 +212,8 @@ class general_ledger(rml_parse.rml_parse, common_report_header):
         return res
 
     def _sum_debit_account(self, account):
+        if account.type == 'view':
+            return account.debit
         move_state = ['draft','posted']
         if self.target_move == 'posted':
             move_state = ['posted','']
@@ -227,6 +238,8 @@ class general_ledger(rml_parse.rml_parse, common_report_header):
         return sum_debit
 
     def _sum_credit_account(self, account):
+        if account.type == 'view':
+            return account.credit
         move_state = ['draft','posted']
         if self.target_move == 'posted':
             move_state = ['posted','']
@@ -251,6 +264,8 @@ class general_ledger(rml_parse.rml_parse, common_report_header):
         return sum_credit
 
     def _sum_balance_account(self, account):
+        if account.type == 'view':
+            return account.balance
         move_state = ['draft','posted']
         if self.target_move == 'posted':
             move_state = ['posted','']
index ba1a353..5a38122 100644 (file)
           <td>
           <blockTable colWidths="245.0,92.5,66.5,64.5,71.5" style="Table5">
       <tr>
-        <td><para style="Standard">[[ o.code or '']] [[ o.name or '']]</para></td>
+        <td><para style="Standard"><font color="white">[[ '..'*(o.level-1) ]]</font>[[ o.code or '']] [[ o.name or '']]</para></td>
         <td><para style="Standard"></para></td>
         <td alignment="right"><para style="P9b"><u>[[formatLang(sum_debit_account(o)) ]]</u></para></td>
         <td alignment="right"><para style="P9b"><u>[[formatLang(sum_credit_account(o)) ]] </u></para></td>
           <td>
           <blockTable colWidths="230.00,74.0,55.5,60.5,60.5,65.5" style="Table5">
               <tr>
-                <td><para style="Standard">[[ o.code or '' ]] [[ o.name or '' ]]</para></td>
+                <td><para style="Standard"><font color="white">[[ '..'*(o.level-1) ]]</font>[[ o.code or '' ]] [[ o.name or '' ]]</para></td>
                 <td><para style="Standard"></para></td>
                 <td alignment="right"><para style="P9b"><u>[[formatLang(sum_debit_account(o)) ]]</u></para></td>
                 <td alignment="right"><para style="P9b"><u>[[formatLang(sum_credit_account(o)) ]]</u></para></td>
index e1bb6ae..80a55c7 100644 (file)
                <td>
                        <blockTable colWidths="404.0,335.0,75.0,75.0,75.0,79.00" style="Table5">
                                <tr>
-                                       <td><para style="Standard">[[ o.code ]] [[ o.name ]]</para></td>
+                                       <td><para style="Standard"><font color="white">[[ '..'*(o.level-1) ]]</font>[[ o.code ]] [[ o.name ]]</para></td>
                                        <td><para style="Standard"></para></td>
                                                <td alignment="right"><para style="P9b"><u>[[formatLang(sum_debit_account(o)) ]]</u></para></td>
                                                <td alignment="right"><para style="P9b"><u>[[formatLang(sum_credit_account(o)) ]]</u></para></td>
                        <td>
                                <blockTable colWidths="405.0,435.0,69.0,72.0,64.0" style="Table5">
                                                <tr>
-                                                       <td><para style="Standard">[[ o.code ]] [[ o.name ]]</para></td>
+                                                       <td><para style="Standard"><font color="white">[[ '..'*(o.level-1) ]]</font>[[ o.code ]] [[ o.name ]]</para></td>
                                                        <td><para style="Standard"></para></td>
                                                        <td alignment="right"><para style="P9b"><u>[[formatLang(sum_debit_account(o)) ]]</u></para></td>
                                                        <td alignment="right"><para style="P9b"><u>[[formatLang(sum_credit_account(o)) ]]</u></para></td>