Skip to content

Commit

Permalink
[FIX] account: bank statement reconciliation: when fetching moves lin…
Browse files Browse the repository at this point in the history
…es for reconciliation, if lines from the same partial reconciliation are filtered out, keep fetching to returne the correct number of lines
  • Loading branch information
Whisno committed Sep 17, 2014
1 parent 1127024 commit 0a7fd6a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
33 changes: 22 additions & 11 deletions addons/account/account_bank_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,22 +602,33 @@ def get_move_lines_for_reconciliation(self, cr, uid, st_line, excluded_ids=None,
domain.insert(-1, '|', )
domain.append(('partner_id.name', 'ilike', str))


# Get move lines
line_ids = mv_line_pool.search(cr, uid, domain, offset=offset, limit=limit, order="date_maturity asc, id asc", context=context)
lines = mv_line_pool.browse(cr, uid, line_ids, context=context)

# Either return number of lines
if count:
nb_lines = 0
reconcile_partial_ids = [] # for a partial reconciliation, take only one line
# Get move lines ; in case of a partial reconciliation, only consider one line
filtered_lines = []
reconcile_partial_ids = []
shift = 0
while True:
actual_offset = offset and offset+limit*shift or offset
actual_limit = limit and limit+limit*shift or limit
line_ids = mv_line_pool.search(cr, uid, domain, offset=actual_offset, limit=actual_limit, order="date_maturity asc, id asc", context=context)
lines = mv_line_pool.browse(cr, uid, line_ids, context=context)

did_filter_out_lines = False
for line in lines:
if line.reconcile_partial_id and line.reconcile_partial_id.id in reconcile_partial_ids:
did_filter_out_lines = True
continue
nb_lines += 1
filtered_lines.append(line)
if line.reconcile_partial_id:
reconcile_partial_ids.append(line.reconcile_partial_id.id)
return nb_lines

if not limit or not did_filter_out_lines or len(filtered_lines) >= limit:
break
shift += 1
lines = limit and filtered_lines[:limit] or filtered_lines

# Either return number of lines
if count:
return len(lines)

# Or return list of dicts representing the formatted move lines
else:
Expand Down
4 changes: 0 additions & 4 deletions addons/account/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,15 +766,11 @@ def prepare_move_lines_for_reconciliation_widget(self, cr, uid, lines, target_cu
currency_obj = self.pool.get('res.currency')
company_currency = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id
rml_parser = report_sxw.rml_parse(cr, uid, 'reconciliation_widget_aml', context=context)
reconcile_partial_ids = [] # for a partial reconciliation, take only one line
ret = []

for line in lines:
if line.reconcile_partial_id and line.reconcile_partial_id.id in reconcile_partial_ids:
continue
partial_reconciliation_siblings_ids = []
if line.reconcile_partial_id:
reconcile_partial_ids.append(line.reconcile_partial_id.id)
partial_reconciliation_siblings_ids = self.search(cr, uid, [('reconcile_partial_id', '=', line.reconcile_partial_id.id)], context=context)
partial_reconciliation_siblings_ids.remove(line.id)

Expand Down

0 comments on commit 0a7fd6a

Please sign in to comment.