~openerp-canada/openerp-canada/7.0-fix-1190823

« back to all changes in this revision

Viewing changes to l10n_ca_account_check_writing/account_voucher.py

[MRG] Fixed bug 1178696

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
##############################################################################
21
21
 
22
22
from openerp.osv import orm, fields
23
 
 
 
23
from openerp.tools.amount_to_text_en import amount_to_text
24
24
 
25
25
class account_voucher(orm.Model):
26
26
    _inherit = 'account.voucher'
27
27
 
 
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 """
 
32
        if not context:
 
33
            context = {}
 
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
 
39
 
 
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})
 
44
            if journal_id:
 
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})
 
48
        return default
 
49
 
28
50
    def print_check(self, cr, uid, ids, context=None):
29
51
        if not ids:
30
52
            return  {}