From 90f334cfcf60d62d5192488cfa6d98aeabaada28 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Mon, 15 Dec 2008 17:39:18 +0530 Subject: [PATCH] fixing for the analytic account in voucher entry bzr revid: mga@tinyerp.com-20081215120918-737pk2agyia6534o --- addons/account_voucher/voucher.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py index 611edebfc92..287bb2c8353 100755 --- a/addons/account_voucher/voucher.py +++ b/addons/account_voucher/voucher.py @@ -331,6 +331,7 @@ class account_voucher(osv.osv): elif line.type == 'cr': move_line['credit'] = line.amount or False amount=line.amount * (-1) + ml_id=self.pool.get('account.move.line').create(cr, uid, move_line) if inv.narration: @@ -338,17 +339,18 @@ class account_voucher(osv.osv): else: line.name=line.name - an_line = { - 'name':line.name, - 'date':inv.date, - 'amount':amount, - 'account_id':line.account_analytic_id.id or False, - 'move_id':ml_id, - 'journal_id':an_journal_id , - 'general_account_id':line.account_id.id, - 'ref':ref - } - self.pool.get('account.analytic.line').create(cr,uid,an_line) + if line.account_analytic_id: + an_line = { + 'name':line.name, + 'date':inv.date, + 'amount':amount, + 'account_id':line.account_analytic_id.id or False, + 'move_id':ml_id, + 'journal_id':an_journal_id , + 'general_account_id':line.account_id.id, + 'ref':ref + } + self.pool.get('account.analytic.line').create(cr,uid,an_line) self.write(cr, uid, [inv.id], {'move_id': move_id}) obj=self.pool.get('account.move').browse(cr, uid, move_id)