From 29d28b05e4b958ce5d8437b03c1bdf711a18ea85 Mon Sep 17 00:00:00 2001 From: Wolfgang Taferner Date: Tue, 6 Oct 2015 07:30:20 +0200 Subject: [PATCH] [FIX] account_check_writing: modify voucher amount without company The code used the key vals['company_id'] while it was not checked it was present in the write call (and it should not necessary). If a key is not present, browse the record instead. Fixes #8906 --- addons/account_check_writing/account_voucher.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/addons/account_check_writing/account_voucher.py b/addons/account_check_writing/account_voucher.py index e85184a07b9..6fe17c4a1b5 100644 --- a/addons/account_check_writing/account_voucher.py +++ b/addons/account_check_writing/account_voucher.py @@ -93,10 +93,16 @@ class account_voucher(osv.osv): return super(account_voucher, self).create(cr, uid, vals, context=context) def write(self, cr, uid, ids, vals, context=None): - if vals.get('amount') and vals.get('journal_id') and 'amount_in_word' not in vals: - vals['amount_in_word'] = self._amount_to_text(cr, uid, vals['amount'], vals.get('currency_id') or \ - self.pool['account.journal'].browse(cr, uid, vals['journal_id'], context=context).currency.id or \ - self.pool['res.company'].browse(cr, uid, vals['company_id']).currency_id.id, context=context) + if vals.get('amount') and 'amount_in_word' not in vals: + voucher = self.browse(cr, uid, ids, context=context) + currency_id = vals.get('currency_id') + if not currency_id: + journal = vals.get('journal_id') and self.pool['account.journal'].browse(cr, uid, vals['journal_id'], context=context) or voucher.journal_id + currency_id = journal.currency.id + if not currency_id: + company = vals.get('company_id') and self.pool['res.company'].browse(cr, uid, vals['company_id'], context=context) or voucher.company_id + currency_id = company.currency_id.id + vals['amount_in_word'] = self._amount_to_text(cr, uid, vals['amount'], currency_id, context=context) return super(account_voucher, self).write(cr, uid, ids, vals, context=context) def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):