Remove bad commit inside function validate and use one function to post account move

bzr revid: ced-40359d0fb608ef223122da9f2bfd32a0b7e8ee20
This commit is contained in:
ced 2007-12-13 13:39:46 +00:00
parent 0237f62a81
commit 4afd281c3f
2 changed files with 5 additions and 4 deletions

View File

@ -606,15 +606,16 @@ class account_move(osv.osv):
'state': lambda *a: 'draft',
'period_id': _get_period,
}
def button_validate(self, cr, uid, ids, context={}):
def post(self, cr, uid, ids, context=None):
if self.validate(cr, uid, ids, context) and len(ids):
cr.execute('update account_move set state=%s where id in ('+','.join(map(str,ids))+')', ('posted',))
else:
cr.execute('update account_move set state=%s where id in ('+','.join(map(str,ids))+')', ('draft',))
cr.commit()
raise osv.except_osv('Integrity Error !', 'You can not validate a non balanced entry !')
return True
def button_validate(self, cursor, user, ids, context=None):
return self.post(cursor, user, ids, context=context)
def button_cancel(self, cr, uid, ids, context={}):
for line in self.browse(cr, uid, ids, context):
if not line.journal_id.update_posted:

View File

@ -503,7 +503,7 @@ class account_invoice(osv.osv):
move_id = self.pool.get('account.move').create(cr, uid, move)
# make the invoice point to that move
self.write(cr, uid, [inv.id], {'move_id': move_id})
self.pool.get('account.move').write(cr, uid, [move_id], {'state':'posted'})
self.pool.get('account.move').post(cr, uid, [move_id])
self._log_event(cr, uid, ids)
return True