From 4afd281c3f2fe6b63fd0e3532b9a071a7f427499 Mon Sep 17 00:00:00 2001 From: ced <> Date: Thu, 13 Dec 2007 13:39:46 +0000 Subject: [PATCH] Remove bad commit inside function validate and use one function to post account move bzr revid: ced-40359d0fb608ef223122da9f2bfd32a0b7e8ee20 --- addons/account/account.py | 7 ++++--- addons/account/invoice.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 054e0dfa8c9..c1f9f2f73b1 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -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: diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 3f24b8aab17..431fc070d42 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -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