[FIX] account: Cancel of invoice throws error, validate of move_id is invalid

bzr revid: ara@tinyerp.com-20110425061114-nq2mzpc8w082hu3j
This commit is contained in:
ARA (OpenERP) 2011-04-25 11:41:14 +05:30
parent 08695d5433
commit ad590ddc86
2 changed files with 4 additions and 13 deletions

View File

@ -32,7 +32,7 @@ class account_analytic_line(osv.osv):
'product_uom_id': fields.many2one('product.uom', 'UoM'),
'product_id': fields.many2one('product.product', 'Product'),
'general_account_id': fields.many2one('account.account', 'General Account', required=True, ondelete='restrict'),
'move_id': fields.many2one('account.move.line', 'Move Line', ondelete='restrict', select=True),
'move_id': fields.many2one('account.move.line', 'Move Line', ondelete='cascade', select=True),
'journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal', required=True, ondelete='restrict', select=True),
'code': fields.char('Code', size=8),
'ref': fields.char('Ref.', size=64),

View File

@ -1085,24 +1085,15 @@ class account_move_line(osv.osv):
if context is None:
context = {}
move_obj = self.pool.get('account.move')
analytic_obj = self.pool.get('account.analytic.line')
self._update_check(cr, uid, ids, context)
result = False
move_ids = set()
analytic_ids = set()
move_line_ids = set()
for line in self.browse(cr, uid, ids, context=context):
move_ids.add(line.move_id.id)
move_line_ids.add(line.id)
for analytic in line.analytic_lines:
analytic_ids.add(analytic.id)
analytic_ids = list(analytic_ids)
context['journal_id'] = line.journal_id.id
context['period_id'] = line.period_id.id
result = super(account_move_line, self).unlink(cr, uid, [line.id], context=context)
move_ids = list(move_ids)
if analytic_ids:
analytic_obj.unlink(cr,uid, analytic_ids, context=context)
result = super(account_move_line, self).unlink(cr, uid, list(move_line_ids), context=context)
if check and move_ids:
move_obj.validate(cr, uid, move_ids, context=context)
return result