[FIX] Account : USer will be notified for unreconciling partial reconcilatins if he tries to cancel the invoice

bzr revid: jma@tinyerp.com-20100512104158-uvbap84l2jnzcnsz
This commit is contained in:
JMA (OpenERP) 2010-05-12 16:11:58 +05:30
parent 0b8c46b909
commit 72bd05b3c2
3 changed files with 21 additions and 8 deletions

View File

@ -581,7 +581,8 @@ class account_move_line(osv.osv):
if line.reconcile_partial_id:
for line2 in line.reconcile_partial_id.line_partial_ids:
if not line2.reconcile_id:
merges.append(line2.id)
if line2.id not in merges:
merges.append(line2.id)
total += (line2.debit or 0.0) - (line2.credit or 0.0)
merges_rec.append(line.reconcile_partial_id.id)
else:

View File

@ -922,7 +922,12 @@ class account_invoice(osv.osv):
# will be automatically deleted too
account_move_obj.unlink(cr, uid, [i['move_id'][0]])
if i['payment_ids']:
self.pool.get('account.move.line').write(cr, uid, i['payment_ids'], {'reconcile_partial_id': False})
account_move_line_obj = self.pool.get('account.move.line')
pay_ids = account_move_line_obj.browse(cr, uid , i['payment_ids'])
for move_line in pay_ids:
if move_line.reconcile_partial_id and move_line.reconcile_partial_id.line_partial_ids:
raise osv.except_osv(_('Error !'), _('You cannot cancel the Invoice which is Partially Paid! You need to unreconcile concerned payment entries!'))
self.write(cr, uid, ids, {'state':'cancel', 'move_id':False})
self._log_event(cr, uid, ids,-1.0, 'Cancel Invoice')
return True

View File

@ -29,11 +29,17 @@ class account_unreconcile(osv.osv_memory):
obj_move_reconcile = self.pool.get('account.move.reconcile')
if context is None:
context = {}
recs = obj_move_line.read(cr, uid, context['active_ids'], ['reconcile_id',])
recs = filter(lambda x: x['reconcile_id'], recs)
rec_ids = [rec['reconcile_id'][0] for rec in recs]
if len(rec_ids):
obj_move_reconcile.unlink(cr, uid, rec_ids)
recs = pool.get('account.move.line').read(cr, uid, data['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):
pooler.get_pool(cr.dbname).get('account.move.reconcile').unlink(cr, uid, unlink_ids)
return {}
account_unreconcile()
@ -44,10 +50,11 @@ class account_unreconcile_reconcile(osv.osv_memory):
def trans_unrec_reconcile(self, cr, uid, ids, context=None):
obj_move_reconcile = self.pool.get('account.move.reconcile')
rec_ids = context['active_ids']
if context is None:
context = {}
if len(rec_ids):
obj_move_reconcile.unlink(cr, uid, context['active_ids'])
obj_move_reconcile.unlink(cr, uid, rec_ids)
return {}
account_unreconcile_reconcile()