diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 9f19fa39183..04578cdd92b 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -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 diff --git a/addons/account/wizard/account_fiscalyear_close.py b/addons/account/wizard/account_fiscalyear_close.py index 76e7eaad974..d6d3b67c10e 100644 --- a/addons/account/wizard/account_fiscalyear_close.py +++ b/addons/account/wizard/account_fiscalyear_close.py @@ -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),)) diff --git a/addons/account/wizard/account_unreconcile.py b/addons/account/wizard/account_unreconcile.py index 671c9456819..1e647742f4a 100644 --- a/addons/account/wizard/account_unreconcile.py +++ b/addons/account/wizard/account_unreconcile.py @@ -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()