Merge lp:~openerp-dev/openobject-addons/trunk-account_check_writing_jam-amount-in-word-sgo into lp:~openerp-dev/openobject-addons/trunk-account_check_writing_jam

Proposed by Sanjay Gohel (Open ERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-account_check_writing_jam-amount-in-word-sgo
Merge into: lp:~openerp-dev/openobject-addons/trunk-account_check_writing_jam
Diff against target: 123 lines (+3/-79)
3 files modified
account_check_writing/__init__.py (+0/-1)
account_check_writing/account_voucher.py (+3/-17)
account_check_writing/amount_to_text_en.py (+0/-61)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-account_check_writing_jam-amount-in-word-sgo
Reviewer Review Type Date Requested Status
Jigar A. Pending
Review via email: mp+192698@code.launchpad.net

Description of the change

Hello,
   Remove amount word usd specific implementation (will be improve in future). Made amt to tax field char which will get values on amount change which can be changed.

Thank You.

Sanjay Gohel

To post a comment you must log in.

Unmerged revisions

8386. By Sanjay Gohel (Open ERP)

[REM/IMP]remove amount word usd specific implementation (will be improve in future). Made amt to tax field char which will get values on amount change which can be changed

8385. By Sanjay Gohel (Open ERP)

[MERGE]with parent

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_check_writing/__init__.py'
2--- account_check_writing/__init__.py 2012-12-16 09:54:23 +0000
3+++ account_check_writing/__init__.py 2013-10-25 13:24:03 +0000
4@@ -18,7 +18,6 @@
5 # along with this program. If not, see <http://www.gnu.org/licenses/>.
6 #
7 ##############################################################################
8-import amount_to_text_en
9 import res_company
10 import account
11 import account_voucher
12
13=== modified file 'account_check_writing/account_voucher.py'
14--- account_check_writing/account_voucher.py 2013-10-15 08:42:29 +0000
15+++ account_check_writing/account_voucher.py 2013-10-25 13:24:03 +0000
16@@ -22,7 +22,7 @@
17 from lxml import etree
18 from openerp.osv import osv, fields
19 from openerp.tools.translate import _
20-from openerp.addons.account_check_writing.amount_to_text_en import amount_to_text
21+from openerp.tools import amount_to_text_en
22
23
24 class account_voucher(osv.Model):
25@@ -45,22 +45,8 @@
26 return journal_pool.search(cr, uid, [('allow_check_writing', '=', True)], limit=1, context=context)
27 return journal_pool.search(cr, uid, [('type', '=', ttype)], limit=1, context=context)
28
29- def _get_amount_in_word(self, cr, uid, ids, field_name, arg, context=None):
30- """
31- fields.function method to generate the textual representation of the
32- float amount, to be printed on check later.
33- """
34- res = {}
35- for check in self.browse(cr, uid, ids, context=context):
36- language = 'en'
37- if context.get('lang'):
38- language = context.get('lang')[0:2]
39- currency = check.currency_id.name.lower()
40- res.update({check.id: amount_to_text(check.amount, lang=language, currency=currency)})
41- return res
42-
43 _columns = {
44- 'amount_in_word': fields.function(_get_amount_in_word, type='char', readonly=True, store=True),
45+ 'amount_in_word': fields.char("Amount in words", size=1024),
46 'allow_check': fields.related('journal_id', 'allow_check_writing', type='boolean', string='Allow Check Writing'),
47 'check_number': fields.char('Check Number', size=32),
48 'journal_id': fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft': [('readonly', False)]}),
49@@ -85,7 +71,7 @@
50 if context.get('lang'):
51 language = context.get('lang')[0:2]
52 currency = currency.name.lower()
53- amount_in_word = amount_to_text(amount, lang=language, currency=currency)
54+ amount_in_word = amount_to_text_en.amount_to_text(amount, lang=language, currency=currency)
55 default['value'].update({'amount_in_word': amount_in_word})
56 if journal_id:
57 allow_check_writing = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context).allow_check_writing
58
59=== removed file 'account_check_writing/amount_to_text_en.py'
60--- account_check_writing/amount_to_text_en.py 2013-10-10 12:38:31 +0000
61+++ account_check_writing/amount_to_text_en.py 1970-01-01 00:00:00 +0000
62@@ -1,61 +0,0 @@
63-# -*- coding: utf-8 -*-
64-##############################################################################
65-#
66-# OpenERP, Open Source Management Solution
67-# Copyright (C) 2004-Today OpenERP S.A. (<http://www.openerp.com>).
68-#
69-# This program is free software: you can redistribute it and/or modify
70-# it under the terms of the GNU Affero General Public License as
71-# published by the Free Software Foundation, either version 3 of the
72-# License, or (at your option) any later version.
73-#
74-# This program is distributed in the hope that it will be useful,
75-# but WITHOUT ANY WARRANTY; without even the implied warranty of
76-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
77-# GNU Affero General Public License for more details.
78-#
79-# You should have received a copy of the GNU Affero General Public License
80-# along with this program. If not, see <http://www.gnu.org/licenses/>.
81-#
82-##############################################################################
83-
84-import logging
85-from openerp.tools.translate import _
86-from openerp.tools import amount_to_text_en
87-
88-_logger = logging.getLogger(__name__)
89-
90-#This will file methods will facilitates the US specific check amount to text
91-#conversion. When we convert the amount to text using server tools api it
92-#produces following output for amount 4500.00:
93-# Four Thousand, Five Hundred euro and Zero Cent
94-#but when it comes to USd check expected output should is:
95-# Four Thousand, Five Hundred and 0/100
96-#So this method below will generate the above output for the USD currency for
97-#the places where we have this specific function called.
98-
99-
100-def amount_to_text(number, currency):
101- if currency == "usd":
102- number = '%.2f' % number
103- list = str(number).split('.')
104- start_word = amount_to_text_en.english_number(int(list[0]))
105- end_word = "%d/%d"%(int(list[1]),100)
106- return ' '.join(filter(None, [start_word, 'and', end_word]))
107- else:
108- return amount_to_text_en.amount_to_text(number, currency)
109-
110-
111-_translate_funcs = {'en' : amount_to_text}
112-
113-def amount_to_text(nbr, lang='en', currency='euro'):
114- """
115- Converts an integer to its textual representation, using the
116- language set in the context if any.
117- """
118- if lang not in _translate_funcs:
119- _logger.warning(_("no translation function found for lang: '%s'"), lang)
120- lang = 'en'
121- return _translate_funcs[lang](abs(nbr), currency)
122-
123-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

Subscribers

People subscribed via source and target branches