20
20
##############################################################################
22
22
from openerp.osv import orm, fields
23
from openerp.tools.amount_to_text_en import amount_to_text
25
25
class account_voucher(orm.Model):
26
26
_inherit = 'account.voucher'
28
def onchange_amount(self, cr, uid, ids, amount, rate, partner_id,
29
journal_id, currency_id, ttype, date,
30
payment_rate_currency_id, company_id, context=None):
31
""" Inherited - add amount_in_word and allow_check_writting in returned value dictionary """
34
default = super(account_voucher, self).onchange_amount(
35
cr, uid, ids, amount, rate, partner_id, journal_id, currency_id,
36
ttype, date, payment_rate_currency_id, company_id, context=context)
37
if 'value' in default:
38
amount = 'amount' in default['value'] and default['value']['amount'] or amount
40
#TODO : generic amount_to_text is not ready yet, otherwise language (and country) and currency can be passed
41
#amount_in_word = amount_to_text(amount, context=context)
42
amount_in_word = amount_to_text(amount, currency='Canadian Dollars')
43
default['value'].update({'amount_in_word':amount_in_word})
45
allow_check_writing = self.pool.get('account.journal').browse(
46
cr, uid, journal_id, context=context).allow_check_writing
47
default['value'].update({'allow_check': allow_check_writing})
28
50
def print_check(self, cr, uid, ids, context=None):