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

Proposed by Joao Alfredo Gama Batista
Status: Merged
Approved by: Joao Alfredo Gama Batista
Approved revision: 12
Merged at revision: 11
Proposed branch: lp:~savoirfairelinux-openerp/openerp-canada/7.0-bug-1178696-l10n_ca_account_check_writing
Merge into: lp:openerp-canada
Diff against target: 52 lines (+25/-3)
2 files modified
l10n_ca_account_check_writing/account_voucher.py (+23/-1)
l10n_ca_account_check_writing/report/l10n_ca_check_print.py (+2/-2)
To merge this branch: bzr merge lp:~savoirfairelinux-openerp/openerp-canada/7.0-bug-1178696-l10n_ca_account_check_writing
Reviewer Review Type Date Requested Status
Alexandre Fayolle - camptocamp code review, no test Approve
Review via email: mp+163328@code.launchpad.net

Description of the change

Force 'Canadian Dollars' as default currency for the canadian checks.

To post a comment you must log in.
12. By Joao Alfredo Gama Batista

[FIX] Don't remove 'Dollars' when printing

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

LGTM

Maybe an automated test would help?

review: Approve (code review, no test)
Revision history for this message
Joao Alfredo Gama Batista (joao-gama) wrote :

> LGTM
>
> Maybe an automated test would help?

It definitely would! ;)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_ca_account_check_writing/account_voucher.py'
2--- l10n_ca_account_check_writing/account_voucher.py 2013-04-25 21:23:42 +0000
3+++ l10n_ca_account_check_writing/account_voucher.py 2013-05-10 16:04:25 +0000
4@@ -20,11 +20,33 @@
5 ##############################################################################
6
7 from openerp.osv import orm, fields
8-
9+from openerp.tools.amount_to_text_en import amount_to_text
10
11 class account_voucher(orm.Model):
12 _inherit = 'account.voucher'
13
14+ def onchange_amount(self, cr, uid, ids, amount, rate, partner_id,
15+ journal_id, currency_id, ttype, date,
16+ payment_rate_currency_id, company_id, context=None):
17+ """ Inherited - add amount_in_word and allow_check_writting in returned value dictionary """
18+ if not context:
19+ context = {}
20+ default = super(account_voucher, self).onchange_amount(
21+ cr, uid, ids, amount, rate, partner_id, journal_id, currency_id,
22+ ttype, date, payment_rate_currency_id, company_id, context=context)
23+ if 'value' in default:
24+ amount = 'amount' in default['value'] and default['value']['amount'] or amount
25+
26+ #TODO : generic amount_to_text is not ready yet, otherwise language (and country) and currency can be passed
27+ #amount_in_word = amount_to_text(amount, context=context)
28+ amount_in_word = amount_to_text(amount, currency='Canadian Dollars')
29+ default['value'].update({'amount_in_word':amount_in_word})
30+ if journal_id:
31+ allow_check_writing = self.pool.get('account.journal').browse(
32+ cr, uid, journal_id, context=context).allow_check_writing
33+ default['value'].update({'allow_check': allow_check_writing})
34+ return default
35+
36 def print_check(self, cr, uid, ids, context=None):
37 if not ids:
38 return {}
39
40=== modified file 'l10n_ca_account_check_writing/report/l10n_ca_check_print.py'
41--- l10n_ca_account_check_writing/report/l10n_ca_check_print.py 2013-04-25 21:23:42 +0000
42+++ l10n_ca_account_check_writing/report/l10n_ca_check_print.py 2013-05-10 16:04:25 +0000
43@@ -35,8 +35,8 @@
44 'fill_stars' : self.fill_stars,
45 })
46 def fill_stars(self, amount):
47- amount = amount.replace('Dollars','')
48- if len(amount) < 100:
49+ #amount = amount.replace('Dollars','')
50+ if len(amount) < 90:
51 stars = 100 - len(amount)
52 return ' '.join([amount,'*'*stars])
53

Subscribers

People subscribed via source and target branches