[FIX] Account : In bank statements,Move Lines should be imported only once
lp bug: https://launchpad.net/bugs/434628 fixed bzr revid: jvo@tinyerp.com-20091214065305-y3qnf11gkb09robr
This commit is contained in:
parent
e0a39bb115
commit
2b77d8c401
|
@ -58,15 +58,35 @@ def _search_invoices(obj, cr, uid, data, context):
|
|||
journal_obj = pool.get('account.journal')
|
||||
|
||||
statement = statement_obj.browse(cr, uid, data['id'], context=context)
|
||||
args_move_line = []
|
||||
repeated_move_line_ids = []
|
||||
# Creating a group that is unique for importing move lines(move lines, once imported into statement lines, should not appear again)
|
||||
for st_line in statement.line_ids:
|
||||
args_move_line = []
|
||||
args_move_line.append(('name','=', st_line.name))
|
||||
args_move_line.append(('ref','=',st_line.ref))
|
||||
if st_line.partner_id:
|
||||
args_move_line.append(('partner_id','=',st_line.partner_id.id))
|
||||
args_move_line.append(('account_id','=',st_line.account_id.id))
|
||||
|
||||
move_line_id = line_obj.search(cr, uid, args_move_line,context=context)
|
||||
if move_line_id:
|
||||
repeated_move_line_ids.append(move_line_id)
|
||||
|
||||
journal_ids = data['form']['journal_id'][0][2]
|
||||
|
||||
if journal_ids == []:
|
||||
journal_ids = journal_obj.search(cr, uid, [('type', 'in', ('sale','cash','purchase'))], context=context)
|
||||
|
||||
line_ids = line_obj.search(cr, uid, [
|
||||
|
||||
args = [
|
||||
('reconcile_id', '=', False),
|
||||
('journal_id', 'in', journal_ids),
|
||||
('account_id.reconcile', '=', True)],
|
||||
('account_id.reconcile', '=', True)]
|
||||
|
||||
if repeated_move_line_ids:
|
||||
args.append(('id','not in',repeated_move_line_ids))
|
||||
|
||||
line_ids = line_obj.search(cr, uid, args,
|
||||
#order='date DESC, id DESC', #doesn't work
|
||||
context=context)
|
||||
|
||||
|
|
Loading…
Reference in New Issue