[IMP] Account: Add method on account move line => which unlink related reconcile ids for moves, Use that method on unreconcile wizard as well as fiscalyear closing with generating entries
bzr revid: mra@mra-laptop-20100907050352-07x1e8yxb9d8jlcm
This commit is contained in:
parent
ec4865d167
commit
42e8cd0749
|
@ -965,6 +965,24 @@ class account_move_line(osv.osv):
|
|||
'has been confirmed!') % res[2])
|
||||
return res
|
||||
|
||||
def _remove_move_reconcile(self, cr, uid, move_ids=[], context=None):
|
||||
# Function remove move rencocile ids related with moves
|
||||
obj_move_line = self.pool.get('account.move.line')
|
||||
obj_move_rec = self.pool.get('account.move.reconcile')
|
||||
unlink_ids = []
|
||||
if not move_ids:
|
||||
return True
|
||||
recs = obj_move_line.read(cr, uid, move_ids, ['reconcile_id','reconcile_partial_id'])
|
||||
full_recs = filter(lambda x: x['reconcile_id'], recs)
|
||||
rec_ids = [rec['reconcile_id'][0] for rec in full_recs]
|
||||
part_recs = filter(lambda x: x['reconcile_partial_id'], recs)
|
||||
part_rec_ids = [rec['reconcile_partial_id'][0] for rec in part_recs]
|
||||
unlink_ids += rec_ids
|
||||
unlink_ids += part_rec_ids
|
||||
if len(unlink_ids):
|
||||
obj_move_rec.unlink(cr, uid, unlink_ids)
|
||||
return True
|
||||
|
||||
def unlink(self, cr, uid, ids, context={}, check=True):
|
||||
self._update_check(cr, uid, ids, context)
|
||||
result = False
|
||||
|
|
|
@ -86,17 +86,9 @@ class account_fiscalyear_close(osv.osv_memory):
|
|||
|
||||
move_ids = obj_acc_move_line.search(cr, uid, [
|
||||
('journal_id', '=', new_journal.id), ('period_id.fiscalyear_id', '=', new_fyear.id)])
|
||||
|
||||
if move_ids:
|
||||
recs = obj_acc_move_line.read(cr, uid, move_ids, ['reconcile_id', 'reconcile_partial_id'])
|
||||
unlink_ids = []
|
||||
full_recs = filter(lambda x: x['reconcile_id'], recs)
|
||||
rec_ids = [rec['reconcile_id'][0] for rec in full_recs]
|
||||
part_recs = filter(lambda x: x['reconcile_partial_id'], recs)
|
||||
part_rec_ids = [rec['reconcile_partial_id'][0] for rec in part_recs]
|
||||
unlink_ids += rec_ids
|
||||
unlink_ids += part_rec_ids
|
||||
if len(unlink_ids):
|
||||
obj_rec.unlink(cr, uid, unlink_ids)
|
||||
obj_acc_move_line._remove_move_reconcile(cr, uid, move_ids, context=context)
|
||||
obj_acc_move_line.unlink(cr, uid, move_ids, context=context)
|
||||
|
||||
cr.execute("SELECT id FROM account_fiscalyear WHERE date_stop < %s", (str(new_fyear.date_start),))
|
||||
|
|
|
@ -29,16 +29,8 @@ class account_unreconcile(osv.osv_memory):
|
|||
obj_move_line = self.pool.get('account.move.line')
|
||||
if context is None:
|
||||
context = {}
|
||||
recs = obj_move_line.read(cr, uid, context['active_ids'], ['reconcile_id','reconcile_partial_id'])
|
||||
unlink_ids = []
|
||||
full_recs = filter(lambda x: x['reconcile_id'], recs)
|
||||
rec_ids = [rec['reconcile_id'][0] for rec in full_recs]
|
||||
part_recs = filter(lambda x: x['reconcile_partial_id'], recs)
|
||||
part_rec_ids = [rec['reconcile_partial_id'][0] for rec in part_recs]
|
||||
unlink_ids += rec_ids
|
||||
unlink_ids += part_rec_ids
|
||||
if len(unlink_ids):
|
||||
self.pool.get('account.move.reconcile').unlink(cr, uid, unlink_ids)
|
||||
if context.get('active_ids', False):
|
||||
obj_move_line._remove_move_reconcile(cr, uid, context['active_ids'], context=context)
|
||||
return {}
|
||||
|
||||
account_unreconcile()
|
||||
|
|
Loading…
Reference in New Issue