[FIX]account_voucher: do not set account_id to False during onchanges
authorDenis Ledoux <dle@openerp.com>
Wed, 12 Feb 2014 17:37:11 +0000 (18:37 +0100)
committerDenis Ledoux <dle@openerp.com>
Wed, 12 Feb 2014 17:37:11 +0000 (18:37 +0100)
bzr revid: dle@openerp.com-20140212173711-nvx2gt1bboyey4qg

addons/account_voucher/account_voucher.py

index a269ae4..f58c640 100644 (file)
@@ -920,9 +920,10 @@ class account_voucher(osv.osv):
         if context.get('payment_expected_currency') and currency_id != context.get('payment_expected_currency'):
             vals['value']['amount'] = 0
             amount = 0
-        res = self.onchange_partner_id(cr, uid, ids, partner_id, journal_id, amount, currency_id, ttype, date, context)
-        for key in res.keys():
-            vals[key].update(res[key])
+        if partner_id:
+            res = self.onchange_partner_id(cr, uid, ids, partner_id, journal_id, amount, currency_id, ttype, date, context)
+            for key in res.keys():
+                vals[key].update(res[key])
         return vals
 
     def button_proforma_voucher(self, cr, uid, ids, context=None):
@@ -979,7 +980,7 @@ class account_voucher(osv.osv):
         res = {}
         if not partner_id:
             return res
-        res = {'account_id':False}
+        res = {}
         partner_pool = self.pool.get('res.partner')
         journal_pool = self.pool.get('account.journal')
         if pay_now == 'pay_later':
@@ -991,7 +992,8 @@ class account_voucher(osv.osv):
                 account_id = partner.property_account_payable.id
             else:
                 account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id
-            res['account_id'] = account_id
+            if account_id:
+                res['account_id'] = account_id
         return {'value':res}
 
     def _sel_context(self, cr, uid, voucher_id, context=None):