~camptocamp/c2c-financial-addons/trunk

« back to all changes in this revision

Viewing changes to account_financial_report_webkit/report/partners_ledger.py

  • Committer: Guewen Baconnier @ Camptocamp
  • Date: 2012-09-11 14:15:00 UTC
  • mfrom: (19.1.64 6.1)
  • Revision ID: guewen.baconnier@camptocamp.com-20120911141500-8tzx2kk7209eq5gu
[MRG] Merged branch with the fixes for the most recent bugs found:

 * Partner balance (in standalone mode, without comparison):
   the partners with a final balance of 0.0 were hidden,
   they must be displayed because we need also, at least their initial balance,
   so we can compare with the preceding year. The debit / credit can be useful too.

 * All partners' reports:
   we can not rely on the entries generated by OpenERP in the opening period for the parters,
   so we force the computation of the initial balance based on the previous fiscal years.
   (previously, we were displaying the entries of the opening period if there
   was at least one, otherwise we were computing it).

 * The computed initial balance was wrong when the opening period
   of the very first fiscal year had entries.
   The entries of the opening periods have to be excluded from the initial balances,
   excepted for this case, because they do not have any counterpart the preceding year.

Show diffs side-by-side

added added

removed removed

Lines of Context:
127
127
        init_balance = main_filter in ('filter_no', 'filter_period')
128
128
        initial_balance_mode = init_balance and self._get_initial_balance_mode(start) or False
129
129
 
130
 
        init_balance_memoizer = {}
 
130
        initial_balance_lines = {}
131
131
        if initial_balance_mode == 'initial_balance':
132
 
            init_balance_memoizer = self._compute_partners_initial_balances(accounts,
 
132
            initial_balance_lines = self._compute_partners_initial_balances(accounts,
133
133
                                                                            start_period,
134
134
                                                                            partner_filter=partner_ids,
135
135
                                                                            exclude_reconcile=False)
136
136
 
137
 
        ledger_lines_memoizer = self._compute_partner_ledger_lines(accounts,
138
 
                                                                   main_filter,
139
 
                                                                   target_move,
140
 
                                                                   start,
141
 
                                                                   stop,
142
 
                                                                   partner_filter=partner_ids)
 
137
        ledger_lines = self._compute_partner_ledger_lines(accounts,
 
138
                                                          main_filter,
 
139
                                                          target_move,
 
140
                                                          start,
 
141
                                                          stop,
 
142
                                                          partner_filter=partner_ids)
143
143
        objects = []
144
144
        for account in self.pool.get('account.account').browse(self.cursor, self.uid, accounts):
145
 
            account.ledger_lines = ledger_lines_memoizer.get(account.id, {})
146
 
            account.init_balance = init_balance_memoizer.get(account.id, {})
 
145
            account.ledger_lines = ledger_lines.get(account.id, {})
 
146
            account.init_balance = initial_balance_lines.get(account.id, {})
147
147
            ## we have to compute partner order based on inital balance
148
148
            ## and ledger line as we may have partner with init bal
149
149
            ## that are not in ledger line and vice versa
150
 
            ledg_lines_pids = ledger_lines_memoizer.get(account.id, {}).keys()
 
150
            ledg_lines_pids = ledger_lines.get(account.id, {}).keys()
151
151
            if initial_balance_mode:
152
152
                non_null_init_balances = dict([(ib, amounts) for ib, amounts in account.init_balance.iteritems()
153
153
                                                             if amounts['init_balance'] or amounts['init_balance_currency']])
157
157
                init_bal_lines_pids = []
158
158
 
159
159
            account.partners_order = self._order_partners(ledg_lines_pids, init_bal_lines_pids)
160
 
            account.ledger_lines = ledger_lines_memoizer.get(account.id, {})
161
160
            objects.append(account)
162
161
 
163
162
        self.localcontext.update({
184
183
                                                             stop,
185
184
                                                             target_move,
186
185
                                                             exclude_reconcile=False,
187
 
                                                             partner_filter=partner_filter,
188
 
                                                             opening_mode='exclude_opening')
 
186
                                                             partner_filter=partner_filter)
189
187
            if not move_line_ids:
190
188
                continue
191
189
            for partner_id in move_line_ids: