← Back to team overview

savoirfairelinux-openerp team mailing list archive

lp:~savoirfairelinux-openerp/openerp-canada/7.0-bug-1178696-l10n_ca_account_check_writing into lp:openerp-canada

 

Joao Alfredo Gama Batista has proposed merging lp:~savoirfairelinux-openerp/openerp-canada/7.0-bug-1178696-l10n_ca_account_check_writing into lp:openerp-canada.

Requested reviews:
  OpenERP Community Reviewer (openerp-community-reviewer)
Related bugs:
  Bug #1178696 in OpenERP Canada: "[6.1/7.0] l10n_ca_account_check_writing: Wrong currency in value as word"
  https://bugs.launchpad.net/openerp-canada/+bug/1178696

For more details, see:
https://code.launchpad.net/~savoirfairelinux-openerp/openerp-canada/7.0-bug-1178696-l10n_ca_account_check_writing/+merge/163328

Force 'Canadian Dollars' as default currency for the canadian checks.
-- 
https://code.launchpad.net/~savoirfairelinux-openerp/openerp-canada/7.0-bug-1178696-l10n_ca_account_check_writing/+merge/163328
Your team Savoir-faire Linux' OpenERP is subscribed to branch lp:~savoirfairelinux-openerp/openerp-canada/7.0-bug-1178696-l10n_ca_account_check_writing.
=== modified file 'l10n_ca_account_check_writing/account_voucher.py'
--- l10n_ca_account_check_writing/account_voucher.py	2013-04-25 21:23:42 +0000
+++ l10n_ca_account_check_writing/account_voucher.py	2013-05-10 15:04:24 +0000
@@ -20,11 +20,33 @@
 ##############################################################################
 
 from openerp.osv import orm, fields
-
+from openerp.tools.amount_to_text_en import amount_to_text
 
 class account_voucher(orm.Model):
     _inherit = 'account.voucher'
 
+    def onchange_amount(self, cr, uid, ids, amount, rate, partner_id,
+                        journal_id, currency_id, ttype, date,
+                        payment_rate_currency_id, company_id, context=None):
+        """ Inherited - add amount_in_word and allow_check_writting in returned value dictionary """
+        if not context:
+            context = {}
+        default = super(account_voucher, self).onchange_amount(
+            cr, uid, ids, amount, rate, partner_id, journal_id, currency_id,
+            ttype, date, payment_rate_currency_id, company_id, context=context)
+        if 'value' in default:
+            amount = 'amount' in default['value'] and default['value']['amount'] or amount
+
+            #TODO : generic amount_to_text is not ready yet, otherwise language (and country) and currency can be passed
+            #amount_in_word = amount_to_text(amount, context=context)
+            amount_in_word = amount_to_text(amount, currency='Canadian Dollars')
+            default['value'].update({'amount_in_word':amount_in_word})
+            if journal_id:
+                allow_check_writing = self.pool.get('account.journal').browse(
+                    cr, uid, journal_id, context=context).allow_check_writing
+                default['value'].update({'allow_check': allow_check_writing})
+        return default
+
     def print_check(self, cr, uid, ids, context=None):
         if not ids:
             return  {}


Follow ups