[FIX] account: bank statement reconciliation: when fetching moves lines for reconciliation, if lines from the same partial reconciliation are filtered out, keep fetching to returne the correct number of lines
This commit is contained in:
parent
1127024eb5
commit
0a7fd6a943
|
@ -602,22 +602,33 @@ class account_bank_statement_line(osv.osv):
|
|||
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)
|
||||
# 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
|
||||
filtered_lines.append(line)
|
||||
if line.reconcile_partial_id:
|
||||
reconcile_partial_ids.append(line.reconcile_partial_id.id)
|
||||
|
||||
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:
|
||||
nb_lines = 0
|
||||
reconcile_partial_ids = [] # for a partial reconciliation, take only one line
|
||||
for line in lines:
|
||||
if line.reconcile_partial_id and line.reconcile_partial_id.id in reconcile_partial_ids:
|
||||
continue
|
||||
nb_lines += 1
|
||||
if line.reconcile_partial_id:
|
||||
reconcile_partial_ids.append(line.reconcile_partial_id.id)
|
||||
return nb_lines
|
||||
return len(lines)
|
||||
|
||||
# Or return list of dicts representing the formatted move lines
|
||||
else:
|
||||
|
|
|
@ -766,15 +766,11 @@ class account_move_line(osv.osv):
|
|||
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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue