Merge lp:~anybox/aeroo/fix-upgrade into lp:aeroo
- fix-upgrade
- Merge into openerp7
Status: | Superseded |
---|---|
Proposed branch: | lp:~anybox/aeroo/fix-upgrade |
Merge into: | lp:aeroo |
Diff against target: |
11765 lines (+11131/-0) (has conflicts) 114 files modified
report_aeroo/ExtraFunctions.py (+664/-0) report_aeroo/__init__.py (+52/-0) report_aeroo/__openerp__.py (+82/-0) report_aeroo/barcode/EANBarCode.py (+159/-0) report_aeroo/barcode/__init__.py (+34/-0) report_aeroo/barcode/barcode.py (+63/-0) report_aeroo/barcode/code128.py (+189/-0) report_aeroo/barcode/code39.py (+166/-0) report_aeroo/check_deps.py (+52/-0) report_aeroo/ctt_languages/__init__.py (+3/-0) report_aeroo/ctt_languages/en_US/__init__.py (+91/-0) report_aeroo/ctt_languages/en_US/currencies/__init__.py (+3/-0) report_aeroo/ctt_languages/en_US/currencies/eur.py (+19/-0) report_aeroo/ctt_languages/en_US/currencies/ltl.py (+19/-0) report_aeroo/ctt_languages/en_US/currencies/lvl.py (+19/-0) report_aeroo/ctt_languages/en_US/currencies/mxn.py (+19/-0) report_aeroo/ctt_languages/en_US/currencies/trl.py (+19/-0) report_aeroo/ctt_languages/en_US/currencies/usd.py (+19/-0) report_aeroo/ctt_languages/es_ES/__init__.py (+102/-0) report_aeroo/ctt_languages/es_ES/currencies/__init__.py (+3/-0) report_aeroo/ctt_languages/es_ES/currencies/eur.py (+19/-0) report_aeroo/ctt_languages/es_ES/currencies/mxn.py (+19/-0) report_aeroo/ctt_languages/es_ES/currencies/usd.py (+19/-0) report_aeroo/ctt_languages/lt_LT/__init__.py (+107/-0) report_aeroo/ctt_languages/lt_LT/currencies/__init__.py (+3/-0) report_aeroo/ctt_languages/lt_LT/currencies/eur.py (+25/-0) report_aeroo/ctt_languages/lt_LT/currencies/ltl.py (+25/-0) report_aeroo/ctt_languages/lt_LT/currencies/lvl.py (+25/-0) report_aeroo/ctt_languages/lt_LT/currencies/uah.py (+25/-0) report_aeroo/ctt_languages/lt_LT/currencies/usd.py (+25/-0) report_aeroo/ctt_languages/lv_LV/__init__.py (+101/-0) report_aeroo/ctt_languages/lv_LV/currencies/__init__.py (+3/-0) report_aeroo/ctt_languages/lv_LV/currencies/eur.py (+22/-0) report_aeroo/ctt_languages/lv_LV/currencies/ltl.py (+25/-0) report_aeroo/ctt_languages/lv_LV/currencies/lvl.py (+25/-0) report_aeroo/ctt_languages/lv_LV/currencies/mxn.py (+22/-0) report_aeroo/ctt_languages/lv_LV/currencies/rub.py (+25/-0) report_aeroo/ctt_languages/lv_LV/currencies/trl.py (+25/-0) report_aeroo/ctt_languages/lv_LV/currencies/uah.py (+24/-0) report_aeroo/ctt_languages/lv_LV/currencies/usd.py (+25/-0) report_aeroo/ctt_languages/ru_RU/__init__.py (+110/-0) report_aeroo/ctt_languages/ru_RU/currencies/__init__.py (+3/-0) report_aeroo/ctt_languages/ru_RU/currencies/eur.py (+22/-0) report_aeroo/ctt_languages/ru_RU/currencies/ltl.py (+23/-0) report_aeroo/ctt_languages/ru_RU/currencies/lvl.py (+23/-0) report_aeroo/ctt_languages/ru_RU/currencies/rub.py (+23/-0) report_aeroo/ctt_languages/ru_RU/currencies/uah.py (+23/-0) report_aeroo/ctt_languages/ru_RU/currencies/usd.py (+23/-0) report_aeroo/ctt_languages/tr_TR/__init__.py (+93/-0) report_aeroo/ctt_languages/tr_TR/currencies/__init__.py (+3/-0) report_aeroo/ctt_languages/tr_TR/currencies/eur.py (+21/-0) report_aeroo/ctt_languages/tr_TR/currencies/lvl.py (+21/-0) report_aeroo/ctt_languages/tr_TR/currencies/trl.py (+21/-0) report_aeroo/ctt_languages/tr_TR/currencies/usd.py (+21/-0) report_aeroo/ctt_languages/uk_UA/__init__.py (+112/-0) report_aeroo/ctt_languages/uk_UA/currencies/__init__.py (+3/-0) report_aeroo/ctt_languages/uk_UA/currencies/eur.py (+21/-0) report_aeroo/ctt_languages/uk_UA/currencies/ltl.py (+23/-0) report_aeroo/ctt_languages/uk_UA/currencies/lvl.py (+23/-0) report_aeroo/ctt_languages/uk_UA/currencies/rub.py (+23/-0) report_aeroo/ctt_languages/uk_UA/currencies/uah.py (+23/-0) report_aeroo/ctt_languages/uk_UA/currencies/usd.py (+23/-0) report_aeroo/ctt_objects.py (+161/-0) report_aeroo/currency_to_text.py (+491/-0) report_aeroo/data/report_aeroo_data.xml (+25/-0) report_aeroo/domain_parser.py (+49/-0) report_aeroo/installer.py (+79/-0) report_aeroo/installer.xml (+56/-0) report_aeroo/report_aeroo.py (+859/-0) report_aeroo/report_view.xml (+322/-0) report_aeroo/report_xml.py (+680/-0) report_aeroo/security/ir.model.access.csv (+5/-0) report_aeroo/translate.py (+352/-0) report_aeroo/wizard/__init__.py (+38/-0) report_aeroo/wizard/add_print_button.py (+111/-0) report_aeroo/wizard/add_print_button_view.xml (+40/-0) report_aeroo/wizard/remove_print_button.py (+97/-0) report_aeroo/wizard/remove_print_button_view.xml (+37/-0) report_aeroo/wizard/report_actions.py (+149/-0) report_aeroo/wizard/report_import_wizard.py (+152/-0) report_aeroo/wizard/report_print_actions.py (+183/-0) report_aeroo/wizard/report_print_by_action.py (+63/-0) report_aeroo_direct_print/__init__.py (+40/-0) report_aeroo_direct_print/__openerp__.py (+76/-0) report_aeroo_direct_print/check_deps.py (+51/-0) report_aeroo_direct_print/data/report_aeroo_direct_data.xml (+17/-0) report_aeroo_direct_print/installer.py (+152/-0) report_aeroo_direct_print/installer.xml (+62/-0) report_aeroo_direct_print/report_aeroo_direct_print.py (+299/-0) report_aeroo_direct_print/report_aeroo_direct_print_view.xml (+158/-0) report_aeroo_direct_print/security/ir.model.access.csv (+2/-0) report_aeroo_direct_print/security/security_rules.xml (+14/-0) report_aeroo_ooo/DocumentConverter.py (+221/-0) report_aeroo_ooo/__init__.py (+80/-0) report_aeroo_ooo/__openerp__.py (+64/-0) report_aeroo_ooo/check_deps.py (+52/-0) report_aeroo_ooo/data/report_aeroo_data.xml (+47/-0) report_aeroo_ooo/installer.py (+165/-0) report_aeroo_ooo/installer.xml (+72/-0) report_aeroo_ooo/report.py (+95/-0) report_aeroo_ooo/report_view.xml (+31/-0) report_aeroo_ooo/tests/__init__.py (+4/-0) report_aeroo_ooo/tests/test_service.py (+34/-0) report_aeroo_printscreen/__init__.py (+32/-0) report_aeroo_printscreen/__openerp__.py (+52/-0) report_aeroo_printscreen/data/report_aeroo_printscreen_data.xml (+21/-0) report_aeroo_printscreen/parser.py (+77/-0) report_aeroo_printscreen/static/src/js/report_aeroo_printscreen.js (+41/-0) report_aeroo_sample/__init__.py (+33/-0) report_aeroo_sample/__openerp__.py (+48/-0) report_aeroo_sample/report/__init__.py (+34/-0) report_aeroo_sample/report/lorem.py (+1982/-0) report_aeroo_sample/report/parser.py (+49/-0) report_aeroo_sample/report/report_sample.xml (+30/-0) Conflict adding file report_aeroo. Moved existing file to report_aeroo.moved. Conflict adding file report_aeroo_direct_print. Moved existing file to report_aeroo_direct_print.moved. Conflict adding file report_aeroo_ooo. Moved existing file to report_aeroo_ooo.moved. Conflict adding file report_aeroo_printscreen. Moved existing file to report_aeroo_printscreen.moved. Conflict adding file report_aeroo_sample. Moved existing file to report_aeroo_sample.moved. |
To merge this branch: | bzr merge lp:~anybox/aeroo/fix-upgrade |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Christophe Combelles | thorough ! | Pending | |
Review via email: mp+214388@code.launchpad.net |
This proposal has been superseded by a proposal from 2014-04-05.
Commit message
Description of the change
To test, take any customer project using an earlier version of aeroo (no restart_ooo_cmd column in oo_config table), and perform an upgrade with the upgrade script provided by the recipe.
A quicker test is to check if the server starts *without -u report_aeroo_ooo*
Note that I am also tempted by fixing the bare excepts once the fix itself is more mature.
I'm asking ccomb, but any comments are welcome, and especially further tests by the Anybox team on customer projects.
- 38. By Georges Racinet <email address hidden>
-
Removed some bare excepts
This did not change the behaviour for me. But exception treatment is so
messy in aeroo that I could not see the warning in the except: blockI could see parts of the module that systematically wrap and reraise everything
as Exception - 39. By Pierre Verkest
-
use exception message
- 40. By Pierre Verkest
-
[FIX]use Message instead message from uno exception
- 41. By Georges Racinet
-
[FIX] (temp) graceful instantiation of OOo service depended on bare except
put a big comment in check_deps indicating how a proper fix of this terrible
entanglement should look
Unmerged revisions
- 41. By Georges Racinet
-
[FIX] (temp) graceful instantiation of OOo service depended on bare except
put a big comment in check_deps indicating how a proper fix of this terrible
entanglement should look - 40. By Pierre Verkest
-
[FIX]use Message instead message from uno exception
- 39. By Pierre Verkest
-
use exception message
- 38. By Georges Racinet <email address hidden>
-
Removed some bare excepts
This did not change the behaviour for me. But exception treatment is so
messy in aeroo that I could not see the warning in the except: blockI could see parts of the module that systematically wrap and reraise everything
as Exception - 37. By Georges Racinet <email address hidden>
-
[FIX] made startup sequence more robust in upgrade situations
See explanations in OpenOffice_service docstring
This fixes in particular upgrades done with anybox.recipe. openerp' s
standard upgrade scripts, which will act only after the database has been
loaded. - 36. By fjouatte <email address hidden>
-
[FIX] Fix report visualization from openerp ui
- 35. By Mathieu Vatel - Julius Network Solutions
-
[FIX] - remove a cr.rollback() which leads to not computing parent_left parent_right in ir_ui_menu when OpenOfficeService is not working
- 34. By Mathieu Vatel - Julius Network Solutions
-
[IMP] simple code cleaning
- 33. By Mathieu Vatel - Julius Network Solutions
-
[FIX] - error on loading
- 32. By Mathieu Vatel - Julius Network Solutions
-
[IMP] - improve the last commit to get the last version of lp:aeroo
Preview Diff
1 | === added directory 'report_aeroo' | |||
2 | === renamed directory 'report_aeroo' => 'report_aeroo.moved' | |||
3 | === added file 'report_aeroo/ExtraFunctions.py' | |||
4 | --- report_aeroo/ExtraFunctions.py 1970-01-01 00:00:00 +0000 | |||
5 | +++ report_aeroo/ExtraFunctions.py 2014-04-05 13:18:49 +0000 | |||
6 | @@ -0,0 +1,664 @@ | |||
7 | 1 | # -*- coding: utf-8 -*- | ||
8 | 2 | ############################################################################## | ||
9 | 3 | # | ||
10 | 4 | # Copyright (c) 2009-2013 Alistek Ltd (http://www.alistek.com) All Rights Reserved. | ||
11 | 5 | # General contacts <info@alistek.com> | ||
12 | 6 | # | ||
13 | 7 | # WARNING: This program as such is intended to be used by professional | ||
14 | 8 | # programmers who take the whole responsability of assessing all potential | ||
15 | 9 | # consequences resulting from its eventual inadequacies and bugs | ||
16 | 10 | # End users who are looking for a ready-to-use solution with commercial | ||
17 | 11 | # garantees and support are strongly adviced to contract a Free Software | ||
18 | 12 | # Service Company | ||
19 | 13 | # | ||
20 | 14 | # This program is Free Software; you can redistribute it and/or | ||
21 | 15 | # modify it under the terms of the GNU General Public License | ||
22 | 16 | # as published by the Free Software Foundation; either version 3 | ||
23 | 17 | # of the License, or (at your option) any later version. | ||
24 | 18 | # | ||
25 | 19 | # This module is GPLv3 or newer and incompatible | ||
26 | 20 | # with OpenERP SA "AGPL + Private Use License"! | ||
27 | 21 | # | ||
28 | 22 | # This program is distributed in the hope that it will be useful, | ||
29 | 23 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
30 | 24 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
31 | 25 | # GNU General Public License for more details. | ||
32 | 26 | # | ||
33 | 27 | # You should have received a copy of the GNU General Public License | ||
34 | 28 | # along with this program; if not, write to the Free Software | ||
35 | 29 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
36 | 30 | # | ||
37 | 31 | ############################################################################## | ||
38 | 32 | |||
39 | 33 | from .barcode import barcode | ||
40 | 34 | from openerp.tools import translate | ||
41 | 35 | #from .currency_to_text import currency_to_text | ||
42 | 36 | from .ctt_objects import supported_language | ||
43 | 37 | import logging | ||
44 | 38 | _logger = logging.getLogger(__name__) | ||
45 | 39 | import base64 | ||
46 | 40 | import StringIO | ||
47 | 41 | try: | ||
48 | 42 | from PIL import Image | ||
49 | 43 | except: | ||
50 | 44 | _logger.warning("ERROR IMPORTING PIL, if not installed, please install it:" | ||
51 | 45 | " get it here: https://pypi.python.org/pypi/PIL") | ||
52 | 46 | from openerp import pooler | ||
53 | 47 | import time | ||
54 | 48 | from openerp.osv import orm | ||
55 | 49 | from openerp.report import report_sxw | ||
56 | 50 | from openerp.tools.translate import _ | ||
57 | 51 | from openerp import netsvc | ||
58 | 52 | from openerp.tools.safe_eval import safe_eval as eval | ||
59 | 53 | from aeroolib.plugins.opendocument import _filter | ||
60 | 54 | |||
61 | 55 | try: | ||
62 | 56 | from docutils.examples import html_parts # use python-docutils library | ||
63 | 57 | except ImportError, e: | ||
64 | 58 | _logger.warning("ERROR IMPORTING docutils, if not installed, please install it:" | ||
65 | 59 | " e.g.: apt-get install python-docutils") | ||
66 | 60 | rest_ok = False | ||
67 | 61 | else: | ||
68 | 62 | rest_ok = True | ||
69 | 63 | |||
70 | 64 | try: | ||
71 | 65 | import nltk | ||
72 | 66 | except: | ||
73 | 67 | _logger.warning("ERROR IMPORTING nltk, if not installed, please install it:" | ||
74 | 68 | " e.g.: apt-get install python-nltk") | ||
75 | 69 | |||
76 | 70 | try: | ||
77 | 71 | import markdown | ||
78 | 72 | from markdown import Markdown # use python-markdown library | ||
79 | 73 | from markdown.inlinepatterns import AutomailPattern | ||
80 | 74 | |||
81 | 75 | class AutomailPattern_mod (AutomailPattern, object): | ||
82 | 76 | def __init__(self, *args, **kwargs): | ||
83 | 77 | super(AutomailPattern_mod, self).__init__(*args, **kwargs) | ||
84 | 78 | |||
85 | 79 | def handleMatch(self, m): | ||
86 | 80 | el = super(AutomailPattern_mod, self).handleMatch(m) | ||
87 | 81 | href = ''.join([chr(int(a.replace(markdown.AMP_SUBSTITUTE+'#', ''))) for a in el.get('href').split(';') if a]) | ||
88 | 82 | el.set('href', href) | ||
89 | 83 | return el | ||
90 | 84 | |||
91 | 85 | markdown.inlinepatterns.AutomailPattern = AutomailPattern_mod # easy hack for correct displaying in Joomla | ||
92 | 86 | |||
93 | 87 | except ImportError, e: | ||
94 | 88 | markdown_ok = False | ||
95 | 89 | _logger.warning("ERROR IMPORTING markdown, if not installed, please install it:" | ||
96 | 90 | " e.g.: apt-get install python-markdown") | ||
97 | 91 | else: | ||
98 | 92 | markdown_ok = True | ||
99 | 93 | |||
100 | 94 | try: | ||
101 | 95 | from mediawiki import wiki2html # use python-mediawiki library | ||
102 | 96 | except ImportError, e: | ||
103 | 97 | wikitext_ok = False | ||
104 | 98 | else: | ||
105 | 99 | wikitext_ok = True | ||
106 | 100 | |||
107 | 101 | from .domain_parser import domain2statement | ||
108 | 102 | |||
109 | 103 | class ExtraFunctions(object): | ||
110 | 104 | """ This class contains some extra functions which | ||
111 | 105 | can be called from the report's template. | ||
112 | 106 | """ | ||
113 | 107 | def __init__(self, cr, uid, report_id, context): | ||
114 | 108 | self.cr = cr | ||
115 | 109 | self.uid = uid | ||
116 | 110 | self.pool = pooler.get_pool(self.cr.dbname) | ||
117 | 111 | self.report_id = report_id | ||
118 | 112 | self.context = context | ||
119 | 113 | self.functions = { | ||
120 | 114 | 'report_context': self.context, | ||
121 | 115 | 'asarray':self._asarray, | ||
122 | 116 | 'asimage':self._asimage, | ||
123 | 117 | 'html_embed_image':self._embed_image, | ||
124 | 118 | 'get_attachments':self._get_attachments, | ||
125 | 119 | 'get_name':self._get_name, | ||
126 | 120 | 'get_label':self._get_label, | ||
127 | 121 | 'getLang':self._get_lang, | ||
128 | 122 | 'get_selection_item':self._get_selection_items('item'), | ||
129 | 123 | 'safe':self._get_safe, | ||
130 | 124 | 'countif':self._countif, | ||
131 | 125 | 'count':self._count, | ||
132 | 126 | 'sumif':self._sumif, | ||
133 | 127 | 'sum_field':self._sum, | ||
134 | 128 | 'max_field':self._max, | ||
135 | 129 | 'min_field':self._min, | ||
136 | 130 | 'average':self._average, | ||
137 | 131 | 'large':self._large, | ||
138 | 132 | 'small':self._small, | ||
139 | 133 | 'count_blank':self._count_blank, | ||
140 | 134 | '_':self._translate_text, | ||
141 | 135 | 'gettext':self._translate_text, | ||
142 | 136 | 'currency_to_text':self._currency2text(context['company'].currency_id.name), #self._currency2text(context['company'].currency_id.code), | ||
143 | 137 | 'barcode':barcode.make_barcode, | ||
144 | 138 | 'debugit':self.debugit, | ||
145 | 139 | 'dec_to_time':self._dec2time, | ||
146 | 140 | 'chunks':self._chunks, | ||
147 | 141 | 'browse':self._browse, | ||
148 | 142 | 'search':self._search, | ||
149 | 143 | 'search_ids':self._search_ids, | ||
150 | 144 | 'field_size':self._field_size, | ||
151 | 145 | 'field_accuracy':self._field_accuracy, | ||
152 | 146 | 'bool_as_icon':self._bool_as_icon, | ||
153 | 147 | 'time':time, | ||
154 | 148 | 'report_xml': self._get_report_xml(), | ||
155 | 149 | 'get_log': self._perm_read(self.cr, self.uid), | ||
156 | 150 | 'get_selection_items': self._get_selection_items(), | ||
157 | 151 | 'itemize': self._itemize, | ||
158 | 152 | 'html_escape': self._html_escape, | ||
159 | 153 | 'html_remove': self._html_remove, | ||
160 | 154 | 'http_prettyuri': self._http_prettyuri, | ||
161 | 155 | 'http_builduri': self._http_builduri, | ||
162 | 156 | 'text_markdown': markdown_ok and self._text_markdown or \ | ||
163 | 157 | self._text_plain('"markdown" format is not supported! Need to be installed "python-markdown" package.'), | ||
164 | 158 | 'text_restruct': rest_ok and self._text_restruct or \ | ||
165 | 159 | self._text_plain('"reStructuredText" format is not supported! Need to be installed "python-docutils" package.'), | ||
166 | 160 | 'text_wiki': wikitext_ok and self._text_wiki or \ | ||
167 | 161 | self._text_plain('"wikimarkup" format is not supported! Need to be installed "python-mediawiki" package.'), | ||
168 | 162 | 'text_markup': self._text_markup, | ||
169 | 163 | '__filter': self.__filter, # Don't use in the report template! | ||
170 | 164 | 'specific_lang': self._specific_lang, | ||
171 | 165 | 'sort_by':self._sort_by, | ||
172 | 166 | 'group_by':self._group_by, | ||
173 | 167 | 'invoice_lines': self._invoice_lines, | ||
174 | 168 | 'location_name': self._location, | ||
175 | 169 | } | ||
176 | 170 | |||
177 | 171 | def __filter(self, val): | ||
178 | 172 | if isinstance(val, orm.browse_null): | ||
179 | 173 | return '' | ||
180 | 174 | elif isinstance(val, orm.browse_record): | ||
181 | 175 | return val.name_get({'lang':self._get_lang()})[0][1] | ||
182 | 176 | return _filter(val) | ||
183 | 177 | |||
184 | 178 | def _perm_read(self, cr, uid): | ||
185 | 179 | def get_log(obj, field=None): | ||
186 | 180 | if field: | ||
187 | 181 | return obj.perm_read(self.uid, [obj.id])[0][field] | ||
188 | 182 | else: | ||
189 | 183 | return obj.perm_read(self.uid, [obj.id])[0] | ||
190 | 184 | return get_log | ||
191 | 185 | |||
192 | 186 | def _get_report_xml(self): | ||
193 | 187 | return self.pool.get('ir.actions.report.xml').browse(self.cr, self.uid, self.report_id) | ||
194 | 188 | |||
195 | 189 | def _get_lang(self, source='current'): | ||
196 | 190 | if source=='current': | ||
197 | 191 | return self.context['lang'] or self.context['user_lang'] | ||
198 | 192 | elif source=='company': | ||
199 | 193 | return self.context['user'].company_id.partner_id.lang | ||
200 | 194 | elif source=='user': | ||
201 | 195 | return self.context['user_lang'] | ||
202 | 196 | |||
203 | 197 | def _bool_as_icon(self, val, kind=0): | ||
204 | 198 | if isinstance(kind, (list, tuple)): | ||
205 | 199 | if val==True: | ||
206 | 200 | return kind [0] | ||
207 | 201 | elif val==False: | ||
208 | 202 | return kind[1] | ||
209 | 203 | else: | ||
210 | 204 | return kind[2] | ||
211 | 205 | bool_kind = {0:{True:self._translate_text('True'), False:self._translate_text('False'), None:""}, | ||
212 | 206 | 1:{True:self._translate_text('T'), False:self._translate_text('F'), None:""}, | ||
213 | 207 | 2:{True:self._translate_text('Yes'), False:self._translate_text('No'), None:""}, | ||
214 | 208 | 3:{True:self._translate_text('Y'), False:self._translate_text('N'), None:""}, | ||
215 | 209 | 4:{True:'+', False:'-', None:""}, | ||
216 | 210 | 5:{True:'[ + ]', False:'[ - ]', None:"[ ]"}, | ||
217 | 211 | 6:{True:'[ x ]', False:'[ ]', None:"[ ]"}, | ||
218 | 212 | 7:{True:'x', False:'', None:""}, | ||
219 | 213 | } | ||
220 | 214 | return bool_kind.get(kind, {}).get(val, val) | ||
221 | 215 | |||
222 | 216 | def _dec2time(self, dec, h_format, min_format): | ||
223 | 217 | if dec==0.0: | ||
224 | 218 | return None | ||
225 | 219 | elif int(dec)==0: | ||
226 | 220 | return min_format.replace('%M', str(int(round((dec-int(dec))*60)))) | ||
227 | 221 | elif dec-int(dec)==0.0: | ||
228 | 222 | return h_format.replace('%H', str(int(dec))) | ||
229 | 223 | else: | ||
230 | 224 | return h_format.replace('%H', str(int(dec)))+min_format.replace('%M', str(int(round((dec-int(dec))*60)))) | ||
231 | 225 | |||
232 | 226 | def _currency2text(self, currency): | ||
233 | 227 | def c_to_text(sum, currency=currency, language=None): | ||
234 | 228 | return unicode(supported_language.get(language or self._get_lang()).currency_to_text(sum, currency), "UTF-8") | ||
235 | 229 | return c_to_text | ||
236 | 230 | |||
237 | 231 | def _translate_text(self, source): | ||
238 | 232 | trans_obj = self.pool.get('ir.translation') | ||
239 | 233 | trans = trans_obj.search(self.cr,self.uid,[('res_id','=',self.report_id),('type','=','report'),('src','=',source),('lang','=',self.context['lang'] or self.context['user_lang'])]) | ||
240 | 234 | if not trans: | ||
241 | 235 | #trans_obj.create(self.cr, self.uid, {'src':source,'type':'report','lang':self._get_lang(),'res_id':self.report_id,'name':('ir.actions.report.xml,%s' % source)[:128]}) | ||
242 | 236 | trans_obj.create(self.cr, self.uid, {'src':source,'type':'report','lang':self._get_lang(),'res_id':self.report_id,'name':'ir.actions.report.xml'}) | ||
243 | 237 | return translate(self.cr, 'ir.actions.report.xml', 'report', self._get_lang(), source) or source | ||
244 | 238 | |||
245 | 239 | def _countif(self, attr, domain): | ||
246 | 240 | statement = domain2statement(domain) | ||
247 | 241 | expr = "for o in objects:\n\tif%s:\n\t\tcount+=1" % statement | ||
248 | 242 | localspace = {'objects':attr, 'count':0} | ||
249 | 243 | exec expr in localspace | ||
250 | 244 | return localspace['count'] | ||
251 | 245 | |||
252 | 246 | def _count_blank(self, attr, field): | ||
253 | 247 | expr = "for o in objects:\n\tif not o.%s:\n\t\tcount+=1" % field | ||
254 | 248 | localspace = {'objects':attr, 'count':0} | ||
255 | 249 | exec expr in localspace | ||
256 | 250 | return localspace['count'] | ||
257 | 251 | |||
258 | 252 | def _count(self, attr): | ||
259 | 253 | return len(attr) | ||
260 | 254 | |||
261 | 255 | def _sumif(self, attr, sum_field, domain): | ||
262 | 256 | statement = domain2statement(domain) | ||
263 | 257 | expr = "for o in objects:\n\tif%s:\n\t\tsumm+=float(o.%s)" % (statement, sum_field) | ||
264 | 258 | localspace = {'objects':attr, 'summ':0} | ||
265 | 259 | exec expr in localspace | ||
266 | 260 | return localspace['summ'] | ||
267 | 261 | |||
268 | 262 | def _sum(self, attr, sum_field): | ||
269 | 263 | expr = "for o in objects:\n\tsumm+=float(o.%s)" % sum_field | ||
270 | 264 | localspace = {'objects':attr, 'summ':0} | ||
271 | 265 | exec expr in localspace | ||
272 | 266 | return localspace['summ'] | ||
273 | 267 | |||
274 | 268 | def _max(self, attr, field): | ||
275 | 269 | expr = "for o in objects:\n\tvalue_list.append(o.%s)" % field | ||
276 | 270 | localspace = {'objects':attr, 'value_list':[]} | ||
277 | 271 | exec expr in localspace | ||
278 | 272 | return max(localspace['value_list']) | ||
279 | 273 | |||
280 | 274 | def _min(self, attr, field): | ||
281 | 275 | expr = "for o in objects:\n\tvalue_list.append(o.%s)" % field | ||
282 | 276 | localspace = {'objects':attr, 'value_list':[]} | ||
283 | 277 | exec expr in localspace | ||
284 | 278 | return min(localspace['value_list']) | ||
285 | 279 | |||
286 | 280 | def _average(self, attr, field): | ||
287 | 281 | expr = "for o in objects:\n\tvalue_list.append(o.%s)" % field | ||
288 | 282 | localspace = {'objects':attr, 'value_list':[]} | ||
289 | 283 | exec expr in localspace | ||
290 | 284 | return float(sum(localspace['value_list']))/float(len(localspace['value_list'])) | ||
291 | 285 | |||
292 | 286 | def _asarray(self, attr, field): | ||
293 | 287 | expr = "for o in objects:\n\tvalue_list.append(o.%s)" % field | ||
294 | 288 | localspace = {'objects':attr, 'value_list':[]} | ||
295 | 289 | exec expr in localspace | ||
296 | 290 | return localspace['value_list'] | ||
297 | 291 | |||
298 | 292 | def _get_name(self, obj): | ||
299 | 293 | if obj.__class__== orm.browse_record: | ||
300 | 294 | return self.pool.get(obj._table_name).name_get(self.cr, self.uid, [obj.id], {'lang':self._get_lang()})[0][1] | ||
301 | 295 | elif type(obj)==str: # only for fields in root record | ||
302 | 296 | model = self.context['model'] | ||
303 | 297 | field, rec_id = obj.split(',') | ||
304 | 298 | rec_id = int(rec_id) | ||
305 | 299 | if rec_id: | ||
306 | 300 | field_data = self.pool.get(model).fields_get(self.cr, self.uid, [field], context=self.context) | ||
307 | 301 | return self.pool.get(field_data[field]['relation']).name_get(self.cr, self.uid, [rec_id], {'lang':self._get_lang()})[0][1] | ||
308 | 302 | else: | ||
309 | 303 | return '' | ||
310 | 304 | return '' | ||
311 | 305 | |||
312 | 306 | def _get_label(self, obj, field): | ||
313 | 307 | if not obj: | ||
314 | 308 | return '' | ||
315 | 309 | try: | ||
316 | 310 | if isinstance(obj, report_sxw.browse_record_list): | ||
317 | 311 | obj = obj[0] | ||
318 | 312 | if isinstance(obj, (str,unicode)): | ||
319 | 313 | model = obj | ||
320 | 314 | else: | ||
321 | 315 | model = obj._table_name | ||
322 | 316 | if isinstance(obj, (str,unicode)) or hasattr(obj, field): | ||
323 | 317 | labels = self.pool.get(model).fields_get(self.cr, self.uid, allfields=[field], context=self.context) | ||
324 | 318 | return labels[field]['string'] | ||
325 | 319 | except Exception, e: | ||
326 | 320 | return '' | ||
327 | 321 | |||
328 | 322 | def _field_size(self, obj, field): | ||
329 | 323 | try: | ||
330 | 324 | if isinstance(obj, report_sxw.browse_record_list): | ||
331 | 325 | obj = obj[0] | ||
332 | 326 | if isinstance(obj, (str,unicode)): | ||
333 | 327 | model = obj | ||
334 | 328 | else: | ||
335 | 329 | model = obj._table_name | ||
336 | 330 | if isinstance(obj, (str,unicode)) or hasattr(obj, field): | ||
337 | 331 | size = self.pool.get(model)._columns[field].size | ||
338 | 332 | return size | ||
339 | 333 | except Exception, e: | ||
340 | 334 | return '' | ||
341 | 335 | |||
342 | 336 | def _field_accuracy(self, obj, field): | ||
343 | 337 | try: | ||
344 | 338 | if isinstance(obj, report_sxw.browse_record_list): | ||
345 | 339 | obj = obj[0] | ||
346 | 340 | if isinstance(obj, (str,unicode)): | ||
347 | 341 | model = obj | ||
348 | 342 | else: | ||
349 | 343 | model = obj._table_name | ||
350 | 344 | if isinstance(obj, (str,unicode)) or hasattr(obj, field): | ||
351 | 345 | digits = self.pool.get(model)._columns[field].digits | ||
352 | 346 | return digits or [16,2] | ||
353 | 347 | except Exception: | ||
354 | 348 | return [] | ||
355 | 349 | |||
356 | 350 | def _get_selection_items(self, kind='items'): | ||
357 | 351 | def get_selection_item(obj, field, value=None): | ||
358 | 352 | try: | ||
359 | 353 | if isinstance(obj, report_sxw.browse_record_list): | ||
360 | 354 | obj = obj[0] | ||
361 | 355 | if isinstance(obj, (str,unicode)): | ||
362 | 356 | model = obj | ||
363 | 357 | field_val = value | ||
364 | 358 | else: | ||
365 | 359 | model = obj._table_name | ||
366 | 360 | field_val = getattr(obj, field) | ||
367 | 361 | if kind=='item': | ||
368 | 362 | if field_val: | ||
369 | 363 | return dict(self.pool.get(model).fields_get(self.cr, self.uid, allfields=[field], context=self.context)[field]['selection'])[field_val] | ||
370 | 364 | elif kind=='items': | ||
371 | 365 | return self.pool.get(model).fields_get(self.cr, self.uid, allfields=[field], context=self.context)[field]['selection'] | ||
372 | 366 | return '' | ||
373 | 367 | except Exception: | ||
374 | 368 | return '' | ||
375 | 369 | return get_selection_item | ||
376 | 370 | |||
377 | 371 | def _get_attachments(self, o, index=None, raw=False): | ||
378 | 372 | attach_obj = self.pool.get('ir.attachment') | ||
379 | 373 | srch_param = [('res_model','=',o._name),('res_id','=',o.id)] | ||
380 | 374 | if type(index)==str: | ||
381 | 375 | srch_param.append(('name','=',index)) | ||
382 | 376 | attachments = attach_obj.search(self.cr,self.uid,srch_param) | ||
383 | 377 | res = [x['datas'] for x in attach_obj.read(self.cr,self.uid,attachments,['datas']) if x['datas']] | ||
384 | 378 | convert = raw and base64.decodestring or (lambda a: a) | ||
385 | 379 | if type(index)==int: | ||
386 | 380 | return convert(res[index]) | ||
387 | 381 | return convert(len(res)==1 and res[0] or res) | ||
388 | 382 | |||
389 | 383 | def _asimage(self, field_value, rotate=None, size_x=None, size_y=None, uom='px', hold_ratio=False): | ||
390 | 384 | def size_by_uom(val, uom, dpi): | ||
391 | 385 | if uom=='px': | ||
392 | 386 | result=str(val/dpi)+'in' | ||
393 | 387 | elif uom=='cm': | ||
394 | 388 | result=str(val/2.54)+'in' | ||
395 | 389 | elif uom=='in': | ||
396 | 390 | result=str(val)+'in' | ||
397 | 391 | return result | ||
398 | 392 | ############################################## | ||
399 | 393 | if not field_value: | ||
400 | 394 | return StringIO.StringIO(), 'image/png' | ||
401 | 395 | field_value = base64.decodestring(field_value) | ||
402 | 396 | tf = StringIO.StringIO(field_value) | ||
403 | 397 | tf.seek(0) | ||
404 | 398 | try: | ||
405 | 399 | im=Image.open(tf) | ||
406 | 400 | format = im.format.lower() | ||
407 | 401 | dpi_x, dpi_y = map(float, im.info.get('dpi', (96, 96))) | ||
408 | 402 | except Exception, e: | ||
409 | 403 | raise orm.except_orm('Error', e) | ||
410 | 404 | try: | ||
411 | 405 | if rotate!=None: | ||
412 | 406 | im=im.rotate(int(rotate)) | ||
413 | 407 | tf.seek(0) | ||
414 | 408 | im.save(tf, format) | ||
415 | 409 | except Exception, e: | ||
416 | 410 | raise orm.except_orm('Error', e) | ||
417 | 411 | |||
418 | 412 | if hold_ratio: | ||
419 | 413 | img_ratio = im.size[0] / float(im.size[1]) # width / height | ||
420 | 414 | if size_x and not size_y: | ||
421 | 415 | size_y = size_x / img_ratio | ||
422 | 416 | elif not size_x and size_y: | ||
423 | 417 | size_x = size_y * img_ratio | ||
424 | 418 | elif size_x and size_y: | ||
425 | 419 | size_y2 = size_x / img_ratio | ||
426 | 420 | size_x2 = size_y * img_ratio | ||
427 | 421 | if size_y2 > size_y: | ||
428 | 422 | size_x = size_x2 | ||
429 | 423 | elif size_x2 > size_x: | ||
430 | 424 | size_y = size_y2 | ||
431 | 425 | |||
432 | 426 | size_x = size_x and size_by_uom(size_x, uom, dpi_x) or str(im.size[0]/dpi_x)+'in' | ||
433 | 427 | size_y = size_y and size_by_uom(size_y, uom, dpi_y) or str(im.size[1]/dpi_y)+'in' | ||
434 | 428 | return tf, 'image/%s' % format, size_x, size_y | ||
435 | 429 | |||
436 | 430 | def _embed_image(self, extention, img, width=0, height=0, raw=False): | ||
437 | 431 | "Transform a DB image into an embeded HTML image" | ||
438 | 432 | if not img: | ||
439 | 433 | return '' | ||
440 | 434 | try: | ||
441 | 435 | if width : | ||
442 | 436 | width = ' width="%spx"'%(width) | ||
443 | 437 | else : | ||
444 | 438 | width = '' | ||
445 | 439 | if height : | ||
446 | 440 | height = 'height="%spx" '%(height) | ||
447 | 441 | else : | ||
448 | 442 | height = '' | ||
449 | 443 | if raw: | ||
450 | 444 | toreturn = 'data:image/%s;base64,%s' % (extention, ''.join(str(img).splitlines())) | ||
451 | 445 | else: | ||
452 | 446 | toreturn = '<img%s %ssrc="data:image/%s;base64,%s">' % (width, height, extention, str(img)) | ||
453 | 447 | return toreturn | ||
454 | 448 | except Exception, exp: | ||
455 | 449 | return 'No image' | ||
456 | 450 | |||
457 | 451 | def _large(self, attr, field, n): | ||
458 | 452 | array=self._asarray(attr, field) | ||
459 | 453 | try: | ||
460 | 454 | n-=1 | ||
461 | 455 | while(n): | ||
462 | 456 | array.remove(max(array)) | ||
463 | 457 | n-=1 | ||
464 | 458 | return max(array) | ||
465 | 459 | except ValueError, e: | ||
466 | 460 | return None | ||
467 | 461 | |||
468 | 462 | def _small(self, attr, field, n): | ||
469 | 463 | array=self._asarray(attr, field) | ||
470 | 464 | try: | ||
471 | 465 | n-=1 | ||
472 | 466 | while(n): | ||
473 | 467 | array.remove(min(array)) | ||
474 | 468 | n-=1 | ||
475 | 469 | return min(array) | ||
476 | 470 | except ValueError, e: | ||
477 | 471 | return None | ||
478 | 472 | |||
479 | 473 | def _chunks(self, l, n): | ||
480 | 474 | """ Yield successive n-sized chunks from l. | ||
481 | 475 | """ | ||
482 | 476 | for i in xrange(0, len(l), n): | ||
483 | 477 | yield l[i:i+n] | ||
484 | 478 | |||
485 | 479 | def _search_ids(self, model, domain): | ||
486 | 480 | obj = self.pool.get(model) | ||
487 | 481 | return obj.search(self.cr, self.uid, domain) | ||
488 | 482 | |||
489 | 483 | def _search(self, model, domain, context=None): | ||
490 | 484 | obj = self.pool.get(model) | ||
491 | 485 | ids = obj.search(self.cr, self.uid, domain) | ||
492 | 486 | if context is None: | ||
493 | 487 | context = {} | ||
494 | 488 | context['lang'] = self._get_lang() | ||
495 | 489 | return obj.browse(self.cr, self.uid, ids, context=context) | ||
496 | 490 | |||
497 | 491 | def _browse(self, *args): | ||
498 | 492 | if not args or (args and not args[0]): | ||
499 | 493 | return None | ||
500 | 494 | if len(args)==1: | ||
501 | 495 | model, id = args[0].split(',') | ||
502 | 496 | id = int(id) | ||
503 | 497 | elif len(args)==2: | ||
504 | 498 | model, id = args | ||
505 | 499 | else: | ||
506 | 500 | raise None | ||
507 | 501 | return self.pool.get(model).browse(self.cr, self.uid, id) | ||
508 | 502 | |||
509 | 503 | def _get_safe(self, expression, obj): | ||
510 | 504 | try: | ||
511 | 505 | return eval(expression, {'o':obj}) | ||
512 | 506 | except Exception, e: | ||
513 | 507 | return None | ||
514 | 508 | |||
515 | 509 | def debugit(self, object): | ||
516 | 510 | """ Run the server from command line and | ||
517 | 511 | call 'debugit' from the template to inspect variables. | ||
518 | 512 | """ | ||
519 | 513 | import pdb;pdb.set_trace() | ||
520 | 514 | return | ||
521 | 515 | |||
522 | 516 | def _itemize(self, array, purefalse = False, base_num = 1): | ||
523 | 517 | it = iter(array) | ||
524 | 518 | falseval = purefalse and False or '' | ||
525 | 519 | e = it.next() | ||
526 | 520 | lind = 0 | ||
527 | 521 | while True: | ||
528 | 522 | lind += 1 | ||
529 | 523 | is_even = lind%2 == 0 or falseval | ||
530 | 524 | is_odd = not is_even or falseval | ||
531 | 525 | is_first = lind == 1 or falseval | ||
532 | 526 | try: | ||
533 | 527 | nxt = it.next() | ||
534 | 528 | yield (lind-1, lind+base_num-1, e, is_even, is_odd, is_first, falseval) | ||
535 | 529 | e = nxt | ||
536 | 530 | except StopIteration: | ||
537 | 531 | yield (lind-1, lind+base_num-1, e, is_even, is_odd, is_first, True) | ||
538 | 532 | break | ||
539 | 533 | |||
540 | 534 | def _html_escape(self, s): | ||
541 | 535 | toesc={ '<': '<', | ||
542 | 536 | '>': '>', | ||
543 | 537 | '&': '&', | ||
544 | 538 | '"': '"', | ||
545 | 539 | "'": ''' } | ||
546 | 540 | |||
547 | 541 | if type(s) is str: | ||
548 | 542 | s.decode() | ||
549 | 543 | try: | ||
550 | 544 | return ''.join(map(lambda a: toesc.get(a, a), s)) | ||
551 | 545 | except TypeError: | ||
552 | 546 | return s | ||
553 | 547 | |||
554 | 548 | def _html_remove(self, s): | ||
555 | 549 | def replace_specifics(s): | ||
556 | 550 | list_to_change = { | ||
557 | 551 | '<': '<', | ||
558 | 552 | '>': '>', | ||
559 | 553 | '&': '&' , | ||
560 | 554 | '"': '"', | ||
561 | 555 | ''': "'" | ||
562 | 556 | } | ||
563 | 557 | for key1 in list_to_change.keys(): | ||
564 | 558 | s = s.replace(key1, list_to_change[key1]) | ||
565 | 559 | return s | ||
566 | 560 | try: | ||
567 | 561 | return replace_specifics(nltk.clean_html(s)) | ||
568 | 562 | except Exception, e: | ||
569 | 563 | raise orm.except_orm('Error', e) | ||
570 | 564 | |||
571 | 565 | def _http_prettyuri(self, s): | ||
572 | 566 | def do_filter(c): | ||
573 | 567 | # filter out reserved and "unsafe" characters | ||
574 | 568 | pos = '''<>$&+,/\:;=?@'"#%{}|^~[]()`'''.find(c) | ||
575 | 569 | if pos >= 0: return False | ||
576 | 570 | |||
577 | 571 | # filter out ASCII Control characters and unhandled Non-ASCII characters | ||
578 | 572 | ordc = ord(c) | ||
579 | 573 | if (ordc >= 0 and ordc <= 31) or (ordc >= 127 and ordc <= 255): return False | ||
580 | 574 | return c | ||
581 | 575 | |||
582 | 576 | if type(s) is str: s.decode() | ||
583 | 577 | # tranlate specific latvian characters into latin and whitespace into dash | ||
584 | 578 | tt = dict(zip(map(ord, 'āčēģīķļņōŗšūžĀČĒĢĪĶĻŅŌŖŠŪŽ '.decode()), 'acegiklnorsuzACEGIKLNORSUZ-'.decode())) | ||
585 | 579 | try: | ||
586 | 580 | s = s.translate(tt) | ||
587 | 581 | return (filter(do_filter, s)).lower() | ||
588 | 582 | except TypeError: | ||
589 | 583 | return s | ||
590 | 584 | |||
591 | 585 | def _http_builduri(self, *dicts): | ||
592 | 586 | d = {} | ||
593 | 587 | for ind in dicts: | ||
594 | 588 | d.update(ind) | ||
595 | 589 | result = '' | ||
596 | 590 | for pair in d.iteritems(): | ||
597 | 591 | result += '&%s=%s' % pair | ||
598 | 592 | return result | ||
599 | 593 | |||
600 | 594 | def _text_restruct(self, text): | ||
601 | 595 | output = html_parts(unicode(text), doctitle=False) | ||
602 | 596 | return output['body'] | ||
603 | 597 | |||
604 | 598 | def _text_markdown(self, text): | ||
605 | 599 | md = Markdown() | ||
606 | 600 | return md.convert(text) | ||
607 | 601 | |||
608 | 602 | def _text_wiki(self, text): | ||
609 | 603 | return wiki2html(text, True) | ||
610 | 604 | |||
611 | 605 | def _text_plain(self, msg): | ||
612 | 606 | def text_plain(text): | ||
613 | 607 | _logger.info(msg) | ||
614 | 608 | return text | ||
615 | 609 | return text_plain | ||
616 | 610 | |||
617 | 611 | def _text_markup(self, text): | ||
618 | 612 | lines = text.splitlines() | ||
619 | 613 | first_line = lines.pop(0) | ||
620 | 614 | if first_line=='text/x-markdown': | ||
621 | 615 | return self._text_markdown('\n'.join(lines)) | ||
622 | 616 | elif first_line=='text/x-wiki': | ||
623 | 617 | return self._text_wiki('\n'.join(lines)) | ||
624 | 618 | elif first_line=='text/x-rst': | ||
625 | 619 | return self._text_rest('\n'.join(lines)) | ||
626 | 620 | return text | ||
627 | 621 | |||
628 | 622 | def _specific_lang(self, model, id, lang=False): | ||
629 | 623 | context = self.context | ||
630 | 624 | context['lang'] = lang or self._get_lang() | ||
631 | 625 | obj = self.pool.get(model) | ||
632 | 626 | return obj.browse(self.cr, self.uid, id, context=context) | ||
633 | 627 | |||
634 | 628 | def _invoice_lines(self, lines): | ||
635 | 629 | result = [] | ||
636 | 630 | res = {} | ||
637 | 631 | for entry in lines: | ||
638 | 632 | flag = False | ||
639 | 633 | for res in result: | ||
640 | 634 | if entry.product_id == res.product_id and entry.price_unit == res.price_unit \ | ||
641 | 635 | and entry.invoice_line_tax_id == res.invoice_line_tax_id and entry.discount == res.discount: | ||
642 | 636 | res.quantity += entry.quantity | ||
643 | 637 | res.price_subtotal += entry.price_subtotal | ||
644 | 638 | flag = True | ||
645 | 639 | if flag == False: | ||
646 | 640 | result.append(entry) | ||
647 | 641 | return result | ||
648 | 642 | |||
649 | 643 | def _location(self): | ||
650 | 644 | if self.context is None: | ||
651 | 645 | self.context = {} | ||
652 | 646 | location_name = '' | ||
653 | 647 | if self.context.get('location'): | ||
654 | 648 | location_name = self.pool.get('stock.location').read(self.cr, self.uid, | ||
655 | 649 | self.context.get('location'), ['name'], context = self.context)['name'] | ||
656 | 650 | return location_name | ||
657 | 651 | |||
658 | 652 | def _sort_by(self, attr, field): | ||
659 | 653 | expr = "for o in objects:\n\tdict_vals[o] = o.%s or ''" % field | ||
660 | 654 | localspace = {'objects':attr, 'dict_vals':{}} | ||
661 | 655 | exec expr in localspace | ||
662 | 656 | return [o for o, val in sorted(localspace['dict_vals'].items(), key=lambda x: x[1])] | ||
663 | 657 | |||
664 | 658 | def _group_by(self, attr, field): | ||
665 | 659 | expr = "for o in objects:\n\tdict_vals.setdefault(o.%s or '', [])\n\tdict_vals[o.%s or ''].append(o)" % (field, field) | ||
666 | 660 | localspace = {'objects':attr, 'dict_vals':{}} | ||
667 | 661 | exec expr in localspace | ||
668 | 662 | return sorted(localspace['dict_vals'].items(), key=lambda x: x[0]) | ||
669 | 663 | |||
670 | 664 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
671 | 0 | 665 | ||
672 | === added file 'report_aeroo/__init__.py' | |||
673 | --- report_aeroo/__init__.py 1970-01-01 00:00:00 +0000 | |||
674 | +++ report_aeroo/__init__.py 2014-04-05 13:18:49 +0000 | |||
675 | @@ -0,0 +1,52 @@ | |||
676 | 1 | # -*- coding: utf-8 -*- | ||
677 | 2 | ############################################################################## | ||
678 | 3 | # | ||
679 | 4 | # Copyright (c) 2009-2012 Alistek Ltd (http://www.alistek.com) All Rights Reserved. | ||
680 | 5 | # General contacts <info@alistek.com> | ||
681 | 6 | # | ||
682 | 7 | # WARNING: This program as such is intended to be used by professional | ||
683 | 8 | # programmers who take the whole responsability of assessing all potential | ||
684 | 9 | # consequences resulting from its eventual inadequacies and bugs | ||
685 | 10 | # End users who are looking for a ready-to-use solution with commercial | ||
686 | 11 | # garantees and support are strongly adviced to contract a Free Software | ||
687 | 12 | # Service Company | ||
688 | 13 | # | ||
689 | 14 | # This program is Free Software; you can redistribute it and/or | ||
690 | 15 | # modify it under the terms of the GNU General Public License | ||
691 | 16 | # as published by the Free Software Foundation; either version 3 | ||
692 | 17 | # of the License, or (at your option) any later version. | ||
693 | 18 | # | ||
694 | 19 | # This module is GPLv3 or newer and incompatible | ||
695 | 20 | # with OpenERP SA "AGPL + Private Use License"! | ||
696 | 21 | # | ||
697 | 22 | # This program is distributed in the hope that it will be useful, | ||
698 | 23 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
699 | 24 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
700 | 25 | # GNU General Public License for more details. | ||
701 | 26 | # | ||
702 | 27 | # You should have received a copy of the GNU General Public License | ||
703 | 28 | # along with this program; if not, write to the Free Software | ||
704 | 29 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
705 | 30 | # | ||
706 | 31 | ############################################################################## | ||
707 | 32 | |||
708 | 33 | import aeroolib | ||
709 | 34 | from genshi.template import NewTextTemplate | ||
710 | 35 | |||
711 | 36 | check_list = [ | ||
712 | 37 | 'import aeroolib', | ||
713 | 38 | 'import genshi', | ||
714 | 39 | 'from genshi.template import NewTextTemplate', | ||
715 | 40 | 'from xml.dom import minidom', | ||
716 | 41 | ] | ||
717 | 42 | |||
718 | 43 | from check_deps import check_deps | ||
719 | 44 | check_deps(check_list) | ||
720 | 45 | |||
721 | 46 | import installer | ||
722 | 47 | import translate | ||
723 | 48 | import report_xml | ||
724 | 49 | import report_aeroo | ||
725 | 50 | import wizard | ||
726 | 51 | |||
727 | 52 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
728 | 0 | 53 | ||
729 | === added file 'report_aeroo/__openerp__.py' | |||
730 | --- report_aeroo/__openerp__.py 1970-01-01 00:00:00 +0000 | |||
731 | +++ report_aeroo/__openerp__.py 2014-04-05 13:18:49 +0000 | |||
732 | @@ -0,0 +1,82 @@ | |||
733 | 1 | # -*- coding: utf-8 -*- | ||
734 | 2 | ######################################################################## | ||
735 | 3 | # | ||
736 | 4 | # Copyright (C) 2009 Domsense s.r.l. | ||
737 | 5 | # @authors: Simone Orsi | ||
738 | 6 | # Copyright (C) 2009-2013 Alistek Ltd | ||
739 | 7 | # | ||
740 | 8 | #This program is free software: you can redistribute it and/or modify | ||
741 | 9 | #it under the terms of the GNU General Public License as published by | ||
742 | 10 | #the Free Software Foundation, either version 3 of the License, or | ||
743 | 11 | #(at your option) any later version. | ||
744 | 12 | # | ||
745 | 13 | # This module is GPLv3 or newer and incompatible | ||
746 | 14 | # with OpenERP SA "AGPL + Private Use License"! | ||
747 | 15 | # | ||
748 | 16 | #This program is distributed in the hope that it will be useful, | ||
749 | 17 | #but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
750 | 18 | #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
751 | 19 | #GNU General Public License for more details. | ||
752 | 20 | # | ||
753 | 21 | #You should have received a copy of the GNU General Public License | ||
754 | 22 | #along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
755 | 23 | ######################################################################## | ||
756 | 24 | |||
757 | 25 | { | ||
758 | 26 | 'name': 'Aeroo Reports', | ||
759 | 27 | 'version': '1.2', | ||
760 | 28 | 'category': 'Generic Modules/Aeroo Reporting', | ||
761 | 29 | 'description': """ | ||
762 | 30 | Aeroo Reports for OpenERP is a comprehensive reporting engine based on Aeroo Library. | ||
763 | 31 | |||
764 | 32 | Report templates can be created directly in of following formats: | ||
765 | 33 | ================================================================= | ||
766 | 34 | * Open Document Format (ODF) - .odt, .ods; | ||
767 | 35 | * Other ASCII based formats, like HTML, CSV, etc. | ||
768 | 36 | |||
769 | 37 | Output formats: | ||
770 | 38 | ================================================================= | ||
771 | 39 | * Open Document Format (ODF) - .odt, .ods; | ||
772 | 40 | * Other ASCII based formats, like HTML, CSV, etc. | ||
773 | 41 | * with report_aeroo_ooo [1] module - PDF, DOC, XLS, CSV. | ||
774 | 42 | |||
775 | 43 | Reporting engine features: | ||
776 | 44 | ================================================================= | ||
777 | 45 | * Add reports from UI "on the fly"; | ||
778 | 46 | * Install reports from module; | ||
779 | 47 | * Dynamic template load/unload; | ||
780 | 48 | * Extra Functions - set of functions for rapid template development; | ||
781 | 49 | * Use templates stored on filesystem, database or elsewhere; | ||
782 | 50 | * Same button - different templates; | ||
783 | 51 | * Powerful stylesheet system for ODF templates; | ||
784 | 52 | * Global or local stylesheets; | ||
785 | 53 | * Template preloading for performance concerns; | ||
786 | 54 | * User defined parsers; | ||
787 | 55 | * Report deactivation; | ||
788 | 56 | * Tunable format fallback; | ||
789 | 57 | * Add/Remove print button wizards; | ||
790 | 58 | * Test report on particular object ID, directly from Report form; | ||
791 | 59 | * Translatable reports; | ||
792 | 60 | * Translation export; | ||
793 | 61 | * Number of copies; | ||
794 | 62 | * Universal Report wizard; | ||
795 | 63 | * Override report file extension (for direct printing, etc); | ||
796 | 64 | * Separate input/output format selections; | ||
797 | 65 | |||
798 | 66 | [1] For more information on available template -> output pairs and other features, see description of report_aeroo_ooo module. | ||
799 | 67 | |||
800 | 68 | => You need to install python-nltk on your machine | ||
801 | 69 | """, | ||
802 | 70 | 'author': 'Alistek Ltd, Simone Orsi - Domsense', | ||
803 | 71 | 'website': 'http://www.alistek.com', | ||
804 | 72 | 'complexity': "easy", | ||
805 | 73 | 'depends': ['base'], | ||
806 | 74 | "init_xml" : [], | ||
807 | 75 | 'update_xml': ["installer.xml", "report_view.xml", "data/report_aeroo_data.xml", "wizard/add_print_button_view.xml", "wizard/remove_print_button_view.xml", "security/ir.model.access.csv"], | ||
808 | 76 | "license" : "GPL-3 or any later version", | ||
809 | 77 | 'installable': True, | ||
810 | 78 | 'active': False, | ||
811 | 79 | 'application': True, | ||
812 | 80 | } | ||
813 | 81 | |||
814 | 82 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
815 | 0 | 83 | ||
816 | === added directory 'report_aeroo/barcode' | |||
817 | === added file 'report_aeroo/barcode/EANBarCode.py' | |||
818 | --- report_aeroo/barcode/EANBarCode.py 1970-01-01 00:00:00 +0000 | |||
819 | +++ report_aeroo/barcode/EANBarCode.py 2014-04-05 13:18:49 +0000 | |||
820 | @@ -0,0 +1,159 @@ | |||
821 | 1 | # Copyright (c) 2009-2011 Alistek Ltd (http://www.alistek.com) All Rights Reserved. | ||
822 | 2 | # General contacts <info@alistek.com> | ||
823 | 3 | |||
824 | 4 | from openerp.tools import config, ustr | ||
825 | 5 | fontsize = 15 | ||
826 | 6 | |||
827 | 7 | """ | ||
828 | 8 | This class generate EAN bar code, it required PIL (python imaging library) | ||
829 | 9 | installed. | ||
830 | 10 | |||
831 | 11 | If the code has not checksum (12 digits), it added automatically. | ||
832 | 12 | |||
833 | 13 | Create bar code sample : | ||
834 | 14 | from EANBarCode import EanBarCode | ||
835 | 15 | bar = EanBarCode() | ||
836 | 16 | bar.getImage("9782212110708",50,"gif") | ||
837 | 17 | |||
838 | 18 | """ | ||
839 | 19 | |||
840 | 20 | class EanBarCode: | ||
841 | 21 | """ Compute the EAN bar code """ | ||
842 | 22 | def __init__(self): | ||
843 | 23 | A = {0 : "0001101", 1 : "0011001", 2 : "0010011", 3 : "0111101", 4 : "0100011", | ||
844 | 24 | 5 : "0110001", 6 : "0101111", 7 : "0111011", 8 : "0110111", 9 : "0001011"} | ||
845 | 25 | B = {0 : "0100111", 1 : "0110011", 2 : "0011011", 3 : "0100001", 4 : "0011101", | ||
846 | 26 | 5 : "0111001", 6 : "0000101", 7 : "0010001", 8 : "0001001", 9 : "0010111"} | ||
847 | 27 | C = {0 : "1110010", 1 : "1100110", 2 : "1101100", 3 : "1000010", 4 : "1011100", | ||
848 | 28 | 5 : "1001110", 6 : "1010000", 7 : "1000100", 8 : "1001000", 9 : "1110100"} | ||
849 | 29 | self.groupC = C | ||
850 | 30 | |||
851 | 31 | self.family = {0 : (A,A,A,A,A,A), 1 : (A,A,B,A,B,B), 2 : (A,A,B,B,A,B), 3 : (A,A,B,B,B,A), 4 : (A,B,A,A,B,B), | ||
852 | 32 | 5 : (A,B,B,A,A,B), 6 : (A,B,B,B,A,A), 7 : (A,B,A,B,A,B), 8 : (A,B,A,B,B,A), 9 : (A,B,B,A,B,A)} | ||
853 | 33 | |||
854 | 34 | |||
855 | 35 | def makeCode(self, code): | ||
856 | 36 | """ Create the binary code | ||
857 | 37 | return a string which contains "0" for white bar, "1" for black bar, "L" for long bar """ | ||
858 | 38 | |||
859 | 39 | # Convert code string in integer list | ||
860 | 40 | self.EAN13 = [] | ||
861 | 41 | for digit in code: | ||
862 | 42 | self.EAN13.append(int(digit)) | ||
863 | 43 | |||
864 | 44 | # If the code has already a checksum | ||
865 | 45 | if len(self.EAN13) == 13: | ||
866 | 46 | # Verify checksum | ||
867 | 47 | self.verifyChecksum(self.EAN13) | ||
868 | 48 | # If the code has not yet checksum | ||
869 | 49 | elif len(self.EAN13) == 12: | ||
870 | 50 | # Add checksum value | ||
871 | 51 | self.EAN13.append(self.computeChecksum(self.EAN13)) | ||
872 | 52 | |||
873 | 53 | # Get the left codage class | ||
874 | 54 | left = self.family[self.EAN13[0]] | ||
875 | 55 | |||
876 | 56 | # Add start separator | ||
877 | 57 | strCode = 'L0L' | ||
878 | 58 | |||
879 | 59 | # Compute the left part of bar code | ||
880 | 60 | for i in range(0,6): | ||
881 | 61 | strCode += left[i][self.EAN13[i+1]] | ||
882 | 62 | |||
883 | 63 | # Add middle separator | ||
884 | 64 | strCode += '0L0L0' | ||
885 | 65 | |||
886 | 66 | # Compute the right codage class | ||
887 | 67 | for i in range (7,13): | ||
888 | 68 | strCode += self.groupC[self.EAN13[i]] | ||
889 | 69 | |||
890 | 70 | # Add stop separator | ||
891 | 71 | strCode += 'L0L' | ||
892 | 72 | |||
893 | 73 | return strCode | ||
894 | 74 | |||
895 | 75 | |||
896 | 76 | def computeChecksum(self, arg): | ||
897 | 77 | """ Compute the checksum of bar code """ | ||
898 | 78 | # UPCA/EAN13 | ||
899 | 79 | weight=[1,3]*6 | ||
900 | 80 | magic=10 | ||
901 | 81 | sum = 0 | ||
902 | 82 | |||
903 | 83 | for i in range(12): # checksum based on first 12 digits. | ||
904 | 84 | sum = sum + int(arg[i]) * weight[i] | ||
905 | 85 | z = ( magic - (sum % magic) ) % magic | ||
906 | 86 | if z < 0 or z >= magic: | ||
907 | 87 | return None | ||
908 | 88 | return z | ||
909 | 89 | |||
910 | 90 | |||
911 | 91 | def verifyChecksum(self, bits): | ||
912 | 92 | """ Verify the checksum """ | ||
913 | 93 | computedChecksum = self.computeChecksum(bits[:12]) | ||
914 | 94 | codeBarChecksum = bits[12] | ||
915 | 95 | |||
916 | 96 | if codeBarChecksum != computedChecksum: | ||
917 | 97 | raise Exception ("Bad checksum is %s and should be %s"%(codeBarChecksum, computedChecksum)) | ||
918 | 98 | |||
919 | 99 | |||
920 | 100 | def getImage(self, value, height = 50, xw=1, rotate=None, extension = "PNG"): | ||
921 | 101 | """ Get an image with PIL library | ||
922 | 102 | value code barre value | ||
923 | 103 | height height in pixel of the bar code | ||
924 | 104 | extension image file extension""" | ||
925 | 105 | from PIL import Image, ImageFont, ImageDraw | ||
926 | 106 | import os | ||
927 | 107 | from string import lower, upper | ||
928 | 108 | |||
929 | 109 | # Get the bar code list | ||
930 | 110 | bits = self.makeCode(value) | ||
931 | 111 | |||
932 | 112 | # Get thee bar code with the checksum added | ||
933 | 113 | code = "" | ||
934 | 114 | for digit in self.EAN13: | ||
935 | 115 | code += "%d"%digit | ||
936 | 116 | |||
937 | 117 | # Create a new image | ||
938 | 118 | position = 8 | ||
939 | 119 | im = Image.new("1",(len(bits)+position,height)) | ||
940 | 120 | |||
941 | 121 | # Load font | ||
942 | 122 | ad = os.path.abspath(os.path.join(ustr(config['root_path']), u'addons')) | ||
943 | 123 | mod_path_list = map(lambda m: os.path.abspath(ustr(m.strip())), config['addons_path'].split(',')) | ||
944 | 124 | mod_path_list.append(ad) | ||
945 | 125 | |||
946 | 126 | for mod_path in mod_path_list: | ||
947 | 127 | font_file = mod_path+os.path.sep+ \ | ||
948 | 128 | "report_aeroo"+os.path.sep+"barcode"+os.path.sep+"FreeMonoBold.ttf" | ||
949 | 129 | if os.path.lexists(font_file): | ||
950 | 130 | font = ImageFont.truetype(font_file, fontsize) | ||
951 | 131 | |||
952 | 132 | # Create drawer | ||
953 | 133 | draw = ImageDraw.Draw(im) | ||
954 | 134 | |||
955 | 135 | # Erase image | ||
956 | 136 | draw.rectangle(((0,0),(im.size[0],im.size[1])),fill=256) | ||
957 | 137 | |||
958 | 138 | # Draw first part of number | ||
959 | 139 | draw.text((0, height-9), code[0], font=font, fill=0) | ||
960 | 140 | |||
961 | 141 | # Draw first part of number | ||
962 | 142 | draw.text((position+7, height-9), code[1:7], font=font, fill=0) | ||
963 | 143 | |||
964 | 144 | # Draw second part of number | ||
965 | 145 | draw.text((len(bits)/2+6+position, height-9), code[7:], font=font, fill=0) | ||
966 | 146 | |||
967 | 147 | # Draw the bar codes | ||
968 | 148 | for bit in range(len(bits)): | ||
969 | 149 | # Draw normal bar | ||
970 | 150 | if bits[bit] == '1': | ||
971 | 151 | draw.rectangle(((bit+position,0),(bit+position,height-10)),fill=0) | ||
972 | 152 | # Draw long bar | ||
973 | 153 | elif bits[bit] == 'L': | ||
974 | 154 | draw.rectangle(((bit+position,0),(bit+position,height-3)),fill=0) | ||
975 | 155 | |||
976 | 156 | # Save the result image | ||
977 | 157 | return im | ||
978 | 158 | |||
979 | 159 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
980 | 0 | 160 | ||
981 | === added file 'report_aeroo/barcode/FreeMonoBold.ttf' | |||
982 | 1 | Binary files report_aeroo/barcode/FreeMonoBold.ttf 1970-01-01 00:00:00 +0000 and report_aeroo/barcode/FreeMonoBold.ttf 2014-04-05 13:18:49 +0000 differ | 161 | Binary files report_aeroo/barcode/FreeMonoBold.ttf 1970-01-01 00:00:00 +0000 and report_aeroo/barcode/FreeMonoBold.ttf 2014-04-05 13:18:49 +0000 differ |
983 | === added file 'report_aeroo/barcode/__init__.py' | |||
984 | --- report_aeroo/barcode/__init__.py 1970-01-01 00:00:00 +0000 | |||
985 | +++ report_aeroo/barcode/__init__.py 2014-04-05 13:18:49 +0000 | |||
986 | @@ -0,0 +1,34 @@ | |||
987 | 1 | ############################################################################## | ||
988 | 2 | # | ||
989 | 3 | # Copyright (c) 2008-2011 Alistek Ltd (http://www.alistek.com) All Rights Reserved. | ||
990 | 4 | # General contacts <info@alistek.com> | ||
991 | 5 | # | ||
992 | 6 | # WARNING: This program as such is intended to be used by professional | ||
993 | 7 | # programmers who take the whole responsability of assessing all potential | ||
994 | 8 | # consequences resulting from its eventual inadequacies and bugs | ||
995 | 9 | # End users who are looking for a ready-to-use solution with commercial | ||
996 | 10 | # garantees and support are strongly adviced to contract a Free Software | ||
997 | 11 | # Service Company | ||
998 | 12 | # | ||
999 | 13 | # This program is Free Software; you can redistribute it and/or | ||
1000 | 14 | # modify it under the terms of the GNU General Public License | ||
1001 | 15 | # as published by the Free Software Foundation; either version 3 | ||
1002 | 16 | # of the License, or (at your option) any later version. | ||
1003 | 17 | # | ||
1004 | 18 | # This module is GPLv3 or newer and incompatible | ||
1005 | 19 | # with OpenERP SA "AGPL + Private Use License"! | ||
1006 | 20 | # | ||
1007 | 21 | # This program is distributed in the hope that it will be useful, | ||
1008 | 22 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1009 | 23 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1010 | 24 | # GNU General Public License for more details. | ||
1011 | 25 | # | ||
1012 | 26 | # You should have received a copy of the GNU General Public License | ||
1013 | 27 | # along with this program; if not, write to the Free Software | ||
1014 | 28 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
1015 | 29 | # | ||
1016 | 30 | ############################################################################## | ||
1017 | 31 | |||
1018 | 32 | import barcode | ||
1019 | 33 | |||
1020 | 34 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1021 | 0 | 35 | ||
1022 | === added file 'report_aeroo/barcode/barcode.py' | |||
1023 | --- report_aeroo/barcode/barcode.py 1970-01-01 00:00:00 +0000 | |||
1024 | +++ report_aeroo/barcode/barcode.py 2014-04-05 13:18:49 +0000 | |||
1025 | @@ -0,0 +1,63 @@ | |||
1026 | 1 | ############################################################################## | ||
1027 | 2 | # | ||
1028 | 3 | # Copyright (c) 2008-2011 Alistek Ltd (http://www.alistek.com) All Rights Reserved. | ||
1029 | 4 | # General contacts <info@alistek.com> | ||
1030 | 5 | # | ||
1031 | 6 | # WARNING: This program as such is intended to be used by professional | ||
1032 | 7 | # programmers who take the whole responsability of assessing all potential | ||
1033 | 8 | # consequences resulting from its eventual inadequacies and bugs | ||
1034 | 9 | # End users who are looking for a ready-to-use solution with commercial | ||
1035 | 10 | # garantees and support are strongly adviced to contract a Free Software | ||
1036 | 11 | # Service Company | ||
1037 | 12 | # | ||
1038 | 13 | # This program is Free Software; you can redistribute it and/or | ||
1039 | 14 | # modify it under the terms of the GNU General Public License | ||
1040 | 15 | # as published by the Free Software Foundation; either version 3 | ||
1041 | 16 | # of the License, or (at your option) any later version. | ||
1042 | 17 | # | ||
1043 | 18 | # This module is GPLv3 or newer and incompatible | ||
1044 | 19 | # with OpenERP SA "AGPL + Private Use License"! | ||
1045 | 20 | # | ||
1046 | 21 | # This program is distributed in the hope that it will be useful, | ||
1047 | 22 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1048 | 23 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1049 | 24 | # GNU General Public License for more details. | ||
1050 | 25 | # | ||
1051 | 26 | # You should have received a copy of the GNU General Public License | ||
1052 | 27 | # along with this program; if not, write to the Free Software | ||
1053 | 28 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
1054 | 29 | # | ||
1055 | 30 | ############################################################################## | ||
1056 | 31 | |||
1057 | 32 | from .code128 import get_code | ||
1058 | 33 | from .code39 import create_c39 | ||
1059 | 34 | from .EANBarCode import EanBarCode | ||
1060 | 35 | try: | ||
1061 | 36 | from cStringIO import StringIO | ||
1062 | 37 | except ImportError: | ||
1063 | 38 | from StringIO import StringIO | ||
1064 | 39 | |||
1065 | 40 | def make_barcode(code, code_type='ean13', rotate=None, height=50, xw=1): | ||
1066 | 41 | if code: | ||
1067 | 42 | if code_type.lower()=='ean13': | ||
1068 | 43 | bar=EanBarCode() | ||
1069 | 44 | im = bar.getImage(code,height) | ||
1070 | 45 | elif code_type.lower()=='code128': | ||
1071 | 46 | im = get_code(code, xw, height) | ||
1072 | 47 | elif code_type.lower()=='code39': | ||
1073 | 48 | im = create_c39(height, xw, code) | ||
1074 | 49 | else: | ||
1075 | 50 | return StringIO(), 'image/png' | ||
1076 | 51 | |||
1077 | 52 | tf = StringIO() | ||
1078 | 53 | try: | ||
1079 | 54 | if rotate!=None: | ||
1080 | 55 | im=im.rotate(int(rotate)) | ||
1081 | 56 | except Exception, e: | ||
1082 | 57 | pass | ||
1083 | 58 | im.save(tf, 'png') | ||
1084 | 59 | size_x = str(im.size[0]/96.0)+'in' | ||
1085 | 60 | size_y = str(im.size[1]/96.0)+'in' | ||
1086 | 61 | return tf, 'image/png', size_x, size_y | ||
1087 | 62 | |||
1088 | 63 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1089 | 0 | 64 | ||
1090 | === added file 'report_aeroo/barcode/code128.py' | |||
1091 | --- report_aeroo/barcode/code128.py 1970-01-01 00:00:00 +0000 | |||
1092 | +++ report_aeroo/barcode/code128.py 2014-04-05 13:18:49 +0000 | |||
1093 | @@ -0,0 +1,189 @@ | |||
1094 | 1 | # Copyright (c) 2009-2011 Alistek Ltd (http://www.alistek.com) All Rights Reserved. | ||
1095 | 2 | # General contacts <info@alistek.com> | ||
1096 | 3 | # This list was cut'n'pasted verbatim from the "Code 128 Specification Page" | ||
1097 | 4 | # at http://www.adams1.com/pub/russadam/128code.html | ||
1098 | 5 | |||
1099 | 6 | codelist="""0 SP SP 00 2 1 2 2 2 2 | ||
1100 | 7 | 1 ! ! 01 2 2 2 1 2 2 | ||
1101 | 8 | 2 " " 02 2 2 2 2 2 1 | ||
1102 | 9 | 3 # # 03 1 2 1 2 2 3 | ||
1103 | 10 | 4 $ $ 04 1 2 1 3 2 2 | ||
1104 | 11 | 5 % % 05 1 3 1 2 2 2 | ||
1105 | 12 | 6 & & 06 1 2 2 2 1 3 | ||
1106 | 13 | 7 ' ' 07 1 2 2 3 1 2 | ||
1107 | 14 | 8 ( ( 08 1 3 2 2 1 2 | ||
1108 | 15 | 9 ) ) 09 2 2 1 2 1 3 | ||
1109 | 16 | 10 * * 10 2 2 1 3 1 2 | ||
1110 | 17 | 11 + + 11 2 3 1 2 1 2 | ||
1111 | 18 | 12 , , 12 1 1 2 2 3 2 | ||
1112 | 19 | 13 - - 13 1 2 2 1 3 2 | ||
1113 | 20 | 14 . . 14 1 2 2 2 3 1 | ||
1114 | 21 | 15 / / 15 1 1 3 2 2 2 | ||
1115 | 22 | 16 0 0 16 1 2 3 1 2 2 | ||
1116 | 23 | 17 1 1 17 1 2 3 2 2 1 | ||
1117 | 24 | 18 2 2 18 2 2 3 2 1 1 | ||
1118 | 25 | 19 3 3 19 2 2 1 1 3 2 | ||
1119 | 26 | 20 4 4 20 2 2 1 2 3 1 | ||
1120 | 27 | 21 5 5 21 2 1 3 2 1 2 | ||
1121 | 28 | 22 6 6 22 2 2 3 1 1 2 | ||
1122 | 29 | 23 7 7 23 3 1 2 1 3 1 | ||
1123 | 30 | 24 8 8 24 3 1 1 2 2 2 | ||
1124 | 31 | 25 9 9 25 3 2 1 1 2 2 | ||
1125 | 32 | 26 : : 26 3 2 1 2 2 1 | ||
1126 | 33 | 27 ; ; 27 3 1 2 2 1 2 | ||
1127 | 34 | 28 < < 28 3 2 2 1 1 2 | ||
1128 | 35 | 29 = = 29 3 2 2 2 1 1 | ||
1129 | 36 | 30 > > 30 2 1 2 1 2 3 | ||
1130 | 37 | 31 ? ? 31 2 1 2 3 2 1 | ||
1131 | 38 | 32 @ @ 32 2 3 2 1 2 1 | ||
1132 | 39 | 33 A A 33 1 1 1 3 2 3 | ||
1133 | 40 | 34 B B 34 1 3 1 1 2 3 | ||
1134 | 41 | 35 C C 35 1 3 1 3 2 1 | ||
1135 | 42 | 36 D D 36 1 1 2 3 1 3 | ||
1136 | 43 | 37 E E 37 1 3 2 1 1 3 | ||
1137 | 44 | 38 F F 38 1 3 2 3 1 1 | ||
1138 | 45 | 39 G G 39 2 1 1 3 1 3 | ||
1139 | 46 | 40 H H 40 2 3 1 1 1 3 | ||
1140 | 47 | 41 I I 41 2 3 1 3 1 1 | ||
1141 | 48 | 42 J J 42 1 1 2 1 3 3 | ||
1142 | 49 | 43 K K 43 1 1 2 3 3 1 | ||
1143 | 50 | 44 L L 44 1 3 2 1 3 1 | ||
1144 | 51 | 45 M M 45 1 1 3 1 2 3 | ||
1145 | 52 | 46 N N 46 1 1 3 3 2 1 | ||
1146 | 53 | 47 O O 47 1 3 3 1 2 1 | ||
1147 | 54 | 48 P P 48 3 1 3 1 2 1 | ||
1148 | 55 | 49 Q Q 49 2 1 1 3 3 1 | ||
1149 | 56 | 50 R R 50 2 3 1 1 3 1 | ||
1150 | 57 | 51 S S 51 2 1 3 1 1 3 | ||
1151 | 58 | 52 T T 52 2 1 3 3 1 1 | ||
1152 | 59 | 53 U U 53 2 1 3 1 3 1 | ||
1153 | 60 | 54 V V 54 3 1 1 1 2 3 | ||
1154 | 61 | 55 W W 55 3 1 1 3 2 1 | ||
1155 | 62 | 56 X X 56 3 3 1 1 2 1 | ||
1156 | 63 | 57 Y Y 57 3 1 2 1 1 3 | ||
1157 | 64 | 58 Z Z 58 3 1 2 3 1 1 | ||
1158 | 65 | 59 [ [ 59 3 3 2 1 1 1 | ||
1159 | 66 | 60 \\ \\ 60 3 1 4 1 1 1 | ||
1160 | 67 | 61 ] ] 61 2 2 1 4 1 1 | ||
1161 | 68 | 62 ^ ^ 62 4 3 1 1 1 1 | ||
1162 | 69 | 63 _ _ 63 1 1 1 2 2 4 | ||
1163 | 70 | 64 NUL ' 64 1 1 1 4 2 2 | ||
1164 | 71 | 65 SOH a 65 1 2 1 1 2 4 | ||
1165 | 72 | 66 STX b 66 1 2 1 4 2 1 | ||
1166 | 73 | 67 ETX c 67 1 4 1 1 2 2 | ||
1167 | 74 | 68 EOT d 68 1 4 1 2 2 1 | ||
1168 | 75 | 69 ENQ e 69 1 1 2 2 1 4 | ||
1169 | 76 | 70 ACK f 70 1 1 2 4 1 2 | ||
1170 | 77 | 71 BEL g 61 1 2 2 1 1 4 | ||
1171 | 78 | 72 BS h 72 1 2 2 4 1 1 | ||
1172 | 79 | 73 HT i 73 1 4 2 1 1 2 | ||
1173 | 80 | 74 LF j 74 1 4 2 2 1 1 | ||
1174 | 81 | 75 VT k 75 2 4 1 2 1 1 | ||
1175 | 82 | 76 FF l 76 2 2 1 1 1 4 | ||
1176 | 83 | 77 CR m 77 4 1 3 1 1 1 | ||
1177 | 84 | 78 SO n 78 2 4 1 1 1 2 | ||
1178 | 85 | 79 SI o 79 1 3 4 1 1 1 | ||
1179 | 86 | 80 DLE p 80 1 1 1 2 4 2 | ||
1180 | 87 | 81 DC1 q 81 1 2 1 1 4 2 | ||
1181 | 88 | 82 DC2 r 82 1 2 1 2 4 1 | ||
1182 | 89 | 83 DC3 s 83 1 1 4 2 1 2 | ||
1183 | 90 | 84 DC4 t 84 1 2 4 1 1 2 | ||
1184 | 91 | 85 NAK u 85 1 2 4 2 1 1 | ||
1185 | 92 | 86 SYN v 86 4 1 1 2 1 2 | ||
1186 | 93 | 87 ETB w 87 4 2 1 1 1 2 | ||
1187 | 94 | 88 CAN x 88 4 2 1 2 1 1 | ||
1188 | 95 | 89 EM y 89 2 1 2 1 4 1 | ||
1189 | 96 | 90 SUB z 90 2 1 4 1 2 1 | ||
1190 | 97 | 91 ESC { 91 4 1 2 1 2 1 | ||
1191 | 98 | 92 FS | 92 1 1 1 1 4 3 | ||
1192 | 99 | 93 GS } 93 1 1 1 3 4 1 | ||
1193 | 100 | 94 RS ~ 94 1 3 1 1 4 1 | ||
1194 | 101 | 95 (Hex 7F) US DEL 95 1 1 4 1 1 3 | ||
1195 | 102 | 96 (Hex 80) FNC 3 FNC 3 96 1 1 4 3 1 1 | ||
1196 | 103 | 97 (Hex 81) FNC 2 FNC 2 97 4 1 1 1 1 3 | ||
1197 | 104 | 98 (Hex 82) SHIFT SHIFT 98 4 1 1 3 1 1 | ||
1198 | 105 | 99 (Hex 83) CODE C CODE C 99 1 1 3 1 4 1 | ||
1199 | 106 | 100 (Hex 84) CODE B FNC 4 CODE B 1 1 4 1 3 1 | ||
1200 | 107 | 101 (Hex 85) FNC 4 CODE A CODE A 3 1 1 1 4 1 | ||
1201 | 108 | 102 (Hex 86) FNC 1 FNC 1 FNC 1 4 1 1 1 3 1""" | ||
1202 | 109 | |||
1203 | 110 | |||
1204 | 111 | |||
1205 | 112 | |||
1206 | 113 | other="""103 (Hex 87) START (Code A) 2 1 1 4 1 2 | ||
1207 | 114 | 104 (Hex 88) START (Code B) 2 1 1 2 1 4 | ||
1208 | 115 | 105 (Hex 89) START (Code C) 2 1 1 2 3 2 | ||
1209 | 116 | 106 STOP 2 3 3 1 1 1 2""" | ||
1210 | 117 | |||
1211 | 118 | |||
1212 | 119 | codes={} | ||
1213 | 120 | values={} | ||
1214 | 121 | for l in codelist.split('\n'): | ||
1215 | 122 | l.strip() | ||
1216 | 123 | num,a1,b1,c1,code=l.split('\t') | ||
1217 | 124 | num=int(num.split(' ')[0]) | ||
1218 | 125 | values[num]=[int(x) for x in code.split()] | ||
1219 | 126 | codes[b1.strip()]=num | ||
1220 | 127 | |||
1221 | 128 | codes[' ']=codes['SP'] | ||
1222 | 129 | |||
1223 | 130 | for l in other.split('\n'): | ||
1224 | 131 | l.strip() | ||
1225 | 132 | num,name,code=l.split('\t') | ||
1226 | 133 | num=int(num.split(' ')[0]) | ||
1227 | 134 | values[num]=[int(x) for x in code.split()] | ||
1228 | 135 | codes[name.strip()]=num | ||
1229 | 136 | |||
1230 | 137 | def encode_message(msg): | ||
1231 | 138 | startnum=codes['START (Code B)'] | ||
1232 | 139 | message=values[startnum][:] | ||
1233 | 140 | chksum=startnum | ||
1234 | 141 | mult=1 | ||
1235 | 142 | for c in msg: | ||
1236 | 143 | if not codes.has_key(c): | ||
1237 | 144 | raise "No code for "+c | ||
1238 | 145 | chksum=chksum+mult*codes[c] | ||
1239 | 146 | mult=mult+1 | ||
1240 | 147 | message=message+values[codes[c]] | ||
1241 | 148 | |||
1242 | 149 | chksum=chksum%103 | ||
1243 | 150 | |||
1244 | 151 | message=message+values[chksum] | ||
1245 | 152 | message=message+values[codes['STOP']] | ||
1246 | 153 | |||
1247 | 154 | return message | ||
1248 | 155 | |||
1249 | 156 | |||
1250 | 157 | import os | ||
1251 | 158 | try: | ||
1252 | 159 | from PIL import Image | ||
1253 | 160 | except: | ||
1254 | 161 | _logger.warning("ERROR IMPORTING PIL, if not installed, please install it:" | ||
1255 | 162 | " get it here: https://pypi.python.org/pypi/PIL") | ||
1256 | 163 | def get_code(message,xw=1,h=100,rotate=None): | ||
1257 | 164 | """ message is message to code. | ||
1258 | 165 | xw is horizontal multiplier (in pixels width of narrowest bar) | ||
1259 | 166 | h is height in pixels. | ||
1260 | 167 | |||
1261 | 168 | Returns a Python Imaging Library object.""" | ||
1262 | 169 | |||
1263 | 170 | widths=[xw*20]+encode_message(message)+[xw*20] | ||
1264 | 171 | |||
1265 | 172 | bits=[] | ||
1266 | 173 | i=1 | ||
1267 | 174 | for w in widths: | ||
1268 | 175 | bits=bits+[i]*w*xw | ||
1269 | 176 | i=1-i | ||
1270 | 177 | |||
1271 | 178 | #print len(bits) | ||
1272 | 179 | #print bits | ||
1273 | 180 | |||
1274 | 181 | i=Image.new('1',(len(bits),h),1) | ||
1275 | 182 | |||
1276 | 183 | for b in range(len(bits)): | ||
1277 | 184 | for y in range(h): | ||
1278 | 185 | i.putpixel((b,y),255*bits[b]) | ||
1279 | 186 | |||
1280 | 187 | return i | ||
1281 | 188 | |||
1282 | 189 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1283 | 0 | 190 | ||
1284 | === added file 'report_aeroo/barcode/code39.py' | |||
1285 | --- report_aeroo/barcode/code39.py 1970-01-01 00:00:00 +0000 | |||
1286 | +++ report_aeroo/barcode/code39.py 2014-04-05 13:18:49 +0000 | |||
1287 | @@ -0,0 +1,166 @@ | |||
1288 | 1 | # Copyright (c) 2008 marscel.wordpress.com | ||
1289 | 2 | # | ||
1290 | 3 | # Copyright (c) 2011 Alistek Ltd (http://www.alistek.com) All Rights Reserved. | ||
1291 | 4 | # General contacts <info@alistek.com> | ||
1292 | 5 | |||
1293 | 6 | # Code39.py v1 | ||
1294 | 7 | # Requires Python and Python Imaging Library (PIL), | ||
1295 | 8 | # has been tested with Python v2.6 and PIL v1.1.6 | ||
1296 | 9 | |||
1297 | 10 | # Usage example: | ||
1298 | 11 | # code39.py 100 2 "Hello World" barcode.png | ||
1299 | 12 | # | ||
1300 | 13 | # This creates a PNG image "barcode.png" containing a barcode of the height of 100px | ||
1301 | 14 | # a min line width of 2px with "Hello World" encoded as "*HELLO WORLD*" in Code 39 | ||
1302 | 15 | try: | ||
1303 | 16 | from PIL import Image, ImageDraw, ImageFont | ||
1304 | 17 | except: | ||
1305 | 18 | _logger.warning("ERROR IMPORTING PIL, if not installed, please install it:" | ||
1306 | 19 | " get it here: https://pypi.python.org/pypi/PIL") | ||
1307 | 20 | from openerp.tools import config, ustr | ||
1308 | 21 | import os, sys | ||
1309 | 22 | |||
1310 | 23 | marginx = 10 | ||
1311 | 24 | marginy = 10 | ||
1312 | 25 | fontsize = 15 | ||
1313 | 26 | |||
1314 | 27 | charmap = { | ||
1315 | 28 | '*':[0,3,0,1,2,1,2,1,0], | ||
1316 | 29 | '-':[0,3,0,1,0,1,2,1,2], | ||
1317 | 30 | '$':[0,3,0,3,0,3,0,1,0], | ||
1318 | 31 | '%':[0,1,0,3,0,3,0,3,0], | ||
1319 | 32 | ' ':[0,3,2,1,0,1,2,1,0], | ||
1320 | 33 | '.':[2,3,0,1,0,1,2,1,0], | ||
1321 | 34 | '/':[0,3,0,3,0,1,0,3,0], | ||
1322 | 35 | '+':[0,3,0,1,0,3,0,3,0], | ||
1323 | 36 | '0':[0,1,0,3,2,1,2,1,0], | ||
1324 | 37 | '1':[2,1,0,3,0,1,0,1,2], | ||
1325 | 38 | '2':[0,1,2,3,0,1,0,1,2], | ||
1326 | 39 | '3':[2,1,2,3,0,1,0,1,0], | ||
1327 | 40 | '4':[0,1,0,3,2,1,0,1,2], | ||
1328 | 41 | '5':[2,1,0,3,2,1,0,1,0], | ||
1329 | 42 | '6':[0,1,2,3,2,1,0,1,0], | ||
1330 | 43 | '7':[0,1,0,3,0,1,2,1,2], | ||
1331 | 44 | '8':[2,1,0,3,0,1,2,1,0], | ||
1332 | 45 | '9':[0,1,2,3,0,1,2,1,0], | ||
1333 | 46 | 'A':[2,1,0,1,0,3,0,1,2], | ||
1334 | 47 | 'B':[0,1,2,1,0,3,0,1,2], | ||
1335 | 48 | 'C':[2,1,2,1,0,3,0,1,0], | ||
1336 | 49 | 'D':[0,1,0,1,2,3,0,1,2], | ||
1337 | 50 | 'E':[2,1,0,1,2,3,0,1,0], | ||
1338 | 51 | 'F':[0,1,2,1,2,3,0,1,0], | ||
1339 | 52 | 'G':[0,1,0,1,0,3,2,1,2], | ||
1340 | 53 | 'H':[2,1,0,1,0,3,2,1,0], | ||
1341 | 54 | 'I':[0,1,2,1,0,3,2,1,0], | ||
1342 | 55 | 'J':[0,1,0,1,2,3,2,1,0], | ||
1343 | 56 | 'K':[2,1,0,1,0,1,0,3,2], | ||
1344 | 57 | 'L':[0,1,2,1,0,1,0,3,2], | ||
1345 | 58 | 'M':[2,1,2,1,0,1,0,3,0], | ||
1346 | 59 | 'N':[0,1,0,1,2,1,0,3,2], | ||
1347 | 60 | 'O':[2,1,0,1,2,1,0,3,0], | ||
1348 | 61 | 'P':[0,1,2,1,2,1,0,3,0], | ||
1349 | 62 | 'Q':[0,1,0,1,0,1,2,3,2], | ||
1350 | 63 | 'R':[2,1,0,1,0,1,2,3,0], | ||
1351 | 64 | 'S':[0,1,2,1,0,1,2,3,0], | ||
1352 | 65 | 'T':[0,1,0,1,2,1,2,3,0], | ||
1353 | 66 | 'U':[2,3,0,1,0,1,0,1,2], | ||
1354 | 67 | 'V':[0,3,2,1,0,1,0,1,2], | ||
1355 | 68 | 'W':[2,3,2,1,0,1,0,1,0], | ||
1356 | 69 | 'X':[0,3,0,1,2,1,0,1,2], | ||
1357 | 70 | 'Y':[2,3,0,1,2,1,0,1,0], | ||
1358 | 71 | 'Z':[0,3,2,1,2,1,0,1,0] | ||
1359 | 72 | } | ||
1360 | 73 | |||
1361 | 74 | def create_c39(height, smallest, text): | ||
1362 | 75 | pixel_length = 0 | ||
1363 | 76 | i = 0 | ||
1364 | 77 | newtext = "" | ||
1365 | 78 | machinetext = "*" + text + "*" | ||
1366 | 79 | seglist = [] | ||
1367 | 80 | while i < len(machinetext): | ||
1368 | 81 | char = machinetext[i].capitalize() | ||
1369 | 82 | i = i + 1 | ||
1370 | 83 | try: | ||
1371 | 84 | cmap = charmap[char] | ||
1372 | 85 | if len(cmap) != 9: | ||
1373 | 86 | continue | ||
1374 | 87 | |||
1375 | 88 | j = 0 | ||
1376 | 89 | while j < 9: | ||
1377 | 90 | seg = int(cmap[j]) | ||
1378 | 91 | |||
1379 | 92 | if seg == 0 or seg == 1: | ||
1380 | 93 | pixel_length = pixel_length + smallest | ||
1381 | 94 | seglist.append(seg) | ||
1382 | 95 | elif seg == 2 or seg == 3: | ||
1383 | 96 | pixel_length = pixel_length + smallest * 3 | ||
1384 | 97 | seglist.append(seg) | ||
1385 | 98 | |||
1386 | 99 | j = j + 1 | ||
1387 | 100 | |||
1388 | 101 | newtext += char | ||
1389 | 102 | except: | ||
1390 | 103 | continue | ||
1391 | 104 | |||
1392 | 105 | pixel_length = pixel_length + 2*marginx + len(newtext) * smallest | ||
1393 | 106 | pixel_height = height + 2*marginy + fontsize | ||
1394 | 107 | |||
1395 | 108 | barcode_img = Image.new('RGB', [pixel_length, pixel_height], "white") | ||
1396 | 109 | |||
1397 | 110 | if len(seglist) == 0: | ||
1398 | 111 | return barcode_img | ||
1399 | 112 | |||
1400 | 113 | i = 0 | ||
1401 | 114 | draw = ImageDraw.Draw(barcode_img) | ||
1402 | 115 | current_x = marginx | ||
1403 | 116 | |||
1404 | 117 | while i < len(seglist): | ||
1405 | 118 | seg = seglist[i] | ||
1406 | 119 | color = (255, 255, 255) | ||
1407 | 120 | wdth = smallest | ||
1408 | 121 | |||
1409 | 122 | if seg == 0 or seg == 2: | ||
1410 | 123 | color = 0 | ||
1411 | 124 | if seg == 0: | ||
1412 | 125 | wdth = smallest | ||
1413 | 126 | else: | ||
1414 | 127 | wdth = smallest * 3 | ||
1415 | 128 | elif seg == 1 or seg == 3: | ||
1416 | 129 | color = (255, 255, 255) | ||
1417 | 130 | if seg == 1: | ||
1418 | 131 | wdth = smallest | ||
1419 | 132 | else: | ||
1420 | 133 | wdth = smallest * 3 | ||
1421 | 134 | |||
1422 | 135 | j = 1 | ||
1423 | 136 | |||
1424 | 137 | while j <= wdth: | ||
1425 | 138 | draw.line((current_x, marginy, current_x, marginy+height), fill=color) | ||
1426 | 139 | current_x = current_x + 1 | ||
1427 | 140 | j = j + 1 | ||
1428 | 141 | |||
1429 | 142 | if ((i+1) % 9) == 0: | ||
1430 | 143 | j = 1 | ||
1431 | 144 | while j <= smallest: | ||
1432 | 145 | draw.line((current_x, marginy, current_x, marginy+height), fill=(255,255,255)) | ||
1433 | 146 | current_x = current_x + 1 | ||
1434 | 147 | j = j + 1 | ||
1435 | 148 | i = i + 1 | ||
1436 | 149 | |||
1437 | 150 | ad = os.path.abspath(os.path.join(ustr(config['root_path']), u'addons')) | ||
1438 | 151 | mod_path_list = map(lambda m: os.path.abspath(ustr(m.strip())), config['addons_path'].split(',')) | ||
1439 | 152 | mod_path_list.append(ad) | ||
1440 | 153 | |||
1441 | 154 | for mod_path in mod_path_list: | ||
1442 | 155 | font_file = mod_path+os.path.sep+ \ | ||
1443 | 156 | "report_aeroo"+os.path.sep+"barcode"+os.path.sep+"FreeMonoBold.ttf" | ||
1444 | 157 | if os.path.lexists(font_file): | ||
1445 | 158 | font = ImageFont.truetype(font_file, fontsize) | ||
1446 | 159 | |||
1447 | 160 | draw.text((pixel_length/2 - len(newtext)*(fontsize/2)/2-len(newtext), height+fontsize), newtext, font=font, fill=0) | ||
1448 | 161 | |||
1449 | 162 | del draw | ||
1450 | 163 | |||
1451 | 164 | return barcode_img | ||
1452 | 165 | |||
1453 | 166 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1454 | 0 | 167 | ||
1455 | === added file 'report_aeroo/barcode/courB08.pbm' | |||
1456 | 1 | Binary files report_aeroo/barcode/courB08.pbm 1970-01-01 00:00:00 +0000 and report_aeroo/barcode/courB08.pbm 2014-04-05 13:18:49 +0000 differ | 168 | Binary files report_aeroo/barcode/courB08.pbm 1970-01-01 00:00:00 +0000 and report_aeroo/barcode/courB08.pbm 2014-04-05 13:18:49 +0000 differ |
1457 | === added file 'report_aeroo/barcode/courB08.pil' | |||
1458 | 2 | Binary files report_aeroo/barcode/courB08.pil 1970-01-01 00:00:00 +0000 and report_aeroo/barcode/courB08.pil 2014-04-05 13:18:49 +0000 differ | 169 | Binary files report_aeroo/barcode/courB08.pil 1970-01-01 00:00:00 +0000 and report_aeroo/barcode/courB08.pil 2014-04-05 13:18:49 +0000 differ |
1459 | === added file 'report_aeroo/check_deps.py' | |||
1460 | --- report_aeroo/check_deps.py 1970-01-01 00:00:00 +0000 | |||
1461 | +++ report_aeroo/check_deps.py 2014-04-05 13:18:49 +0000 | |||
1462 | @@ -0,0 +1,52 @@ | |||
1463 | 1 | # -*- encoding: utf-8 -*- | ||
1464 | 2 | ############################################################################## | ||
1465 | 3 | # | ||
1466 | 4 | # Copyright (c) 2009-2011 Alistek Ltd (http://www.alistek.com) All Rights Reserved. | ||
1467 | 5 | # General contacts <info@alistek.com> | ||
1468 | 6 | # | ||
1469 | 7 | # WARNING: This program as such is intended to be used by professional | ||
1470 | 8 | # programmers who take the whole responsability of assessing all potential | ||
1471 | 9 | # consequences resulting from its eventual inadequacies and bugs | ||
1472 | 10 | # End users who are looking for a ready-to-use solution with commercial | ||
1473 | 11 | # garantees and support are strongly adviced to contract a Free Software | ||
1474 | 12 | # Service Company | ||
1475 | 13 | # | ||
1476 | 14 | # This program is Free Software; you can redistribute it and/or | ||
1477 | 15 | # modify it under the terms of the GNU General Public License | ||
1478 | 16 | # as published by the Free Software Foundation; either version 3 | ||
1479 | 17 | # of the License, or (at your option) any later version. | ||
1480 | 18 | # | ||
1481 | 19 | # This module is GPLv3 or newer and incompatible | ||
1482 | 20 | # with OpenERP SA "AGPL + Private Use License"! | ||
1483 | 21 | # | ||
1484 | 22 | # This program is distributed in the hope that it will be useful, | ||
1485 | 23 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1486 | 24 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1487 | 25 | # GNU General Public License for more details. | ||
1488 | 26 | # | ||
1489 | 27 | # You should have received a copy of the GNU General Public License | ||
1490 | 28 | # along with this program; if not, write to the Free Software | ||
1491 | 29 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
1492 | 30 | # | ||
1493 | 31 | ############################################################################## | ||
1494 | 32 | |||
1495 | 33 | from openerp.osv import orm | ||
1496 | 34 | from openerp.tools.translate import _ | ||
1497 | 35 | |||
1498 | 36 | __all__ = [ | ||
1499 | 37 | 'check_deps', | ||
1500 | 38 | ] | ||
1501 | 39 | |||
1502 | 40 | def check_deps(check_list): | ||
1503 | 41 | error = False | ||
1504 | 42 | import_errors = [] | ||
1505 | 43 | for imp in check_list: | ||
1506 | 44 | try: | ||
1507 | 45 | exec imp in {} | ||
1508 | 46 | except ImportError,e: | ||
1509 | 47 | error = True | ||
1510 | 48 | import_errors.append(str(e)) | ||
1511 | 49 | if error: | ||
1512 | 50 | raise orm.except_orm(_('Warning!')+' '+_('Unmet python dependencies!'), '\n'.join(import_errors)) | ||
1513 | 51 | |||
1514 | 52 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1515 | 0 | 53 | ||
1516 | === added directory 'report_aeroo/config_pixmaps' | |||
1517 | === added file 'report_aeroo/config_pixmaps/module_banner.png' | |||
1518 | 1 | Binary files report_aeroo/config_pixmaps/module_banner.png 1970-01-01 00:00:00 +0000 and report_aeroo/config_pixmaps/module_banner.png 2014-04-05 13:18:49 +0000 differ | 54 | Binary files report_aeroo/config_pixmaps/module_banner.png 1970-01-01 00:00:00 +0000 and report_aeroo/config_pixmaps/module_banner.png 2014-04-05 13:18:49 +0000 differ |
1519 | === added directory 'report_aeroo/ctt_languages' | |||
1520 | === added file 'report_aeroo/ctt_languages/__init__.py' | |||
1521 | --- report_aeroo/ctt_languages/__init__.py 1970-01-01 00:00:00 +0000 | |||
1522 | +++ report_aeroo/ctt_languages/__init__.py 2014-04-05 13:18:49 +0000 | |||
1523 | @@ -0,0 +1,3 @@ | |||
1524 | 1 | #!/usr/bin/python | ||
1525 | 2 | # -*- coding: utf8 -*- | ||
1526 | 3 | # Please do not edit this file! | ||
1527 | 0 | 4 | ||
1528 | === added directory 'report_aeroo/ctt_languages/en_US' | |||
1529 | === added file 'report_aeroo/ctt_languages/en_US/__init__.py' | |||
1530 | --- report_aeroo/ctt_languages/en_US/__init__.py 1970-01-01 00:00:00 +0000 | |||
1531 | +++ report_aeroo/ctt_languages/en_US/__init__.py 2014-04-05 13:18:49 +0000 | |||
1532 | @@ -0,0 +1,91 @@ | |||
1533 | 1 | #!/usr/bin/python | ||
1534 | 2 | # -*- coding: utf8 -*- | ||
1535 | 3 | # en_US | ||
1536 | 4 | |||
1537 | 5 | from report_aeroo.ctt_objects import ctt_language | ||
1538 | 6 | |||
1539 | 7 | class en_US(ctt_language): | ||
1540 | 8 | def _init_lang(self): | ||
1541 | 9 | # language name | ||
1542 | 10 | self.name = 'en_US' | ||
1543 | 11 | # digits - masculine, singular | ||
1544 | 12 | self.digits_sng_msc = [u'zero', u'one', u'two', u'three', u'four', | ||
1545 | 13 | u'five', u'six', u'seven', u'eight', u'nine'] | ||
1546 | 14 | # tens - masculine, singular | ||
1547 | 15 | self.tens_sng_msc = [u'', u'one', u'twen', u'thir', u'four', u'fif', | ||
1548 | 16 | u'six', u'seven', u'eigh', u'nine'] | ||
1549 | 17 | # teens - masculine | ||
1550 | 18 | self.teens = [u'ten', u'eleven', u'twelve', u'thirteen', u'fourteen', | ||
1551 | 19 | u'fifteen', u'sixteen', u'seventeen', u'eighteen', | ||
1552 | 20 | u'nineteen'] | ||
1553 | 21 | # multiplier - masculine, singular | ||
1554 | 22 | self.multi_sng_msc = [u' hundred', u' thousand', u' million', | ||
1555 | 23 | u' billion'] | ||
1556 | 24 | # multiplier - masculine, plural | ||
1557 | 25 | self.multi_plr_msc = [u' hundreds', u' thousands', u' millions', | ||
1558 | 26 | u' billions'] | ||
1559 | 27 | |||
1560 | 28 | # next line is needed for correct loading of currencies | ||
1561 | 29 | import currencies | ||
1562 | 30 | return currencies | ||
1563 | 31 | |||
1564 | 32 | |||
1565 | 33 | def wordify(self, chunk, chunknr, gender): | ||
1566 | 34 | if gender == 'm': | ||
1567 | 35 | number = self.digits_sng_msc | ||
1568 | 36 | elif gender == 'f': | ||
1569 | 37 | number = self.digits_sng_fem | ||
1570 | 38 | elif gender == 'n': | ||
1571 | 39 | number = self.digits_sng_neu | ||
1572 | 40 | words = u'' | ||
1573 | 41 | digit1 = u'' | ||
1574 | 42 | digit2 = u'' | ||
1575 | 43 | digit3 = u'' | ||
1576 | 44 | chunklength = len(chunk) | ||
1577 | 45 | # placing digits in right places | ||
1578 | 46 | if chunklength == 1: | ||
1579 | 47 | digit3 = chunk[0 : 1] | ||
1580 | 48 | if chunklength == 2: | ||
1581 | 49 | digit2 = chunk[0 : 1] | ||
1582 | 50 | digit3 = chunk[1 : 2] | ||
1583 | 51 | if chunklength == 3: | ||
1584 | 52 | digit1 = chunk[0 : 1] | ||
1585 | 53 | digit2 = chunk[1 : 2] | ||
1586 | 54 | digit3 = chunk[-1] | ||
1587 | 55 | # processing zero | ||
1588 | 56 | if chunklength == 1 and digit3 == '0' : | ||
1589 | 57 | return number[0] | ||
1590 | 58 | # processing hundreds | ||
1591 | 59 | if chunklength == 3 : | ||
1592 | 60 | if digit1 == '1' : | ||
1593 | 61 | words += self.digits_sng_msc[int(digit1)] + self.multi_sng_msc[0] | ||
1594 | 62 | else : | ||
1595 | 63 | if int(digit1) >= 1 : words += self.digits_sng_msc[int(digit1)] + self.multi_plr_msc[0] | ||
1596 | 64 | # processing tens | ||
1597 | 65 | if chunklength > 1: | ||
1598 | 66 | spacer = '' | ||
1599 | 67 | if len(words) > 0 : spacer = u' ' | ||
1600 | 68 | if digit2 == '1': | ||
1601 | 69 | words += spacer + self.teens[int(digit3)] | ||
1602 | 70 | else: | ||
1603 | 71 | if int(digit2) > 1 and int(digit2) > 0: | ||
1604 | 72 | words += spacer + self.tens_sng_msc[int(digit2)] + u'ty' | ||
1605 | 73 | |||
1606 | 74 | # processing ones | ||
1607 | 75 | if chunklength > 0 and digit2 != '1' : | ||
1608 | 76 | spacer = '' | ||
1609 | 77 | if len(words) > 0: spacer = u' ' | ||
1610 | 78 | if int(digit3) > 0: | ||
1611 | 79 | words += spacer + number[int(digit3)] | ||
1612 | 80 | # end processing | ||
1613 | 81 | if len(words) > 0 : | ||
1614 | 82 | if digit3 == '1' and chunknr > 0: | ||
1615 | 83 | return words + self.multi_sng_msc[chunknr] | ||
1616 | 84 | elif digit3 != '1' and chunknr > 0: | ||
1617 | 85 | return words + self.multi_sng_msc[chunknr] | ||
1618 | 86 | else: | ||
1619 | 87 | return words | ||
1620 | 88 | else: | ||
1621 | 89 | return '' | ||
1622 | 90 | |||
1623 | 91 | en_US() | ||
1624 | 0 | 92 | ||
1625 | === added directory 'report_aeroo/ctt_languages/en_US/currencies' | |||
1626 | === added file 'report_aeroo/ctt_languages/en_US/currencies/__init__.py' | |||
1627 | --- report_aeroo/ctt_languages/en_US/currencies/__init__.py 1970-01-01 00:00:00 +0000 | |||
1628 | +++ report_aeroo/ctt_languages/en_US/currencies/__init__.py 2014-04-05 13:18:49 +0000 | |||
1629 | @@ -0,0 +1,3 @@ | |||
1630 | 1 | #!/usr/bin/python | ||
1631 | 2 | # -*- coding: utf8 -*- | ||
1632 | 3 | # Please do not edit this file! | ||
1633 | 0 | 4 | ||
1634 | === added file 'report_aeroo/ctt_languages/en_US/currencies/eur.py' | |||
1635 | --- report_aeroo/ctt_languages/en_US/currencies/eur.py 1970-01-01 00:00:00 +0000 | |||
1636 | +++ report_aeroo/ctt_languages/en_US/currencies/eur.py 2014-04-05 13:18:49 +0000 | |||
1637 | @@ -0,0 +1,19 @@ | |||
1638 | 1 | #!/usr/bin/python | ||
1639 | 2 | # -*- coding: utf8 -*- | ||
1640 | 3 | |||
1641 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
1642 | 5 | |||
1643 | 6 | class eur(ctt_currency): | ||
1644 | 7 | def _init_currency(self): | ||
1645 | 8 | self.language = u'en_US' | ||
1646 | 9 | self.code = u'EUR' | ||
1647 | 10 | self.fractions = 100 | ||
1648 | 11 | self.cur_singular = u' euro' | ||
1649 | 12 | self.cur_plural = u' euro' | ||
1650 | 13 | self.frc_singular = u' cent' | ||
1651 | 14 | self.frc_plural = u' cents' | ||
1652 | 15 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
1653 | 16 | self.cur_gram_gender = 'm' | ||
1654 | 17 | self.frc_gram_gender = 'm' | ||
1655 | 18 | |||
1656 | 19 | eur() | ||
1657 | 0 | 20 | ||
1658 | === added file 'report_aeroo/ctt_languages/en_US/currencies/ltl.py' | |||
1659 | --- report_aeroo/ctt_languages/en_US/currencies/ltl.py 1970-01-01 00:00:00 +0000 | |||
1660 | +++ report_aeroo/ctt_languages/en_US/currencies/ltl.py 2014-04-05 13:18:49 +0000 | |||
1661 | @@ -0,0 +1,19 @@ | |||
1662 | 1 | #!/usr/bin/python | ||
1663 | 2 | # -*- coding: utf8 -*- | ||
1664 | 3 | |||
1665 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
1666 | 5 | |||
1667 | 6 | class ltl(ctt_currency): | ||
1668 | 7 | def _init_currency(self): | ||
1669 | 8 | self.language = u'en_US' | ||
1670 | 9 | self.code = u'LTL' | ||
1671 | 10 | self.fractions = 100 | ||
1672 | 11 | self.cur_singular = u' Lithuanian litas' | ||
1673 | 12 | self.cur_plural = u' Lithuanian litas' | ||
1674 | 13 | self.frc_singular = u' cent' | ||
1675 | 14 | self.frc_plural = u' cents' | ||
1676 | 15 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
1677 | 16 | self.cur_gram_gender = 'm' | ||
1678 | 17 | self.frc_gram_gender = 'm' | ||
1679 | 18 | |||
1680 | 19 | ltl() | ||
1681 | 0 | 20 | ||
1682 | === added file 'report_aeroo/ctt_languages/en_US/currencies/lvl.py' | |||
1683 | --- report_aeroo/ctt_languages/en_US/currencies/lvl.py 1970-01-01 00:00:00 +0000 | |||
1684 | +++ report_aeroo/ctt_languages/en_US/currencies/lvl.py 2014-04-05 13:18:49 +0000 | |||
1685 | @@ -0,0 +1,19 @@ | |||
1686 | 1 | #!/usr/bin/python | ||
1687 | 2 | # -*- coding: utf8 -*- | ||
1688 | 3 | |||
1689 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
1690 | 5 | |||
1691 | 6 | class lvl(ctt_currency): | ||
1692 | 7 | def _init_currency(self): | ||
1693 | 8 | self.language = u'en_US' | ||
1694 | 9 | self.code = u'LVL' | ||
1695 | 10 | self.fractions = 100 | ||
1696 | 11 | self.cur_singular = u' lat' | ||
1697 | 12 | self.cur_plural = u' lats' | ||
1698 | 13 | self.frc_singular = u' santim' | ||
1699 | 14 | self.frc_plural = u' santims' | ||
1700 | 15 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
1701 | 16 | self.cur_gram_gender = 'm' | ||
1702 | 17 | self.frc_gram_gender = 'm' | ||
1703 | 18 | |||
1704 | 19 | lvl() | ||
1705 | 0 | 20 | ||
1706 | === added file 'report_aeroo/ctt_languages/en_US/currencies/mxn.py' | |||
1707 | --- report_aeroo/ctt_languages/en_US/currencies/mxn.py 1970-01-01 00:00:00 +0000 | |||
1708 | +++ report_aeroo/ctt_languages/en_US/currencies/mxn.py 2014-04-05 13:18:49 +0000 | |||
1709 | @@ -0,0 +1,19 @@ | |||
1710 | 1 | #!/usr/bin/python | ||
1711 | 2 | # -*- coding: utf8 -*- | ||
1712 | 3 | |||
1713 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
1714 | 5 | |||
1715 | 6 | class mxn(ctt_currency): | ||
1716 | 7 | def _init_currency(self): | ||
1717 | 8 | self.language = u'en_US' | ||
1718 | 9 | self.code = u'MXN' | ||
1719 | 10 | self.fractions = 100 | ||
1720 | 11 | self.cur_singular = u' Mexican peso' | ||
1721 | 12 | self.cur_plural = u' Mexican pesos' | ||
1722 | 13 | self.frc_singular = u' cent' | ||
1723 | 14 | self.frc_plural = u' cents' | ||
1724 | 15 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
1725 | 16 | self.cur_gram_gender = 'm' | ||
1726 | 17 | self.frc_gram_gender = 'm' | ||
1727 | 18 | |||
1728 | 19 | mxn() | ||
1729 | 0 | 20 | ||
1730 | === added file 'report_aeroo/ctt_languages/en_US/currencies/trl.py' | |||
1731 | --- report_aeroo/ctt_languages/en_US/currencies/trl.py 1970-01-01 00:00:00 +0000 | |||
1732 | +++ report_aeroo/ctt_languages/en_US/currencies/trl.py 2014-04-05 13:18:49 +0000 | |||
1733 | @@ -0,0 +1,19 @@ | |||
1734 | 1 | #!/usr/bin/python | ||
1735 | 2 | # -*- coding: utf8 -*- | ||
1736 | 3 | |||
1737 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
1738 | 5 | |||
1739 | 6 | class trl(ctt_currency): | ||
1740 | 7 | def _init_currency(self): | ||
1741 | 8 | self.language = u'en_US' | ||
1742 | 9 | self.code = u'TRL' | ||
1743 | 10 | self.fractions = 100 | ||
1744 | 11 | self.cur_singular = u' Turkish lira' | ||
1745 | 12 | self.cur_plural = u' Turkish Liras' | ||
1746 | 13 | self.frc_singular = u' kurus' | ||
1747 | 14 | self.frc_plural = u' kuruss' | ||
1748 | 15 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
1749 | 16 | self.cur_gram_gender = 'm' | ||
1750 | 17 | self.frc_gram_gender = 'm' | ||
1751 | 18 | |||
1752 | 19 | trl() | ||
1753 | 0 | 20 | ||
1754 | === added file 'report_aeroo/ctt_languages/en_US/currencies/usd.py' | |||
1755 | --- report_aeroo/ctt_languages/en_US/currencies/usd.py 1970-01-01 00:00:00 +0000 | |||
1756 | +++ report_aeroo/ctt_languages/en_US/currencies/usd.py 2014-04-05 13:18:49 +0000 | |||
1757 | @@ -0,0 +1,19 @@ | |||
1758 | 1 | #!/usr/bin/python | ||
1759 | 2 | # -*- coding: utf8 -*- | ||
1760 | 3 | |||
1761 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
1762 | 5 | |||
1763 | 6 | class usd(ctt_currency): | ||
1764 | 7 | def _init_currency(self): | ||
1765 | 8 | self.language = u'en_US' | ||
1766 | 9 | self.code = u'USD' | ||
1767 | 10 | self.fractions = 100 | ||
1768 | 11 | self.cur_singular = u' US dollar' | ||
1769 | 12 | self.cur_plural = u' US dollars' | ||
1770 | 13 | self.frc_singular = u' cent' | ||
1771 | 14 | self.frc_plural = u' cents' | ||
1772 | 15 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
1773 | 16 | self.cur_gram_gender = 'm' | ||
1774 | 17 | self.frc_gram_gender = 'm' | ||
1775 | 18 | |||
1776 | 19 | usd() | ||
1777 | 0 | 20 | ||
1778 | === added directory 'report_aeroo/ctt_languages/es_ES' | |||
1779 | === added file 'report_aeroo/ctt_languages/es_ES/__init__.py' | |||
1780 | --- report_aeroo/ctt_languages/es_ES/__init__.py 1970-01-01 00:00:00 +0000 | |||
1781 | +++ report_aeroo/ctt_languages/es_ES/__init__.py 2014-04-05 13:18:49 +0000 | |||
1782 | @@ -0,0 +1,102 @@ | |||
1783 | 1 | #!/usr/bin/python | ||
1784 | 2 | # -*- coding: utf8 -*- | ||
1785 | 3 | # es_ES | ||
1786 | 4 | ################################################################################ | ||
1787 | 5 | # Spanish language support assembled from contributions provided by: | ||
1788 | 6 | # * mechiscogo | ||
1789 | 7 | # * Christopher Ormaza - Ecuadorenlinea.net <chris.ormaza@gmail.com>, 2011 | ||
1790 | 8 | ################################################################################ | ||
1791 | 9 | |||
1792 | 10 | from report_aeroo.ctt_objects import ctt_language | ||
1793 | 11 | |||
1794 | 12 | class es_ES(ctt_language): | ||
1795 | 13 | def _init_lang(self): | ||
1796 | 14 | # language name | ||
1797 | 15 | self.name = 'es_ES' | ||
1798 | 16 | # digits - masculine, singular | ||
1799 | 17 | self.digits_sng_msc = [u'cero', u'uno', u'dos', u'tres', u'cuatro', | ||
1800 | 18 | u'cinco', u'seis', u'siete', u'ocho', u'nueve'] | ||
1801 | 19 | |||
1802 | 20 | # tens - masculine, singular | ||
1803 | 21 | self.tens_sng_msc = [u'', u'', u'veint', u'treinta', u'cuarenta', | ||
1804 | 22 | u'cincuenta', u'sesenta', u'setenta', u'ochenta', | ||
1805 | 23 | u'noventa '] | ||
1806 | 24 | |||
1807 | 25 | # teens - masculine | ||
1808 | 26 | self.teens = [u'diez', u'once', u'doce', u'trece', u'catorce', | ||
1809 | 27 | u'quince', u'dieciséis', u'diecisiete', u'dieciocho', | ||
1810 | 28 | u'diecinueve'] | ||
1811 | 29 | |||
1812 | 30 | # multiplier - masculine, singular | ||
1813 | 31 | self.multi_sng_msc = [u'cien', u' mil', u' millón', u' billón'] | ||
1814 | 32 | |||
1815 | 33 | # multiplier - masculine, plural | ||
1816 | 34 | self.multi_plr_msc = [u'cientos', u' mil', u' millones', u' billones'] | ||
1817 | 35 | |||
1818 | 36 | # next line is needed for correct loading of currencies | ||
1819 | 37 | import currencies | ||
1820 | 38 | return currencies | ||
1821 | 39 | |||
1822 | 40 | |||
1823 | 41 | def wordify(self, chunk, chunknr, gender): | ||
1824 | 42 | if gender == 'm': | ||
1825 | 43 | number = self.digits_sng_msc | ||
1826 | 44 | elif gender == 'f': | ||
1827 | 45 | number = self.digits_sng_fem | ||
1828 | 46 | elif gender == 'n': | ||
1829 | 47 | number = self.digits_sng_neu | ||
1830 | 48 | words = u'' | ||
1831 | 49 | digit1 = u'' | ||
1832 | 50 | digit2 = u'' | ||
1833 | 51 | digit3 = u'' | ||
1834 | 52 | chunklength = len(chunk) | ||
1835 | 53 | # placing digits in right places | ||
1836 | 54 | if chunklength == 1: | ||
1837 | 55 | digit3 = chunk[0 : 1] | ||
1838 | 56 | if chunklength == 2: | ||
1839 | 57 | digit2 = chunk[0 : 1] | ||
1840 | 58 | digit3 = chunk[1 : 2] | ||
1841 | 59 | if chunklength == 3: | ||
1842 | 60 | digit1 = chunk[0 : 1] | ||
1843 | 61 | digit2 = chunk[1 : 2] | ||
1844 | 62 | digit3 = chunk[-1] | ||
1845 | 63 | # processing zero | ||
1846 | 64 | if chunklength == 1 and digit3 == '0' : | ||
1847 | 65 | return number[0] | ||
1848 | 66 | # processing hundreds | ||
1849 | 67 | if chunklength == 3 : | ||
1850 | 68 | if digit1 == '1' : | ||
1851 | 69 | words += self.multi_sng_msc[0] | ||
1852 | 70 | else : | ||
1853 | 71 | if int(digit1) >= 1 : words += self.digits_sng_msc[int(digit1)]\ | ||
1854 | 72 | + self.multi_plr_msc[0] | ||
1855 | 73 | # processing tens | ||
1856 | 74 | if chunklength > 1: | ||
1857 | 75 | spacer = '' | ||
1858 | 76 | if len(words) > 0 : spacer = u' ' | ||
1859 | 77 | if digit2 == '1': | ||
1860 | 78 | words += spacer + self.teens[int(digit3)] | ||
1861 | 79 | else: | ||
1862 | 80 | if int(digit2) > 1 and int(digit2) > 0: | ||
1863 | 81 | words += spacer + self.tens_sng_msc[int(digit2)] | ||
1864 | 82 | if int(digit3) > 0: | ||
1865 | 83 | words += u' y' | ||
1866 | 84 | |||
1867 | 85 | # processing ones | ||
1868 | 86 | if chunklength > 0 and digit2 != '1' : | ||
1869 | 87 | spacer = '' | ||
1870 | 88 | if len(words) > 0: spacer = u' ' | ||
1871 | 89 | if int(digit3) > 0: | ||
1872 | 90 | words += spacer + number[int(digit3)] | ||
1873 | 91 | # end processing | ||
1874 | 92 | if len(words) > 0 : | ||
1875 | 93 | if digit3 == '1' and chunknr > 0: | ||
1876 | 94 | return words + self.multi_sng_msc[chunknr] | ||
1877 | 95 | elif digit3 != '1' and chunknr > 0: | ||
1878 | 96 | return words + self.multi_plr_msc[chunknr] | ||
1879 | 97 | else: | ||
1880 | 98 | return words | ||
1881 | 99 | else: | ||
1882 | 100 | return '' | ||
1883 | 101 | |||
1884 | 102 | es_ES() | ||
1885 | 0 | 103 | ||
1886 | === added directory 'report_aeroo/ctt_languages/es_ES/currencies' | |||
1887 | === added file 'report_aeroo/ctt_languages/es_ES/currencies/__init__.py' | |||
1888 | --- report_aeroo/ctt_languages/es_ES/currencies/__init__.py 1970-01-01 00:00:00 +0000 | |||
1889 | +++ report_aeroo/ctt_languages/es_ES/currencies/__init__.py 2014-04-05 13:18:49 +0000 | |||
1890 | @@ -0,0 +1,3 @@ | |||
1891 | 1 | #!/usr/bin/python | ||
1892 | 2 | # -*- coding: utf8 -*- | ||
1893 | 3 | # Please do not edit this file! | ||
1894 | 0 | 4 | ||
1895 | === added file 'report_aeroo/ctt_languages/es_ES/currencies/eur.py' | |||
1896 | --- report_aeroo/ctt_languages/es_ES/currencies/eur.py 1970-01-01 00:00:00 +0000 | |||
1897 | +++ report_aeroo/ctt_languages/es_ES/currencies/eur.py 2014-04-05 13:18:49 +0000 | |||
1898 | @@ -0,0 +1,19 @@ | |||
1899 | 1 | #!/usr/bin/python | ||
1900 | 2 | # -*- coding: utf8 -*- | ||
1901 | 3 | |||
1902 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
1903 | 5 | |||
1904 | 6 | class eur(ctt_currency): | ||
1905 | 7 | def _init_currency(self): | ||
1906 | 8 | self.language = u'es_ES' | ||
1907 | 9 | self.code = u'EUR' | ||
1908 | 10 | self.fractions = 100 | ||
1909 | 11 | self.cur_singular = u' euro' | ||
1910 | 12 | self.cur_plural = u' euros' | ||
1911 | 13 | self.frc_singular = u' centavo' | ||
1912 | 14 | self.frc_plural = u' centavos' | ||
1913 | 15 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
1914 | 16 | self.cur_gram_gender = 'm' | ||
1915 | 17 | self.frc_gram_gender = 'm' | ||
1916 | 18 | |||
1917 | 19 | eur() | ||
1918 | 0 | 20 | ||
1919 | === added file 'report_aeroo/ctt_languages/es_ES/currencies/mxn.py' | |||
1920 | --- report_aeroo/ctt_languages/es_ES/currencies/mxn.py 1970-01-01 00:00:00 +0000 | |||
1921 | +++ report_aeroo/ctt_languages/es_ES/currencies/mxn.py 2014-04-05 13:18:49 +0000 | |||
1922 | @@ -0,0 +1,19 @@ | |||
1923 | 1 | #!/usr/bin/python | ||
1924 | 2 | # -*- coding: utf8 -*- | ||
1925 | 3 | |||
1926 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
1927 | 5 | |||
1928 | 6 | class mxn(ctt_currency): | ||
1929 | 7 | def _init_currency(self): | ||
1930 | 8 | self.language = u'es_ES' | ||
1931 | 9 | self.code = u'MXN' | ||
1932 | 10 | self.fractions = 100 | ||
1933 | 11 | self.cur_singular = u' peso' | ||
1934 | 12 | self.cur_plural = u' pesos' | ||
1935 | 13 | self.frc_singular = u' centavo' | ||
1936 | 14 | self.frc_plural = u' centavos' | ||
1937 | 15 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
1938 | 16 | self.cur_gram_gender = 'm' | ||
1939 | 17 | self.frc_gram_gender = 'm' | ||
1940 | 18 | |||
1941 | 19 | mxn() | ||
1942 | 0 | 20 | ||
1943 | === added file 'report_aeroo/ctt_languages/es_ES/currencies/usd.py' | |||
1944 | --- report_aeroo/ctt_languages/es_ES/currencies/usd.py 1970-01-01 00:00:00 +0000 | |||
1945 | +++ report_aeroo/ctt_languages/es_ES/currencies/usd.py 2014-04-05 13:18:49 +0000 | |||
1946 | @@ -0,0 +1,19 @@ | |||
1947 | 1 | #!/usr/bin/python | ||
1948 | 2 | # -*- coding: utf8 -*- | ||
1949 | 3 | |||
1950 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
1951 | 5 | |||
1952 | 6 | class usd(ctt_currency): | ||
1953 | 7 | def _init_currency(self): | ||
1954 | 8 | self.language = u'es_ES' | ||
1955 | 9 | self.code = u'USD' | ||
1956 | 10 | self.fractions = 100 | ||
1957 | 11 | self.cur_singular = u' dólar Américano' | ||
1958 | 12 | self.cur_plural = u' dólares Américanos' | ||
1959 | 13 | self.frc_singular = u' centavo' | ||
1960 | 14 | self.frc_plural = u' centavos' | ||
1961 | 15 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
1962 | 16 | self.cur_gram_gender = 'm' | ||
1963 | 17 | self.frc_gram_gender = 'm' | ||
1964 | 18 | |||
1965 | 19 | usd() | ||
1966 | 0 | 20 | ||
1967 | === added directory 'report_aeroo/ctt_languages/lt_LT' | |||
1968 | === added file 'report_aeroo/ctt_languages/lt_LT/__init__.py' | |||
1969 | --- report_aeroo/ctt_languages/lt_LT/__init__.py 1970-01-01 00:00:00 +0000 | |||
1970 | +++ report_aeroo/ctt_languages/lt_LT/__init__.py 2014-04-05 13:18:49 +0000 | |||
1971 | @@ -0,0 +1,107 @@ | |||
1972 | 1 | #!/usr/bin/python | ||
1973 | 2 | # -*- coding: utf8 -*- | ||
1974 | 3 | # lt_LT | ||
1975 | 4 | ################################################################################ | ||
1976 | 5 | # | ||
1977 | 6 | # Lithuanian language support assembled from contributions provided by: | ||
1978 | 7 | # Paulius Sladkevičius | ||
1979 | 8 | # | ||
1980 | 9 | ################################################################################ | ||
1981 | 10 | |||
1982 | 11 | from report_aeroo.ctt_objects import ctt_language | ||
1983 | 12 | |||
1984 | 13 | class lt_LT(ctt_language): | ||
1985 | 14 | def _init_lang(self): | ||
1986 | 15 | self.name = 'lt_LT' | ||
1987 | 16 | # digits - masculine, singular | ||
1988 | 17 | self.number_sng_msc = [u'nulis', u'vienas', u'du', u'trys', u'keturi', | ||
1989 | 18 | u'penkti', u'šeši', u'septyni', u'aštuoni', | ||
1990 | 19 | u'devyni'] | ||
1991 | 20 | # tens - masculine, singular | ||
1992 | 21 | self.tens_sng_msc = [u'nulis', u'vienas', u'dvi', u'tris', | ||
1993 | 22 | u'keturias', u'penkias', u'šešias', u'septynias', | ||
1994 | 23 | u'aštuonias', u'devynias'] | ||
1995 | 24 | # teens - masculine | ||
1996 | 25 | self.teens = [u'dešimt', u'vienuolika', u'dvylika', u'trylika', | ||
1997 | 26 | u'keturiolika', u'penkiolika', u'šešiolika', | ||
1998 | 27 | u'septyniolika', u'aštuonolika', u'devyniolika'] | ||
1999 | 28 | # multiplier - masculine, singular | ||
2000 | 29 | self.multi_sng_msc = [u' šimtas', u' tūkstantis', u' milijonas', | ||
2001 | 30 | u' milijardas'] | ||
2002 | 31 | # multiplier - masculine, plural | ||
2003 | 32 | self.multi_plr_msc = [u' šimtai', u' tūkstančiai', u' milijonai', | ||
2004 | 33 | u' milijardai'] | ||
2005 | 34 | # multiplier - masculine, plural (other form) | ||
2006 | 35 | self.multi_plr_msc_2 = [u' šimtų', u' tūkstančių', u' milijonų', | ||
2007 | 36 | u' milijardų'] | ||
2008 | 37 | |||
2009 | 38 | # next line is needed for correct loading of currencies | ||
2010 | 39 | import currencies | ||
2011 | 40 | return currencies | ||
2012 | 41 | |||
2013 | 42 | |||
2014 | 43 | def wordify(self, chunk, chunknr, gender): | ||
2015 | 44 | if gender == 'm': | ||
2016 | 45 | number = self.number_sng_msc | ||
2017 | 46 | elif gender == 'f': | ||
2018 | 47 | number = self.number_sng_fem | ||
2019 | 48 | elif gender == 'n': | ||
2020 | 49 | number = self.number_sng_neu | ||
2021 | 50 | words = u'' | ||
2022 | 51 | digit1 = u'' | ||
2023 | 52 | digit2 = u'' | ||
2024 | 53 | digit3 = u'' | ||
2025 | 54 | chunklength = len(chunk) | ||
2026 | 55 | # placing digits in right places | ||
2027 | 56 | if chunklength == 1: | ||
2028 | 57 | digit3 = chunk[0 : 1] | ||
2029 | 58 | if chunklength == 2: | ||
2030 | 59 | digit2 = chunk[0 : 1] | ||
2031 | 60 | digit3 = chunk[1 : 2] | ||
2032 | 61 | if chunklength == 3: | ||
2033 | 62 | digit1 = chunk[0 : 1] | ||
2034 | 63 | digit2 = chunk[1 : 2] | ||
2035 | 64 | digit3 = chunk[-1] | ||
2036 | 65 | # processing zero | ||
2037 | 66 | if chunklength == 1 and digit3 == '0' : | ||
2038 | 67 | return number[0] | ||
2039 | 68 | # processing hundreds | ||
2040 | 69 | if chunklength == 3 : | ||
2041 | 70 | if digit1 == '1' : | ||
2042 | 71 | words += self.multi_sng_msc[0] | ||
2043 | 72 | else : | ||
2044 | 73 | if int(digit1) > 1 : words += number[int(digit1)] + \ | ||
2045 | 74 | self.multi_plr_msc[0] | ||
2046 | 75 | # processing tens | ||
2047 | 76 | if chunklength > 1: | ||
2048 | 77 | spacer = '' | ||
2049 | 78 | if len(words) > 0 : spacer = ' ' | ||
2050 | 79 | if digit2 == '1': | ||
2051 | 80 | words += spacer + self.number_teens[int(digit3)] | ||
2052 | 81 | else: | ||
2053 | 82 | if int(digit2) > 1 and int(digit2) > 0: | ||
2054 | 83 | words += spacer + self.tens_sng_msc[int(digit2)] + u'dešimt' | ||
2055 | 84 | |||
2056 | 85 | # processing ones | ||
2057 | 86 | if chunklength > 0 and digit2 != '1' : | ||
2058 | 87 | spacer = '' | ||
2059 | 88 | if len(words) > 0: spacer = u' ' | ||
2060 | 89 | if int(digit3) > 0: | ||
2061 | 90 | words += spacer + number[int(digit3)] | ||
2062 | 91 | # end processing | ||
2063 | 92 | if len(words) > 0 : | ||
2064 | 93 | if digit3 == '1' and chunknr > 0: | ||
2065 | 94 | return words + self.multi_sng_msc[chunknr] | ||
2066 | 95 | elif digit3 != '1' and chunknr > 0: | ||
2067 | 96 | if chunklength >= 2 and ((int(chunk) % 10) == 0 or (digit2 == \ | ||
2068 | 97 | '1' and int(digit3) > 0)): | ||
2069 | 98 | return words + multi_plr_msc_2[chunknr] | ||
2070 | 99 | else: | ||
2071 | 100 | return words + multi_plr_msc[chunknr] | ||
2072 | 101 | |||
2073 | 102 | else: | ||
2074 | 103 | return words | ||
2075 | 104 | else: | ||
2076 | 105 | return '' | ||
2077 | 106 | |||
2078 | 107 | lt_LT() | ||
2079 | 0 | 108 | ||
2080 | === added directory 'report_aeroo/ctt_languages/lt_LT/currencies' | |||
2081 | === added file 'report_aeroo/ctt_languages/lt_LT/currencies/__init__.py' | |||
2082 | --- report_aeroo/ctt_languages/lt_LT/currencies/__init__.py 1970-01-01 00:00:00 +0000 | |||
2083 | +++ report_aeroo/ctt_languages/lt_LT/currencies/__init__.py 2014-04-05 13:18:49 +0000 | |||
2084 | @@ -0,0 +1,3 @@ | |||
2085 | 1 | #!/usr/bin/python | ||
2086 | 2 | # -*- coding: utf8 -*- | ||
2087 | 3 | # Please do not edit this file! | ||
2088 | 0 | 4 | ||
2089 | === added file 'report_aeroo/ctt_languages/lt_LT/currencies/eur.py' | |||
2090 | --- report_aeroo/ctt_languages/lt_LT/currencies/eur.py 1970-01-01 00:00:00 +0000 | |||
2091 | +++ report_aeroo/ctt_languages/lt_LT/currencies/eur.py 2014-04-05 13:18:49 +0000 | |||
2092 | @@ -0,0 +1,25 @@ | |||
2093 | 1 | #!/usr/bin/python | ||
2094 | 2 | # -*- coding: utf8 -*- | ||
2095 | 3 | |||
2096 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2097 | 5 | |||
2098 | 6 | class eur(ctt_currency): | ||
2099 | 7 | def _init_currency(self): | ||
2100 | 8 | self.language = u'lt_LT' | ||
2101 | 9 | self.code = u'EUR' | ||
2102 | 10 | self.fractions = 100 | ||
2103 | 11 | self.cur_singular = u' euras' | ||
2104 | 12 | # default plural form for currency | ||
2105 | 13 | self.cur_plural = u' eurų' | ||
2106 | 14 | # betwean 1 and 10 yields different plural form, if defined | ||
2107 | 15 | self.cur_plural_2to10 = u' eurai' | ||
2108 | 16 | self.frc_singular = u' centas' | ||
2109 | 17 | # default plural form for fractions | ||
2110 | 18 | self.frc_plural = u' centų' | ||
2111 | 19 | # betwean 1 and 10 yields different plural form, if defined | ||
2112 | 20 | self.frc_plural_2to10 = u' centai' | ||
2113 | 21 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
2114 | 22 | self.cur_gram_gender = 'm' | ||
2115 | 23 | self.frc_gram_gender = 'm' | ||
2116 | 24 | |||
2117 | 25 | eur() | ||
2118 | 0 | 26 | ||
2119 | === added file 'report_aeroo/ctt_languages/lt_LT/currencies/ltl.py' | |||
2120 | --- report_aeroo/ctt_languages/lt_LT/currencies/ltl.py 1970-01-01 00:00:00 +0000 | |||
2121 | +++ report_aeroo/ctt_languages/lt_LT/currencies/ltl.py 2014-04-05 13:18:49 +0000 | |||
2122 | @@ -0,0 +1,25 @@ | |||
2123 | 1 | #!/usr/bin/python | ||
2124 | 2 | # -*- coding: utf8 -*- | ||
2125 | 3 | |||
2126 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2127 | 5 | |||
2128 | 6 | class ltl(ctt_currency): | ||
2129 | 7 | def _init_currency(self): | ||
2130 | 8 | self.language = u'lt_LT' | ||
2131 | 9 | self.code = u'LTL' | ||
2132 | 10 | self.fractions = 100 | ||
2133 | 11 | self.cur_singular = u' litas' | ||
2134 | 12 | # default plural form for currency | ||
2135 | 13 | self.cur_plural = u' litų' | ||
2136 | 14 | # betwean 1 and 10 yields different plural form, if defined | ||
2137 | 15 | self.cur_plural_2to10 = u' litai' | ||
2138 | 16 | self.frc_singular = u' centas' | ||
2139 | 17 | # default plural form for fractions | ||
2140 | 18 | self.frc_plural = u' centų' | ||
2141 | 19 | # betwean 1 and 10 yields different plural form, if defined | ||
2142 | 20 | self.frc_plural_2to10 = u' centai' | ||
2143 | 21 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
2144 | 22 | self.cur_gram_gender = 'm' | ||
2145 | 23 | self.frc_gram_gender = 'm' | ||
2146 | 24 | |||
2147 | 25 | ltl() | ||
2148 | 0 | 26 | ||
2149 | === added file 'report_aeroo/ctt_languages/lt_LT/currencies/lvl.py' | |||
2150 | --- report_aeroo/ctt_languages/lt_LT/currencies/lvl.py 1970-01-01 00:00:00 +0000 | |||
2151 | +++ report_aeroo/ctt_languages/lt_LT/currencies/lvl.py 2014-04-05 13:18:49 +0000 | |||
2152 | @@ -0,0 +1,25 @@ | |||
2153 | 1 | #!/usr/bin/python | ||
2154 | 2 | # -*- coding: utf8 -*- | ||
2155 | 3 | |||
2156 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2157 | 5 | |||
2158 | 6 | class lvl(ctt_currency): | ||
2159 | 7 | def _init_currency(self): | ||
2160 | 8 | self.language = u'lt_LT' | ||
2161 | 9 | self.code = u'LVL' | ||
2162 | 10 | self.fractions = 100 | ||
2163 | 11 | self.cur_singular = u' latas' | ||
2164 | 12 | # default plural form for currency | ||
2165 | 13 | self.cur_plural = u' latų' | ||
2166 | 14 | # betwean 1 and 10 yields different plural form, if defined | ||
2167 | 15 | self.cur_plural_2to10 = u' latai' | ||
2168 | 16 | self.frc_singular = u' santimas' | ||
2169 | 17 | # default plural form for fractions | ||
2170 | 18 | self.frc_plural = u' santimų' | ||
2171 | 19 | # betwean 1 and 10 yields different plural form, if defined | ||
2172 | 20 | self.frc_plural_2to10 = u' santimai' | ||
2173 | 21 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
2174 | 22 | self.cur_gram_gender = 'm' | ||
2175 | 23 | self.frc_gram_gender = 'm' | ||
2176 | 24 | |||
2177 | 25 | lvl() | ||
2178 | 0 | 26 | ||
2179 | === added file 'report_aeroo/ctt_languages/lt_LT/currencies/uah.py' | |||
2180 | --- report_aeroo/ctt_languages/lt_LT/currencies/uah.py 1970-01-01 00:00:00 +0000 | |||
2181 | +++ report_aeroo/ctt_languages/lt_LT/currencies/uah.py 2014-04-05 13:18:49 +0000 | |||
2182 | @@ -0,0 +1,25 @@ | |||
2183 | 1 | #!/usr/bin/python | ||
2184 | 2 | # -*- coding: utf8 -*- | ||
2185 | 3 | |||
2186 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2187 | 5 | |||
2188 | 6 | class uah(ctt_currency): | ||
2189 | 7 | def _init_currency(self): | ||
2190 | 8 | self.language = u'lt_LT' | ||
2191 | 9 | self.code = u'UAH' | ||
2192 | 10 | self.fractions = 100 | ||
2193 | 11 | self.cur_singular = u' grivna' | ||
2194 | 12 | # default plural form for currency | ||
2195 | 13 | self.cur_plural = u' grivnų' | ||
2196 | 14 | # betwean 1 and 10 yields different plural form, if defined | ||
2197 | 15 | self.cur_plural_2to10 = u' grivnai' | ||
2198 | 16 | self.frc_singular = u' kapeika' | ||
2199 | 17 | # default plural form for fractions | ||
2200 | 18 | self.frc_plural = u' kapeikų' | ||
2201 | 19 | # betwean 1 and 10 yields different plural form, if defined | ||
2202 | 20 | self.frc_plural_2to10 = u' kapeikos' | ||
2203 | 21 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
2204 | 22 | self.cur_gram_gender = 'm' | ||
2205 | 23 | self.frc_gram_gender = 'm' | ||
2206 | 24 | |||
2207 | 25 | uah() | ||
2208 | 0 | 26 | ||
2209 | === added file 'report_aeroo/ctt_languages/lt_LT/currencies/usd.py' | |||
2210 | --- report_aeroo/ctt_languages/lt_LT/currencies/usd.py 1970-01-01 00:00:00 +0000 | |||
2211 | +++ report_aeroo/ctt_languages/lt_LT/currencies/usd.py 2014-04-05 13:18:49 +0000 | |||
2212 | @@ -0,0 +1,25 @@ | |||
2213 | 1 | #!/usr/bin/python | ||
2214 | 2 | # -*- coding: utf8 -*- | ||
2215 | 3 | |||
2216 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2217 | 5 | |||
2218 | 6 | class usd(ctt_currency): | ||
2219 | 7 | def _init_currency(self): | ||
2220 | 8 | self.language = u'lt_LT' | ||
2221 | 9 | self.code = u'USD' | ||
2222 | 10 | self.fractions = 100 | ||
2223 | 11 | self.cur_singular = u' doleris' | ||
2224 | 12 | # default plural form for currency | ||
2225 | 13 | self.cur_plural = u' dolerių' | ||
2226 | 14 | # betwean 1 and 10 yields different plural form, if defined | ||
2227 | 15 | self.cur_plural_2to10 = u' doleriai' | ||
2228 | 16 | self.frc_singular = u' centas' | ||
2229 | 17 | # default plural form for fractions | ||
2230 | 18 | self.frc_plural = u' centų' | ||
2231 | 19 | # betwean 1 and 10 yields different plural form, if defined | ||
2232 | 20 | self.frc_plural_2to10 = u' centai' | ||
2233 | 21 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
2234 | 22 | self.cur_gram_gender = 'm' | ||
2235 | 23 | self.frc_gram_gender = 'm' | ||
2236 | 24 | |||
2237 | 25 | usd() | ||
2238 | 0 | 26 | ||
2239 | === added directory 'report_aeroo/ctt_languages/lv_LV' | |||
2240 | === added file 'report_aeroo/ctt_languages/lv_LV/__init__.py' | |||
2241 | --- report_aeroo/ctt_languages/lv_LV/__init__.py 1970-01-01 00:00:00 +0000 | |||
2242 | +++ report_aeroo/ctt_languages/lv_LV/__init__.py 2014-04-05 13:18:49 +0000 | |||
2243 | @@ -0,0 +1,101 @@ | |||
2244 | 1 | #!/usr/bin/python | ||
2245 | 2 | # -*- coding: utf8 -*- | ||
2246 | 3 | # lv_LV | ||
2247 | 4 | |||
2248 | 5 | from report_aeroo.ctt_objects import ctt_language | ||
2249 | 6 | |||
2250 | 7 | class lv_LV(ctt_language): | ||
2251 | 8 | def _init_lang(self): | ||
2252 | 9 | self.name = 'lv_LV' | ||
2253 | 10 | # digits - masculine, singular | ||
2254 | 11 | self.number_sng_msc = [u'nulle', u'viens', u'divi', | ||
2255 | 12 | u'trīs', u'četri', u'pieci', | ||
2256 | 13 | u'seši', u'septiņi', u'astoņi', | ||
2257 | 14 | u'deviņi'] | ||
2258 | 15 | # digits - feminine, singular | ||
2259 | 16 | self.number_sng_fem = [u'nulle', u'viena', u'divas', | ||
2260 | 17 | u'trīs', u'četras', u'piecas', | ||
2261 | 18 | u'sešas', u'septiņas', u'astoņas', | ||
2262 | 19 | u'deviņas'] | ||
2263 | 20 | # tens - masculine, singular | ||
2264 | 21 | self.tens_sng_msc = [u'nulle', u'vien', u'div', | ||
2265 | 22 | u'trīs', u'četr', u'piec', | ||
2266 | 23 | u'seš', u'septiņ', u'astoņ', | ||
2267 | 24 | u'deviņ'] | ||
2268 | 25 | # teens - masculine | ||
2269 | 26 | self.teens = [u'desmit', u'vienpadsmit', u'divpadsmit', | ||
2270 | 27 | u'trīspadsmit', u'četrpadsmit', u'piecpadsmit', | ||
2271 | 28 | u'sešpadsmit', u'septiņpadsmit', u'astoņpadsmit', | ||
2272 | 29 | u'deviņpadsmit'] | ||
2273 | 30 | # multiplier - masculine, singular | ||
2274 | 31 | self.multi_sng_msc = [u'simts', u' tūkstotis', u' miljons', | ||
2275 | 32 | u' miljards'] | ||
2276 | 33 | # multiplier - masculine, plural | ||
2277 | 34 | self.multi_plr_msc = [u' simti', u' tūkstoši', u' miljoni', | ||
2278 | 35 | u' miljardi'] | ||
2279 | 36 | |||
2280 | 37 | # next line is needed for correct loading of currencies | ||
2281 | 38 | import currencies | ||
2282 | 39 | return currencies | ||
2283 | 40 | |||
2284 | 41 | |||
2285 | 42 | def wordify(self, chunk, chunknr, gender): | ||
2286 | 43 | if gender == 'm': | ||
2287 | 44 | number = self.number_sng_msc | ||
2288 | 45 | elif gender == 'f': | ||
2289 | 46 | number = self.number_sng_fem | ||
2290 | 47 | elif gender == 'n': | ||
2291 | 48 | number = self.number_sng_neu | ||
2292 | 49 | words = u'' | ||
2293 | 50 | digit1 = u'' | ||
2294 | 51 | digit2 = u'' | ||
2295 | 52 | digit3 = u'' | ||
2296 | 53 | chunklength = len(chunk) | ||
2297 | 54 | # placing digits in right places | ||
2298 | 55 | if chunklength == 1: | ||
2299 | 56 | digit3 = chunk[0 : 1] | ||
2300 | 57 | if chunklength == 2: | ||
2301 | 58 | digit2 = chunk[0 : 1] | ||
2302 | 59 | digit3 = chunk[1 : 2] | ||
2303 | 60 | if chunklength == 3: | ||
2304 | 61 | digit1 = chunk[0 : 1] | ||
2305 | 62 | digit2 = chunk[1 : 2] | ||
2306 | 63 | digit3 = chunk[-1] | ||
2307 | 64 | # processing zero | ||
2308 | 65 | if chunklength == 1 and digit3 == '0' : | ||
2309 | 66 | return number[0] | ||
2310 | 67 | # processing hundreds | ||
2311 | 68 | if chunklength == 3 : | ||
2312 | 69 | if digit1 == '1' : | ||
2313 | 70 | words += self.multi_sng_msc[0] | ||
2314 | 71 | else : | ||
2315 | 72 | if int(digit1) > 1 : words += number[int(digit1)] + \ | ||
2316 | 73 | self.multi_plr_msc[0] | ||
2317 | 74 | # processing tens | ||
2318 | 75 | if chunklength > 1: | ||
2319 | 76 | spacer = '' | ||
2320 | 77 | if len(words) > 0 : spacer = ' ' | ||
2321 | 78 | if digit2 == '1': | ||
2322 | 79 | words += spacer + self.teens[int(digit3)] | ||
2323 | 80 | else: | ||
2324 | 81 | if int(digit2) > 1 and int(digit2) > 0: | ||
2325 | 82 | words += spacer + self.tens_sng_msc[int(digit2)] + u'desmit' | ||
2326 | 83 | |||
2327 | 84 | # processing ones | ||
2328 | 85 | if chunklength > 0 and digit2 != '1' : | ||
2329 | 86 | spacer = '' | ||
2330 | 87 | if len(words) > 0: spacer = u' ' | ||
2331 | 88 | if int(digit3) > 0: | ||
2332 | 89 | words += spacer + number[int(digit3)] | ||
2333 | 90 | # end processing | ||
2334 | 91 | if len(words) > 0 : | ||
2335 | 92 | if digit3 == '1' and chunknr > 0: | ||
2336 | 93 | return words + self.multi_sng_msc[chunknr] | ||
2337 | 94 | elif digit3 != '1' and chunknr > 0: | ||
2338 | 95 | return words + self.multi_plr_msc[chunknr] | ||
2339 | 96 | else: | ||
2340 | 97 | return words | ||
2341 | 98 | else: | ||
2342 | 99 | return '' | ||
2343 | 100 | |||
2344 | 101 | lv_LV() | ||
2345 | 0 | 102 | ||
2346 | === added directory 'report_aeroo/ctt_languages/lv_LV/currencies' | |||
2347 | === added file 'report_aeroo/ctt_languages/lv_LV/currencies/__init__.py' | |||
2348 | --- report_aeroo/ctt_languages/lv_LV/currencies/__init__.py 1970-01-01 00:00:00 +0000 | |||
2349 | +++ report_aeroo/ctt_languages/lv_LV/currencies/__init__.py 2014-04-05 13:18:49 +0000 | |||
2350 | @@ -0,0 +1,3 @@ | |||
2351 | 1 | #!/usr/bin/python | ||
2352 | 2 | # -*- coding: utf8 -*- | ||
2353 | 3 | # Please do not edit this file! | ||
2354 | 0 | 4 | ||
2355 | === added file 'report_aeroo/ctt_languages/lv_LV/currencies/eur.py' | |||
2356 | --- report_aeroo/ctt_languages/lv_LV/currencies/eur.py 1970-01-01 00:00:00 +0000 | |||
2357 | +++ report_aeroo/ctt_languages/lv_LV/currencies/eur.py 2014-04-05 13:18:49 +0000 | |||
2358 | @@ -0,0 +1,22 @@ | |||
2359 | 1 | #!/usr/bin/python | ||
2360 | 2 | # -*- coding: utf8 -*- | ||
2361 | 3 | |||
2362 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2363 | 5 | |||
2364 | 6 | class eur(ctt_currency): | ||
2365 | 7 | def _init_currency(self): | ||
2366 | 8 | self.language = u'lv_LV' | ||
2367 | 9 | self.code = u'EUR' | ||
2368 | 10 | self.fractions = 100 | ||
2369 | 11 | self.cur_singular = u' eiro' | ||
2370 | 12 | self.cur_plural = u' eiro' | ||
2371 | 13 | self.frc_singular = u' cents' | ||
2372 | 14 | # default plural form for fractions | ||
2373 | 15 | self.frc_plural = u' centu' | ||
2374 | 16 | # betwean 1 and 10 yields different plural form, if defined | ||
2375 | 17 | self.frc_plural_2to10 = u' centi' | ||
2376 | 18 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
2377 | 19 | self.cur_gram_gender = 'm' | ||
2378 | 20 | self.frc_gram_gender = 'm' | ||
2379 | 21 | |||
2380 | 22 | eur() | ||
2381 | 0 | 23 | ||
2382 | === added file 'report_aeroo/ctt_languages/lv_LV/currencies/ltl.py' | |||
2383 | --- report_aeroo/ctt_languages/lv_LV/currencies/ltl.py 1970-01-01 00:00:00 +0000 | |||
2384 | +++ report_aeroo/ctt_languages/lv_LV/currencies/ltl.py 2014-04-05 13:18:49 +0000 | |||
2385 | @@ -0,0 +1,25 @@ | |||
2386 | 1 | #!/usr/bin/python | ||
2387 | 2 | # -*- coding: utf8 -*- | ||
2388 | 3 | |||
2389 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2390 | 5 | |||
2391 | 6 | class ltl(ctt_currency): | ||
2392 | 7 | def _init_currency(self): | ||
2393 | 8 | self.language = u'lv_LV' | ||
2394 | 9 | self.code = u'LTL' | ||
2395 | 10 | self.fractions = 100 | ||
2396 | 11 | self.cur_singular = u' lits' | ||
2397 | 12 | # default plural form for currency | ||
2398 | 13 | self.cur_plural = u' litu' | ||
2399 | 14 | # betwean 1 and 10 yields different plural form, if defined | ||
2400 | 15 | self.cur_plural_2to10 = u' liti' | ||
2401 | 16 | self.frc_singular = u' cents' | ||
2402 | 17 | # default plural form for fractions | ||
2403 | 18 | self.frc_plural = u' centu' | ||
2404 | 19 | # betwean 1 and 10 yields different plural form, if defined | ||
2405 | 20 | self.frc_plural_2to10 = u' centi' | ||
2406 | 21 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
2407 | 22 | self.cur_gram_gender = 'm' | ||
2408 | 23 | self.frc_gram_gender = 'm' | ||
2409 | 24 | |||
2410 | 25 | ltl() | ||
2411 | 0 | 26 | ||
2412 | === added file 'report_aeroo/ctt_languages/lv_LV/currencies/lvl.py' | |||
2413 | --- report_aeroo/ctt_languages/lv_LV/currencies/lvl.py 1970-01-01 00:00:00 +0000 | |||
2414 | +++ report_aeroo/ctt_languages/lv_LV/currencies/lvl.py 2014-04-05 13:18:49 +0000 | |||
2415 | @@ -0,0 +1,25 @@ | |||
2416 | 1 | #!/usr/bin/python | ||
2417 | 2 | # -*- coding: utf8 -*- | ||
2418 | 3 | |||
2419 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2420 | 5 | |||
2421 | 6 | class lvl(ctt_currency): | ||
2422 | 7 | def _init_currency(self): | ||
2423 | 8 | self.language = u'lv_LV' | ||
2424 | 9 | self.code = u'LVL' | ||
2425 | 10 | self.fractions = 100 | ||
2426 | 11 | self.cur_singular = u' lats' | ||
2427 | 12 | # default plural form for currency | ||
2428 | 13 | self.cur_plural = u' latu' | ||
2429 | 14 | # betwean 1 and 10 yields different plural form, if defined | ||
2430 | 15 | self.cur_plural_2to10 = u' lati' | ||
2431 | 16 | self.frc_singular = u' santīms' | ||
2432 | 17 | # default plural form for fractions | ||
2433 | 18 | self.frc_plural = u' santīmi' | ||
2434 | 19 | # betwean 1 and 10 yields different plural form, if defined | ||
2435 | 20 | self.frc_plural_2to10 = u' santīmu' | ||
2436 | 21 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
2437 | 22 | self.cur_gram_gender = 'm' | ||
2438 | 23 | self.frc_gram_gender = 'm' | ||
2439 | 24 | |||
2440 | 25 | lvl() | ||
2441 | 0 | 26 | ||
2442 | === added file 'report_aeroo/ctt_languages/lv_LV/currencies/mxn.py' | |||
2443 | --- report_aeroo/ctt_languages/lv_LV/currencies/mxn.py 1970-01-01 00:00:00 +0000 | |||
2444 | +++ report_aeroo/ctt_languages/lv_LV/currencies/mxn.py 2014-04-05 13:18:49 +0000 | |||
2445 | @@ -0,0 +1,22 @@ | |||
2446 | 1 | #!/usr/bin/python | ||
2447 | 2 | # -*- coding: utf8 -*- | ||
2448 | 3 | |||
2449 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2450 | 5 | |||
2451 | 6 | class mxn(ctt_currency): | ||
2452 | 7 | def _init_currency(self): | ||
2453 | 8 | self.language = u'lv_LV' | ||
2454 | 9 | self.code = u'MXN' | ||
2455 | 10 | self.fractions = 100 | ||
2456 | 11 | self.cur_singular = u' Meksikas peso' | ||
2457 | 12 | self.cur_plural = self.cur_singular | ||
2458 | 13 | self.frc_singular = u' cents' | ||
2459 | 14 | # default plural form for fractions | ||
2460 | 15 | self.frc_plural = u' centu' | ||
2461 | 16 | # betwean 1 and 10 yields different plural form, if defined | ||
2462 | 17 | self.frc_plural_2to10 = u' centi' | ||
2463 | 18 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
2464 | 19 | self.cur_gram_gender = 'm' | ||
2465 | 20 | self.frc_gram_gender = 'm' | ||
2466 | 21 | |||
2467 | 22 | mxn() | ||
2468 | 0 | 23 | ||
2469 | === added file 'report_aeroo/ctt_languages/lv_LV/currencies/rub.py' | |||
2470 | --- report_aeroo/ctt_languages/lv_LV/currencies/rub.py 1970-01-01 00:00:00 +0000 | |||
2471 | +++ report_aeroo/ctt_languages/lv_LV/currencies/rub.py 2014-04-05 13:18:49 +0000 | |||
2472 | @@ -0,0 +1,25 @@ | |||
2473 | 1 | #!/usr/bin/python | ||
2474 | 2 | # -*- coding: utf8 -*- | ||
2475 | 3 | |||
2476 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2477 | 5 | |||
2478 | 6 | class rub(ctt_currency): | ||
2479 | 7 | def _init_currency(self): | ||
2480 | 8 | self.language = u'lv_LV' | ||
2481 | 9 | self.code = u'RUB' | ||
2482 | 10 | self.fractions = 100 | ||
2483 | 11 | self.cur_singular = u' rublis' | ||
2484 | 12 | # default plural form for currency | ||
2485 | 13 | self.cur_plural = u' rubļu' | ||
2486 | 14 | # betwean 1 and 10 yields different plural form, if defined | ||
2487 | 15 | self.cur_plural_2to10 = u' rubļi' | ||
2488 | 16 | self.frc_singular = u' kapeika' | ||
2489 | 17 | # default plural form for fractions | ||
2490 | 18 | self.frc_plural = u' kapeiku' | ||
2491 | 19 | # betwean 1 and 10 yields different plural form, if defined | ||
2492 | 20 | self.frc_plural_2to10 = u' kapeikas' | ||
2493 | 21 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
2494 | 22 | self.cur_gram_gender = 'm' | ||
2495 | 23 | self.frc_gram_gender = 'f' | ||
2496 | 24 | |||
2497 | 25 | rub() | ||
2498 | 0 | 26 | ||
2499 | === added file 'report_aeroo/ctt_languages/lv_LV/currencies/trl.py' | |||
2500 | --- report_aeroo/ctt_languages/lv_LV/currencies/trl.py 1970-01-01 00:00:00 +0000 | |||
2501 | +++ report_aeroo/ctt_languages/lv_LV/currencies/trl.py 2014-04-05 13:18:49 +0000 | |||
2502 | @@ -0,0 +1,25 @@ | |||
2503 | 1 | #!/usr/bin/python | ||
2504 | 2 | # -*- coding: utf8 -*- | ||
2505 | 3 | |||
2506 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2507 | 5 | |||
2508 | 6 | class trl(ctt_currency): | ||
2509 | 7 | def _init_currency(self): | ||
2510 | 8 | self.language = u'lv_LV' | ||
2511 | 9 | self.code = u'TRL' | ||
2512 | 10 | self.fractions = 100 | ||
2513 | 11 | self.cur_singular = u' Turku lira' | ||
2514 | 12 | # default plural form for currency | ||
2515 | 13 | self.cur_plural = u' Turku liru' | ||
2516 | 14 | # betwean 1 and 10 yields different plural form, if defined | ||
2517 | 15 | self.cur_plural_2to10 = u' Turku liras' | ||
2518 | 16 | self.frc_singular = u' kurušs' | ||
2519 | 17 | # default plural form for fractions | ||
2520 | 18 | self.frc_plural = u' kurušu' | ||
2521 | 19 | # betwean 1 and 10 yields different plural form, if defined | ||
2522 | 20 | self.frc_plural_2to10 = u' kuruši' | ||
2523 | 21 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
2524 | 22 | self.cur_gram_gender = 'f' | ||
2525 | 23 | self.frc_gram_gender = 'm' | ||
2526 | 24 | |||
2527 | 25 | trl() | ||
2528 | 0 | 26 | ||
2529 | === added file 'report_aeroo/ctt_languages/lv_LV/currencies/uah.py' | |||
2530 | --- report_aeroo/ctt_languages/lv_LV/currencies/uah.py 1970-01-01 00:00:00 +0000 | |||
2531 | +++ report_aeroo/ctt_languages/lv_LV/currencies/uah.py 2014-04-05 13:18:49 +0000 | |||
2532 | @@ -0,0 +1,24 @@ | |||
2533 | 1 | #!/usr/bin/python | ||
2534 | 2 | # -*- coding: utf8 -*- | ||
2535 | 3 | |||
2536 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2537 | 5 | |||
2538 | 6 | class uah(ctt_currency): | ||
2539 | 7 | def _init_currency(self): | ||
2540 | 8 | self.language = u'lv_LV' | ||
2541 | 9 | self.code = u'UAH' | ||
2542 | 10 | self.fractions = 100 | ||
2543 | 11 | self.cur_singular = u' grivna' | ||
2544 | 12 | # default plural form for currency | ||
2545 | 13 | self.cur_plural = u' grivnu' | ||
2546 | 14 | # betwean 1 and 10 yields different plural form, if defined | ||
2547 | 15 | self.cur_plural_2to10 = u' grivnas' | ||
2548 | 16 | self.frc_singular = u' kapeika' | ||
2549 | 17 | # default plural form for fractions | ||
2550 | 18 | self.frc_plural = u' kapeiku' | ||
2551 | 19 | # betwean 1 and 10 yields different plural form, if defined | ||
2552 | 20 | self.frc_plural_2to10 = u' kapeikas' | ||
2553 | 21 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
2554 | 22 | self.cur_gram_gender = 'f' | ||
2555 | 23 | self.frc_gram_gender = 'f' | ||
2556 | 24 | uah() | ||
2557 | 0 | 25 | ||
2558 | === added file 'report_aeroo/ctt_languages/lv_LV/currencies/usd.py' | |||
2559 | --- report_aeroo/ctt_languages/lv_LV/currencies/usd.py 1970-01-01 00:00:00 +0000 | |||
2560 | +++ report_aeroo/ctt_languages/lv_LV/currencies/usd.py 2014-04-05 13:18:49 +0000 | |||
2561 | @@ -0,0 +1,25 @@ | |||
2562 | 1 | #!/usr/bin/python | ||
2563 | 2 | # -*- coding: utf8 -*- | ||
2564 | 3 | |||
2565 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2566 | 5 | |||
2567 | 6 | class usd(ctt_currency): | ||
2568 | 7 | def _init_currency(self): | ||
2569 | 8 | self.language = u'lv_LV' | ||
2570 | 9 | self.code = u'USD' | ||
2571 | 10 | self.fractions = 100 | ||
2572 | 11 | self.cur_singular = u' ASV dolārs' | ||
2573 | 12 | # default plural form for currency | ||
2574 | 13 | self.cur_plural = u' ASV dolāru' | ||
2575 | 14 | # betwean 1 and 10 yields different plural form, if defined | ||
2576 | 15 | self.cur_plural_2to10 = u' ASV dolāri' | ||
2577 | 16 | self.frc_singular = u' cents' | ||
2578 | 17 | # default plural form for fractions | ||
2579 | 18 | self.frc_plural = u' centu' | ||
2580 | 19 | # betwean 1 and 10 yields different plural form, if defined | ||
2581 | 20 | self.frc_plural_2to10 = u' centi' | ||
2582 | 21 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
2583 | 22 | self.cur_gram_gender = 'm' | ||
2584 | 23 | self.frc_gram_gender = 'm' | ||
2585 | 24 | |||
2586 | 25 | usd() | ||
2587 | 0 | 26 | ||
2588 | === added directory 'report_aeroo/ctt_languages/ru_RU' | |||
2589 | === added file 'report_aeroo/ctt_languages/ru_RU/__init__.py' | |||
2590 | --- report_aeroo/ctt_languages/ru_RU/__init__.py 1970-01-01 00:00:00 +0000 | |||
2591 | +++ report_aeroo/ctt_languages/ru_RU/__init__.py 2014-04-05 13:18:49 +0000 | |||
2592 | @@ -0,0 +1,110 @@ | |||
2593 | 1 | #!/usr/bin/python | ||
2594 | 2 | # -*- coding: utf8 -*- | ||
2595 | 3 | # ru_RU | ||
2596 | 4 | |||
2597 | 5 | from report_aeroo.ctt_objects import ctt_language | ||
2598 | 6 | |||
2599 | 7 | class ru_RU(ctt_language): | ||
2600 | 8 | def _init_lang(self): | ||
2601 | 9 | # language name | ||
2602 | 10 | self.name = 'ru_RU' | ||
2603 | 11 | # digits - masculine, singular | ||
2604 | 12 | self.number_sng_msc = [u'ноль', u'один', u'два', u'три', u'четыре', | ||
2605 | 13 | u'пять', u'шесть', u'семь', u'восемь', u'девять'] | ||
2606 | 14 | # tens - masculine, singular | ||
2607 | 15 | self.number_sng_fem = [u'ноль', u'одна', u'две', u'три', u'четыре', | ||
2608 | 16 | u'пять', u'шесть', u'семь', u'восемь', u'девять'] | ||
2609 | 17 | # tens - masculine, plural | ||
2610 | 18 | self.number_plr_msc = [u'', u'один', u'двa', u'три', u'четыре', u'пять', | ||
2611 | 19 | u'шесть', u'семь', u'восемь', u'девять'] | ||
2612 | 20 | # teens - masculine | ||
2613 | 21 | self.number_teens = [u'десять', u'одиннадцать', u'двенадцать', | ||
2614 | 22 | u'тринадцать', u'четырнадцать', u'пятнадцать', | ||
2615 | 23 | u'шестнадцать', u'семнадцать', u'восемнадцать', | ||
2616 | 24 | u'девятнадцать'] | ||
2617 | 25 | # multiplier - masculine, singular | ||
2618 | 26 | self.multi_sng_msc = [u'стo', u' тысяча', u' миллион', u' миллиард'] | ||
2619 | 27 | # multiplier - masculine, plural | ||
2620 | 28 | self.multi_plr_msc = [u'сoт', u' тысяч', u' миллионов', u' миллиардов'] | ||
2621 | 29 | |||
2622 | 30 | # next line is needed for correct loading of currencies | ||
2623 | 31 | import currencies | ||
2624 | 32 | return currencies | ||
2625 | 33 | |||
2626 | 34 | |||
2627 | 35 | def wordify(self, chunk, chunknr, gender): | ||
2628 | 36 | if gender == 'm': | ||
2629 | 37 | number = self.number_sng_msc | ||
2630 | 38 | elif gender == 'f': | ||
2631 | 39 | number = self.number_sng_fem | ||
2632 | 40 | elif gender == 'n': | ||
2633 | 41 | number = self.number_sng_neu | ||
2634 | 42 | words = u'' | ||
2635 | 43 | digit1 = u'' | ||
2636 | 44 | digit2 = u'' | ||
2637 | 45 | digit3 = u'' | ||
2638 | 46 | chunklength = len(chunk) | ||
2639 | 47 | # placing digits in right places | ||
2640 | 48 | if chunklength == 1: | ||
2641 | 49 | digit3 = chunk[0 : 1] | ||
2642 | 50 | if chunklength == 2: | ||
2643 | 51 | digit2 = chunk[0 : 1] | ||
2644 | 52 | digit3 = chunk[1 : 2] | ||
2645 | 53 | if chunklength == 3: | ||
2646 | 54 | digit1 = chunk[0 : 1] | ||
2647 | 55 | digit2 = chunk[1 : 2] | ||
2648 | 56 | digit3 = chunk[-1] | ||
2649 | 57 | # processing zero | ||
2650 | 58 | if chunklength == 1 and digit3 == '0' : | ||
2651 | 59 | return number[0] | ||
2652 | 60 | # processing hundreds | ||
2653 | 61 | if chunklength == 3 : | ||
2654 | 62 | if int(digit1) == 1 : | ||
2655 | 63 | words += self.multi_sng_msc[0] | ||
2656 | 64 | elif int(digit1) == 2 : | ||
2657 | 65 | words += u'двести' | ||
2658 | 66 | elif int(digit1) == 3 : | ||
2659 | 67 | words += u'триста' | ||
2660 | 68 | elif int(digit1) == 4 : | ||
2661 | 69 | words += u'четыреста' | ||
2662 | 70 | elif int(digit1) >= 5 : | ||
2663 | 71 | words += self.number_sng_msc[int(digit1)] + self.multi_plr_msc[0] | ||
2664 | 72 | # processing tens | ||
2665 | 73 | if chunklength > 1: | ||
2666 | 74 | spacer = '' | ||
2667 | 75 | if len(words) > 0 : spacer = ' ' | ||
2668 | 76 | if digit2 == '1': | ||
2669 | 77 | words += spacer + self.number_teens[int(digit3)] | ||
2670 | 78 | else: | ||
2671 | 79 | if int(digit2) > 1 and int(digit2) < 4: | ||
2672 | 80 | words += spacer + self.number_plr_msc[int(digit2)] + u'дцать' | ||
2673 | 81 | elif digit2 == '4': | ||
2674 | 82 | words += spacer + u'сорок' | ||
2675 | 83 | elif int(digit2) >= 5 and int(digit2) != 9: | ||
2676 | 84 | words += spacer + self.number_plr_msc[int(digit2)] + u'десят' | ||
2677 | 85 | elif digit2 == '9': | ||
2678 | 86 | words += spacer + u'девяносто' | ||
2679 | 87 | |||
2680 | 88 | # processing ones | ||
2681 | 89 | if chunklength > 0 and digit2 != '1' : | ||
2682 | 90 | spacer = '' | ||
2683 | 91 | if len(words) > 0: spacer = u' ' | ||
2684 | 92 | if chunknr == 1: | ||
2685 | 93 | if int(digit3) == 1 or int(digit3) == 2: | ||
2686 | 94 | words += spacer + self.number_sng_fem[int(digit3)] | ||
2687 | 95 | elif int(digit3) >= 3 and int(digit3) != 0: | ||
2688 | 96 | words += spacer + self.number_sng_msc[int(digit3)] | ||
2689 | 97 | else: | ||
2690 | 98 | if int(digit3) > 0: words += spacer + self.number_sng_msc[int(digit3)] | ||
2691 | 99 | # end processing | ||
2692 | 100 | if len(words) > 0 : | ||
2693 | 101 | if digit3 == '1' and chunknr > 0: | ||
2694 | 102 | return words + self.multi_sng_msc[chunknr] | ||
2695 | 103 | elif digit3 != '1' and chunknr > 0: | ||
2696 | 104 | return words + self.multi_plr_msc[chunknr] | ||
2697 | 105 | else: | ||
2698 | 106 | return words | ||
2699 | 107 | else: | ||
2700 | 108 | return '' | ||
2701 | 109 | |||
2702 | 110 | ru_RU() | ||
2703 | 0 | 111 | ||
2704 | === added directory 'report_aeroo/ctt_languages/ru_RU/currencies' | |||
2705 | === added file 'report_aeroo/ctt_languages/ru_RU/currencies/__init__.py' | |||
2706 | --- report_aeroo/ctt_languages/ru_RU/currencies/__init__.py 1970-01-01 00:00:00 +0000 | |||
2707 | +++ report_aeroo/ctt_languages/ru_RU/currencies/__init__.py 2014-04-05 13:18:49 +0000 | |||
2708 | @@ -0,0 +1,3 @@ | |||
2709 | 1 | #!/usr/bin/python | ||
2710 | 2 | # -*- coding: utf8 -*- | ||
2711 | 3 | # Please do not edit this file! | ||
2712 | 0 | 4 | ||
2713 | === added file 'report_aeroo/ctt_languages/ru_RU/currencies/eur.py' | |||
2714 | --- report_aeroo/ctt_languages/ru_RU/currencies/eur.py 1970-01-01 00:00:00 +0000 | |||
2715 | +++ report_aeroo/ctt_languages/ru_RU/currencies/eur.py 2014-04-05 13:18:49 +0000 | |||
2716 | @@ -0,0 +1,22 @@ | |||
2717 | 1 | #!/usr/bin/python | ||
2718 | 2 | # -*- coding: utf8 -*- | ||
2719 | 3 | |||
2720 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2721 | 5 | |||
2722 | 6 | class eur(ctt_currency): | ||
2723 | 7 | def _init_currency(self): | ||
2724 | 8 | self.language = u'ru_RU' | ||
2725 | 9 | self.code = u'EUR' | ||
2726 | 10 | self.fractions = 100 | ||
2727 | 11 | self.cur_singular = u' евро' | ||
2728 | 12 | self.cur_plural = u' евро' | ||
2729 | 13 | self.frc_singular = u' цент' | ||
2730 | 14 | # default plural form for fractions | ||
2731 | 15 | self.frc_plural = u' центов' | ||
2732 | 16 | self.frc_plural_2_to4 = u' цента' | ||
2733 | 17 | |||
2734 | 18 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
2735 | 19 | self.cur_gram_gender = 'm' | ||
2736 | 20 | self.frc_gram_gender = 'm' | ||
2737 | 21 | |||
2738 | 22 | eur() | ||
2739 | 0 | 23 | ||
2740 | === added file 'report_aeroo/ctt_languages/ru_RU/currencies/ltl.py' | |||
2741 | --- report_aeroo/ctt_languages/ru_RU/currencies/ltl.py 1970-01-01 00:00:00 +0000 | |||
2742 | +++ report_aeroo/ctt_languages/ru_RU/currencies/ltl.py 2014-04-05 13:18:49 +0000 | |||
2743 | @@ -0,0 +1,23 @@ | |||
2744 | 1 | #!/usr/bin/python | ||
2745 | 2 | # -*- coding: utf8 -*- | ||
2746 | 3 | |||
2747 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2748 | 5 | |||
2749 | 6 | class ltl(ctt_currency): | ||
2750 | 7 | def _init_currency(self): | ||
2751 | 8 | self.language = u'ru_RU' | ||
2752 | 9 | self.code = u'LTL' | ||
2753 | 10 | self.fractions = 100 | ||
2754 | 11 | self.cur_singular = u' лит' | ||
2755 | 12 | # default plural form for currency | ||
2756 | 13 | self.cur_plural = u' литов' | ||
2757 | 14 | self.cur_plural_2to4 = u' лита' | ||
2758 | 15 | self.frc_singular = u' цент' | ||
2759 | 16 | # default plural form for fractions | ||
2760 | 17 | self.frc_plural = u' центов' | ||
2761 | 18 | self.frc_plural_2to4 = u' цента' | ||
2762 | 19 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
2763 | 20 | self.cur_gram_gender = 'm' | ||
2764 | 21 | self.frc_gram_gender = 'm' | ||
2765 | 22 | |||
2766 | 23 | ltl() | ||
2767 | 0 | 24 | ||
2768 | === added file 'report_aeroo/ctt_languages/ru_RU/currencies/lvl.py' | |||
2769 | --- report_aeroo/ctt_languages/ru_RU/currencies/lvl.py 1970-01-01 00:00:00 +0000 | |||
2770 | +++ report_aeroo/ctt_languages/ru_RU/currencies/lvl.py 2014-04-05 13:18:49 +0000 | |||
2771 | @@ -0,0 +1,23 @@ | |||
2772 | 1 | #!/usr/bin/python | ||
2773 | 2 | # -*- coding: utf8 -*- | ||
2774 | 3 | |||
2775 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2776 | 5 | |||
2777 | 6 | class lvl(ctt_currency): | ||
2778 | 7 | def _init_currency(self): | ||
2779 | 8 | self.language = u'ru_RU' | ||
2780 | 9 | self.code = u'LVL' | ||
2781 | 10 | self.fractions = 100 | ||
2782 | 11 | self.cur_singular = u' лат' | ||
2783 | 12 | # default plural form for currency | ||
2784 | 13 | self.cur_plural = u' латов' | ||
2785 | 14 | self.cur_plural_2to4 = u' лата' | ||
2786 | 15 | self.frc_singular = u' сантим' | ||
2787 | 16 | # default plural form for fractions | ||
2788 | 17 | self.frc_plural = u' сантимов' | ||
2789 | 18 | self.frc_plural_2to4 = u' сантима' | ||
2790 | 19 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
2791 | 20 | self.cur_gram_gender = 'm' | ||
2792 | 21 | self.frc_gram_gender = 'm' | ||
2793 | 22 | |||
2794 | 23 | lvl() | ||
2795 | 0 | 24 | ||
2796 | === added file 'report_aeroo/ctt_languages/ru_RU/currencies/rub.py' | |||
2797 | --- report_aeroo/ctt_languages/ru_RU/currencies/rub.py 1970-01-01 00:00:00 +0000 | |||
2798 | +++ report_aeroo/ctt_languages/ru_RU/currencies/rub.py 2014-04-05 13:18:49 +0000 | |||
2799 | @@ -0,0 +1,23 @@ | |||
2800 | 1 | #!/usr/bin/python | ||
2801 | 2 | # -*- coding: utf8 -*- | ||
2802 | 3 | |||
2803 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2804 | 5 | |||
2805 | 6 | class rub(ctt_currency): | ||
2806 | 7 | def _init_currency(self): | ||
2807 | 8 | self.language = u'ru_RU' | ||
2808 | 9 | self.code = u'RUB' | ||
2809 | 10 | self.fractions = 100 | ||
2810 | 11 | self.cur_singular = u' рубль' | ||
2811 | 12 | # default plural form for currency | ||
2812 | 13 | self.cur_plural = u' рублей' | ||
2813 | 14 | self.cur_plural_2to4 = u' рубля' | ||
2814 | 15 | self.frc_singular = u' копейка' | ||
2815 | 16 | # default plural form for fractions | ||
2816 | 17 | self.frc_plural = u' копеек' | ||
2817 | 18 | self.frc_plural_2to4 = u' копейки' | ||
2818 | 19 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
2819 | 20 | self.cur_gram_gender = 'm' | ||
2820 | 21 | self.frc_gram_gender = 'f' | ||
2821 | 22 | |||
2822 | 23 | rub() | ||
2823 | 0 | 24 | ||
2824 | === added file 'report_aeroo/ctt_languages/ru_RU/currencies/uah.py' | |||
2825 | --- report_aeroo/ctt_languages/ru_RU/currencies/uah.py 1970-01-01 00:00:00 +0000 | |||
2826 | +++ report_aeroo/ctt_languages/ru_RU/currencies/uah.py 2014-04-05 13:18:49 +0000 | |||
2827 | @@ -0,0 +1,23 @@ | |||
2828 | 1 | #!/usr/bin/python | ||
2829 | 2 | # -*- coding: utf8 -*- | ||
2830 | 3 | |||
2831 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2832 | 5 | |||
2833 | 6 | class uah(ctt_currency): | ||
2834 | 7 | def _init_currency(self): | ||
2835 | 8 | self.language = u'ru_RU' | ||
2836 | 9 | self.code = u'UAH' | ||
2837 | 10 | self.fractions = 100 | ||
2838 | 11 | self.cur_singular = u' гривна' | ||
2839 | 12 | # default plural form for currency | ||
2840 | 13 | self.cur_plural = u' гривен' | ||
2841 | 14 | self.cur_plural_2to4 = u' гривны' | ||
2842 | 15 | self.frc_singular = u' копeйка' | ||
2843 | 16 | # default plural form for fractions | ||
2844 | 17 | self.frc_plural = u' копeек' | ||
2845 | 18 | self.frc_plural_2to4 = u' копeйки' | ||
2846 | 19 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
2847 | 20 | self.cur_gram_gender = 'f' | ||
2848 | 21 | self.frc_gram_gender = 'f' | ||
2849 | 22 | |||
2850 | 23 | uah() | ||
2851 | 0 | 24 | ||
2852 | === added file 'report_aeroo/ctt_languages/ru_RU/currencies/usd.py' | |||
2853 | --- report_aeroo/ctt_languages/ru_RU/currencies/usd.py 1970-01-01 00:00:00 +0000 | |||
2854 | +++ report_aeroo/ctt_languages/ru_RU/currencies/usd.py 2014-04-05 13:18:49 +0000 | |||
2855 | @@ -0,0 +1,23 @@ | |||
2856 | 1 | #!/usr/bin/python | ||
2857 | 2 | # -*- coding: utf8 -*- | ||
2858 | 3 | |||
2859 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2860 | 5 | |||
2861 | 6 | class usd(ctt_currency): | ||
2862 | 7 | def _init_currency(self): | ||
2863 | 8 | self.language = u'ru_RU' | ||
2864 | 9 | self.code = u'USD' | ||
2865 | 10 | self.fractions = 100 | ||
2866 | 11 | self.cur_singular = u' доллара США' | ||
2867 | 12 | # default plural form for currency | ||
2868 | 13 | self.cur_plural = u' долларов США' | ||
2869 | 14 | self.cur_frc_plural_2to4 = u' доллара США' | ||
2870 | 15 | self.frc_singular = u' цент' | ||
2871 | 16 | # default plural form for fractions | ||
2872 | 17 | self.frc_plural = u' центов' | ||
2873 | 18 | self.frc_plural_2to4 = u' цента' | ||
2874 | 19 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
2875 | 20 | self.cur_gram_gender = 'm' | ||
2876 | 21 | self.frc_gram_gender = 'm' | ||
2877 | 22 | |||
2878 | 23 | usd() | ||
2879 | 0 | 24 | ||
2880 | === added directory 'report_aeroo/ctt_languages/tr_TR' | |||
2881 | === added file 'report_aeroo/ctt_languages/tr_TR/__init__.py' | |||
2882 | --- report_aeroo/ctt_languages/tr_TR/__init__.py 1970-01-01 00:00:00 +0000 | |||
2883 | +++ report_aeroo/ctt_languages/tr_TR/__init__.py 2014-04-05 13:18:49 +0000 | |||
2884 | @@ -0,0 +1,93 @@ | |||
2885 | 1 | #!/usr/bin/python | ||
2886 | 2 | # -*- coding: utf8 -*- | ||
2887 | 3 | # tr_TR | ||
2888 | 4 | ################################################################################ | ||
2889 | 5 | # | ||
2890 | 6 | # Turkish language support assembled from contributions provided by: | ||
2891 | 7 | # Ahmet Altınışık | ||
2892 | 8 | # | ||
2893 | 9 | ################################################################################ | ||
2894 | 10 | from report_aeroo.ctt_objects import ctt_language | ||
2895 | 11 | |||
2896 | 12 | class tr_TR(ctt_language): | ||
2897 | 13 | def _init_lang(self): | ||
2898 | 14 | self.name = 'tr_TR' | ||
2899 | 15 | # digits - masculine, singular | ||
2900 | 16 | self.number_sng_msc = [u'', u'bir', u'iki', u'üç', u'dört', u'beş', | ||
2901 | 17 | u'alti', u'yedi', u'sekiz', u'dokuz'] | ||
2902 | 18 | # tens - masculine, singular | ||
2903 | 19 | self.tens_sng_msc = [u'on', u'on bir', u'on iki', u'on üç', u'on dört', | ||
2904 | 20 | u'on beş', u'on alti', u'on yedi', u'on sekiz', | ||
2905 | 21 | u'on dokuz'] | ||
2906 | 22 | # teens - masculine | ||
2907 | 23 | self.teens = [u'on', u'on bir', u'on iki', u'on üç', u'on dört', | ||
2908 | 24 | u'on beş', u'on alti', u'on yedi', u'on sekiz', | ||
2909 | 25 | u'on dokuz'] | ||
2910 | 26 | # multiplier - masculine, singular | ||
2911 | 27 | self.multi_sng_msc = [u'yüz', u' bin', u' milyon', u' milyar'] | ||
2912 | 28 | |||
2913 | 29 | # next line is needed for correct loading of currencies | ||
2914 | 30 | import currencies | ||
2915 | 31 | return currencies | ||
2916 | 32 | |||
2917 | 33 | |||
2918 | 34 | def wordify(self, chunk, chunknr, gender): | ||
2919 | 35 | if gender == 'm': | ||
2920 | 36 | number = self.number_sng_msc | ||
2921 | 37 | elif gender == 'f': | ||
2922 | 38 | number = self.number_sng_fem | ||
2923 | 39 | elif gender == 'n': | ||
2924 | 40 | number = self.number_sng_neu | ||
2925 | 41 | words = u'' | ||
2926 | 42 | digit1 = u'' | ||
2927 | 43 | digit2 = u'' | ||
2928 | 44 | digit3 = u'' | ||
2929 | 45 | chunklength = len(chunk) | ||
2930 | 46 | # placing digits in right places | ||
2931 | 47 | if chunklength == 1: | ||
2932 | 48 | digit3 = chunk[0 : 1] | ||
2933 | 49 | if chunklength == 2: | ||
2934 | 50 | digit2 = chunk[0 : 1] | ||
2935 | 51 | digit3 = chunk[1 : 2] | ||
2936 | 52 | if chunklength == 3: | ||
2937 | 53 | digit1 = chunk[0 : 1] | ||
2938 | 54 | digit2 = chunk[1 : 2] | ||
2939 | 55 | digit3 = chunk[-1] | ||
2940 | 56 | # processing zero | ||
2941 | 57 | if chunklength == 1 and digit3 == '0' : | ||
2942 | 58 | return number[0] | ||
2943 | 59 | # processing hundreds | ||
2944 | 60 | if chunklength == 3 : | ||
2945 | 61 | if digit1 == '1' : | ||
2946 | 62 | words += self.multi_sng_msc[0] | ||
2947 | 63 | else : | ||
2948 | 64 | if int(digit1) > 1 : words += number[int(digit1)] + \ | ||
2949 | 65 | self.multi_plr_msc[0] | ||
2950 | 66 | # processing tens | ||
2951 | 67 | if chunklength > 1: | ||
2952 | 68 | spacer = '' | ||
2953 | 69 | if len(words) > 0 : spacer = ' ' | ||
2954 | 70 | if digit2 == '1': | ||
2955 | 71 | words += spacer + self.teens[int(digit3)] | ||
2956 | 72 | else: | ||
2957 | 73 | if int(digit2) > 1 and int(digit2) > 0: | ||
2958 | 74 | words += spacer + self.tens_sng_msc[int(digit2)] | ||
2959 | 75 | |||
2960 | 76 | # processing ones | ||
2961 | 77 | if chunklength > 0 and digit2 != '1' : | ||
2962 | 78 | spacer = '' | ||
2963 | 79 | if len(words) > 0: spacer = u' ' | ||
2964 | 80 | if int(digit3) > 0: | ||
2965 | 81 | words += spacer + number[int(digit3)] | ||
2966 | 82 | # end processing | ||
2967 | 83 | if len(words) > 0 : | ||
2968 | 84 | if digit3 == '1' and chunknr > 0: | ||
2969 | 85 | return words + self.multi_sng_msc[chunknr] | ||
2970 | 86 | elif digit3 != '1' and chunknr > 0: | ||
2971 | 87 | return words + self.multi_plr_msc[chunknr] | ||
2972 | 88 | else: | ||
2973 | 89 | return words | ||
2974 | 90 | else: | ||
2975 | 91 | return '' | ||
2976 | 92 | |||
2977 | 93 | tr_TR() | ||
2978 | 0 | 94 | ||
2979 | === added directory 'report_aeroo/ctt_languages/tr_TR/currencies' | |||
2980 | === added file 'report_aeroo/ctt_languages/tr_TR/currencies/__init__.py' | |||
2981 | --- report_aeroo/ctt_languages/tr_TR/currencies/__init__.py 1970-01-01 00:00:00 +0000 | |||
2982 | +++ report_aeroo/ctt_languages/tr_TR/currencies/__init__.py 2014-04-05 13:18:49 +0000 | |||
2983 | @@ -0,0 +1,3 @@ | |||
2984 | 1 | #!/usr/bin/python | ||
2985 | 2 | # -*- coding: utf8 -*- | ||
2986 | 3 | # Please do not edit this file! | ||
2987 | 0 | 4 | ||
2988 | === added file 'report_aeroo/ctt_languages/tr_TR/currencies/eur.py' | |||
2989 | --- report_aeroo/ctt_languages/tr_TR/currencies/eur.py 1970-01-01 00:00:00 +0000 | |||
2990 | +++ report_aeroo/ctt_languages/tr_TR/currencies/eur.py 2014-04-05 13:18:49 +0000 | |||
2991 | @@ -0,0 +1,21 @@ | |||
2992 | 1 | #!/usr/bin/python | ||
2993 | 2 | # -*- coding: utf8 -*- | ||
2994 | 3 | |||
2995 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
2996 | 5 | |||
2997 | 6 | class eur(ctt_currency): | ||
2998 | 7 | def _init_currency(self): | ||
2999 | 8 | self.language = u'tr_TR' | ||
3000 | 9 | self.code = u'EUR' | ||
3001 | 10 | self.fractions = 100 | ||
3002 | 11 | self.cur_singular = u' Euro' | ||
3003 | 12 | # default plural form for currency | ||
3004 | 13 | self.cur_plural = u' Euro' | ||
3005 | 14 | self.frc_singular = u' sent' | ||
3006 | 15 | # default plural form for fractions | ||
3007 | 16 | self.frc_plural = u' sent' | ||
3008 | 17 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
3009 | 18 | self.cur_gram_gender = 'm' | ||
3010 | 19 | self.frc_gram_gender = 'm' | ||
3011 | 20 | |||
3012 | 21 | eur() | ||
3013 | 0 | 22 | ||
3014 | === added file 'report_aeroo/ctt_languages/tr_TR/currencies/lvl.py' | |||
3015 | --- report_aeroo/ctt_languages/tr_TR/currencies/lvl.py 1970-01-01 00:00:00 +0000 | |||
3016 | +++ report_aeroo/ctt_languages/tr_TR/currencies/lvl.py 2014-04-05 13:18:49 +0000 | |||
3017 | @@ -0,0 +1,21 @@ | |||
3018 | 1 | #!/usr/bin/python | ||
3019 | 2 | # -*- coding: utf8 -*- | ||
3020 | 3 | |||
3021 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
3022 | 5 | |||
3023 | 6 | class lvl(ctt_currency): | ||
3024 | 7 | def _init_currency(self): | ||
3025 | 8 | self.language = u'tr_TR' | ||
3026 | 9 | self.code = u'LVL' | ||
3027 | 10 | self.fractions = 100 | ||
3028 | 11 | self.cur_singular = u' Litvanya Liatası' | ||
3029 | 12 | # default plural form for currency | ||
3030 | 13 | self.cur_plural = u' Litvanya Liatası' | ||
3031 | 14 | self.frc_singular = u' santim' | ||
3032 | 15 | # default plural form for fractions | ||
3033 | 16 | self.frc_plural = u' santims' | ||
3034 | 17 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
3035 | 18 | self.cur_gram_gender = 'm' | ||
3036 | 19 | self.frc_gram_gender = 'm' | ||
3037 | 20 | |||
3038 | 21 | lvl() | ||
3039 | 0 | 22 | ||
3040 | === added file 'report_aeroo/ctt_languages/tr_TR/currencies/trl.py' | |||
3041 | --- report_aeroo/ctt_languages/tr_TR/currencies/trl.py 1970-01-01 00:00:00 +0000 | |||
3042 | +++ report_aeroo/ctt_languages/tr_TR/currencies/trl.py 2014-04-05 13:18:49 +0000 | |||
3043 | @@ -0,0 +1,21 @@ | |||
3044 | 1 | #!/usr/bin/python | ||
3045 | 2 | # -*- coding: utf8 -*- | ||
3046 | 3 | |||
3047 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
3048 | 5 | |||
3049 | 6 | class trl(ctt_currency): | ||
3050 | 7 | def _init_currency(self): | ||
3051 | 8 | self.language = u'tr_TR' | ||
3052 | 9 | self.code = u'TRL' | ||
3053 | 10 | self.fractions = 100 | ||
3054 | 11 | self.cur_singular = u' Lira' | ||
3055 | 12 | # default plural form for currency | ||
3056 | 13 | self.cur_plural = u' Lira' | ||
3057 | 14 | self.frc_singular = u' kuruş' | ||
3058 | 15 | # default plural form for fractions | ||
3059 | 16 | self.frc_plural = u' kuruş' | ||
3060 | 17 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
3061 | 18 | self.cur_gram_gender = 'm' | ||
3062 | 19 | self.frc_gram_gender = 'm' | ||
3063 | 20 | |||
3064 | 21 | trl() | ||
3065 | 0 | 22 | ||
3066 | === added file 'report_aeroo/ctt_languages/tr_TR/currencies/usd.py' | |||
3067 | --- report_aeroo/ctt_languages/tr_TR/currencies/usd.py 1970-01-01 00:00:00 +0000 | |||
3068 | +++ report_aeroo/ctt_languages/tr_TR/currencies/usd.py 2014-04-05 13:18:49 +0000 | |||
3069 | @@ -0,0 +1,21 @@ | |||
3070 | 1 | #!/usr/bin/python | ||
3071 | 2 | # -*- coding: utf8 -*- | ||
3072 | 3 | |||
3073 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
3074 | 5 | |||
3075 | 6 | class usd(ctt_currency): | ||
3076 | 7 | def _init_currency(self): | ||
3077 | 8 | self.language = u'tr_TR' | ||
3078 | 9 | self.code = u'USD' | ||
3079 | 10 | self.fractions = 100 | ||
3080 | 11 | self.cur_singular = u' USD' | ||
3081 | 12 | # default plural form for currency | ||
3082 | 13 | self.cur_plural = u' USD' | ||
3083 | 14 | self.frc_singular = u' sent' | ||
3084 | 15 | # default plural form for fractions | ||
3085 | 16 | self.frc_plural = u' sent' | ||
3086 | 17 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
3087 | 18 | self.cur_gram_gender = 'm' | ||
3088 | 19 | self.frc_gram_gender = 'm' | ||
3089 | 20 | |||
3090 | 21 | usd() | ||
3091 | 0 | 22 | ||
3092 | === added directory 'report_aeroo/ctt_languages/uk_UA' | |||
3093 | === added file 'report_aeroo/ctt_languages/uk_UA/__init__.py' | |||
3094 | --- report_aeroo/ctt_languages/uk_UA/__init__.py 1970-01-01 00:00:00 +0000 | |||
3095 | +++ report_aeroo/ctt_languages/uk_UA/__init__.py 2014-04-05 13:18:49 +0000 | |||
3096 | @@ -0,0 +1,112 @@ | |||
3097 | 1 | #!/usr/bin/python | ||
3098 | 2 | # -*- coding: utf8 -*- | ||
3099 | 3 | # uk_UA | ||
3100 | 4 | |||
3101 | 5 | from report_aeroo.ctt_objects import ctt_language | ||
3102 | 6 | |||
3103 | 7 | class uk_UA(ctt_language): | ||
3104 | 8 | def _init_lang(self): | ||
3105 | 9 | # language name | ||
3106 | 10 | self.name = 'uk_UA' | ||
3107 | 11 | # digits - masculine, singular | ||
3108 | 12 | self.number_sng_msc = [u'ноль', u'один', u'два', u'три', u'чотири', | ||
3109 | 13 | u'п\'ять', u'шість', u'сім', u'вісім', | ||
3110 | 14 | u'дев\'ять'] | ||
3111 | 15 | # tens - masculine, singular | ||
3112 | 16 | self.number_sng_fem = [u'ноль', u'одна', u'дві', u'три', u'чотири', | ||
3113 | 17 | u'п\'ять', u'шість', u'сім', u'вісім', | ||
3114 | 18 | u'дев\'ять'] | ||
3115 | 19 | # tens - masculine, plural | ||
3116 | 20 | self.number_plr_msc = [u'', u'один', u'двa', u'три', u'четыре', u'пять', | ||
3117 | 21 | u'шесть', u'семь', u'восемь', u'девять'] | ||
3118 | 22 | # teens - masculine | ||
3119 | 23 | self.number_teens = [u'десять', u'одинадцять', u'дванадцять', | ||
3120 | 24 | u'тринадцять', u'чотирнадцять', u'п\'ятнадцять', | ||
3121 | 25 | u'шістнадцять', u'сімнадцять', u'вісімнадцять', | ||
3122 | 26 | u'дев\'ятнадцять'] | ||
3123 | 27 | # multiplier - masculine, singular | ||
3124 | 28 | self.multi_sng_msc = [u'стo', u' тисяча', u' мiллiон', u' мiллiард'] | ||
3125 | 29 | # multiplier - masculine, plural | ||
3126 | 30 | self.multi_plr_msc = [u'сoт', u' тисяч', u' мiллiонiв', u' мiллiардов'] | ||
3127 | 31 | |||
3128 | 32 | # next line is needed for correct loading of currencies | ||
3129 | 33 | import currencies | ||
3130 | 34 | return currencies | ||
3131 | 35 | |||
3132 | 36 | |||
3133 | 37 | def wordify(self, chunk, chunknr, gender): | ||
3134 | 38 | if gender == 'm': | ||
3135 | 39 | number = self.number_sng_msc | ||
3136 | 40 | elif gender == 'f': | ||
3137 | 41 | number = self.number_sng_fem | ||
3138 | 42 | elif gender == 'n': | ||
3139 | 43 | number = self.number_sng_neu | ||
3140 | 44 | words = u'' | ||
3141 | 45 | digit1 = u'' | ||
3142 | 46 | digit2 = u'' | ||
3143 | 47 | digit3 = u'' | ||
3144 | 48 | chunklength = len(chunk) | ||
3145 | 49 | # placing digits in right places | ||
3146 | 50 | if chunklength == 1: | ||
3147 | 51 | digit3 = chunk[0 : 1] | ||
3148 | 52 | if chunklength == 2: | ||
3149 | 53 | digit2 = chunk[0 : 1] | ||
3150 | 54 | digit3 = chunk[1 : 2] | ||
3151 | 55 | if chunklength == 3: | ||
3152 | 56 | digit1 = chunk[0 : 1] | ||
3153 | 57 | digit2 = chunk[1 : 2] | ||
3154 | 58 | digit3 = chunk[-1] | ||
3155 | 59 | # processing zero | ||
3156 | 60 | if chunklength == 1 and digit3 == '0' : | ||
3157 | 61 | return number[0] | ||
3158 | 62 | # processing hundreds | ||
3159 | 63 | if chunklength == 3 : | ||
3160 | 64 | if int(digit1) == 1 : | ||
3161 | 65 | words += self.multi_sng_msc[0] | ||
3162 | 66 | elif int(digit1) == 2 : | ||
3163 | 67 | words += u'двісті' | ||
3164 | 68 | elif int(digit1) == 3 : | ||
3165 | 69 | words += u'триста' | ||
3166 | 70 | elif int(digit1) == 4 : | ||
3167 | 71 | words += u'чотириста' | ||
3168 | 72 | elif int(digit1) >= 5 : | ||
3169 | 73 | words += self.number_sng_msc[int(digit1)] + self.multi_plr_msc[0] | ||
3170 | 74 | # processing tens | ||
3171 | 75 | if chunklength > 1: | ||
3172 | 76 | spacer = '' | ||
3173 | 77 | if len(words) > 0 : spacer = ' ' | ||
3174 | 78 | if digit2 == '1': | ||
3175 | 79 | words += spacer + self.number_teens[int(digit3)] | ||
3176 | 80 | else: | ||
3177 | 81 | if int(digit2) > 1 and int(digit2) < 4: | ||
3178 | 82 | words += spacer + skaitlix[int(digit2)] + u'дцять' | ||
3179 | 83 | elif digit2 == '4': | ||
3180 | 84 | words += spacer + u'сорок' | ||
3181 | 85 | elif int(digit2) >= 5 and int(digit2) != 9: | ||
3182 | 86 | words += spacer + skaitlix[int(digit2)] + u'десят' | ||
3183 | 87 | elif digit2 == '9': | ||
3184 | 88 | words += spacer + u'дев\'яносто' | ||
3185 | 89 | |||
3186 | 90 | # processing ones | ||
3187 | 91 | if chunklength > 0 and digit2 != '1' : | ||
3188 | 92 | spacer = '' | ||
3189 | 93 | if len(words) > 0: spacer = u' ' | ||
3190 | 94 | if chunknr == 1: | ||
3191 | 95 | if int(digit3) == 1 or int(digit3) == 2: | ||
3192 | 96 | words += spacer + self.number_sng_fem[int(digit3)] | ||
3193 | 97 | elif int(digit3) >= 3 and int(digit3) != 0: | ||
3194 | 98 | words += spacer + self.number_sng_msc[int(digit3)] | ||
3195 | 99 | else: | ||
3196 | 100 | if int(digit3) > 0: words += spacer + self.number_sng_msc[int(digit3)] | ||
3197 | 101 | # end processing | ||
3198 | 102 | if len(words) > 0 : | ||
3199 | 103 | if digit3 == '1' and chunknr > 0: | ||
3200 | 104 | return words + self.multi_sng_msc[chunknr] | ||
3201 | 105 | elif digit3 != '1' and chunknr > 0: | ||
3202 | 106 | return words + self.multi_plr_msc[chunknr] | ||
3203 | 107 | else: | ||
3204 | 108 | return words | ||
3205 | 109 | else: | ||
3206 | 110 | return '' | ||
3207 | 111 | |||
3208 | 112 | uk_UA() | ||
3209 | 0 | 113 | ||
3210 | === added directory 'report_aeroo/ctt_languages/uk_UA/currencies' | |||
3211 | === added file 'report_aeroo/ctt_languages/uk_UA/currencies/__init__.py' | |||
3212 | --- report_aeroo/ctt_languages/uk_UA/currencies/__init__.py 1970-01-01 00:00:00 +0000 | |||
3213 | +++ report_aeroo/ctt_languages/uk_UA/currencies/__init__.py 2014-04-05 13:18:49 +0000 | |||
3214 | @@ -0,0 +1,3 @@ | |||
3215 | 1 | #!/usr/bin/python | ||
3216 | 2 | # -*- coding: utf8 -*- | ||
3217 | 3 | # Please do not edit this file! | ||
3218 | 0 | 4 | ||
3219 | === added file 'report_aeroo/ctt_languages/uk_UA/currencies/eur.py' | |||
3220 | --- report_aeroo/ctt_languages/uk_UA/currencies/eur.py 1970-01-01 00:00:00 +0000 | |||
3221 | +++ report_aeroo/ctt_languages/uk_UA/currencies/eur.py 2014-04-05 13:18:49 +0000 | |||
3222 | @@ -0,0 +1,21 @@ | |||
3223 | 1 | #!/usr/bin/python | ||
3224 | 2 | # -*- coding: utf8 -*- | ||
3225 | 3 | |||
3226 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
3227 | 5 | |||
3228 | 6 | class eur(ctt_currency): | ||
3229 | 7 | def _init_currency(self): | ||
3230 | 8 | self.language = u'uk_UA' | ||
3231 | 9 | self.code = u'EUR' | ||
3232 | 10 | self.fractions = 100 | ||
3233 | 11 | self.cur_singular = u' евро' | ||
3234 | 12 | self.cur_plural = u' евро' | ||
3235 | 13 | self.frc_singular = u' цент' | ||
3236 | 14 | # default plural form for fractions | ||
3237 | 15 | self.frc_plural = u' центов' | ||
3238 | 16 | self.frc_plural_2to4 = u' цента' | ||
3239 | 17 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
3240 | 18 | self.cur_gram_gender = 'm' | ||
3241 | 19 | self.frc_gram_gender = 'm' | ||
3242 | 20 | |||
3243 | 21 | eur() | ||
3244 | 0 | 22 | ||
3245 | === added file 'report_aeroo/ctt_languages/uk_UA/currencies/ltl.py' | |||
3246 | --- report_aeroo/ctt_languages/uk_UA/currencies/ltl.py 1970-01-01 00:00:00 +0000 | |||
3247 | +++ report_aeroo/ctt_languages/uk_UA/currencies/ltl.py 2014-04-05 13:18:49 +0000 | |||
3248 | @@ -0,0 +1,23 @@ | |||
3249 | 1 | #!/usr/bin/python | ||
3250 | 2 | # -*- coding: utf8 -*- | ||
3251 | 3 | |||
3252 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
3253 | 5 | |||
3254 | 6 | class ltl(ctt_currency): | ||
3255 | 7 | def _init_currency(self): | ||
3256 | 8 | self.language = u'uk_UA' | ||
3257 | 9 | self.code = u'LTL' | ||
3258 | 10 | self.fractions = 100 | ||
3259 | 11 | self.cur_singular = u' лит' | ||
3260 | 12 | # default plural form for currency | ||
3261 | 13 | self.cur_plural = u' литов' | ||
3262 | 14 | self.cur_plural_2to4 = u' лита' | ||
3263 | 15 | self.frc_singular = u' цент' | ||
3264 | 16 | # default plural form for fractions | ||
3265 | 17 | self.frc_plural = u' центов' | ||
3266 | 18 | self.frc_plural_2to4 = u' цента' | ||
3267 | 19 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
3268 | 20 | self.cur_gram_gender = 'm' | ||
3269 | 21 | self.frc_gram_gender = 'm' | ||
3270 | 22 | |||
3271 | 23 | ltl() | ||
3272 | 0 | 24 | ||
3273 | === added file 'report_aeroo/ctt_languages/uk_UA/currencies/lvl.py' | |||
3274 | --- report_aeroo/ctt_languages/uk_UA/currencies/lvl.py 1970-01-01 00:00:00 +0000 | |||
3275 | +++ report_aeroo/ctt_languages/uk_UA/currencies/lvl.py 2014-04-05 13:18:49 +0000 | |||
3276 | @@ -0,0 +1,23 @@ | |||
3277 | 1 | #!/usr/bin/python | ||
3278 | 2 | # -*- coding: utf8 -*- | ||
3279 | 3 | |||
3280 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
3281 | 5 | |||
3282 | 6 | class lvl(ctt_currency): | ||
3283 | 7 | def _init_currency(self): | ||
3284 | 8 | self.language = u'uk_UA' | ||
3285 | 9 | self.code = u'LVL' | ||
3286 | 10 | self.fractions = 100 | ||
3287 | 11 | self.cur_singular = u' лат' | ||
3288 | 12 | # default plural form for currency | ||
3289 | 13 | self.cur_plural = u' латов' | ||
3290 | 14 | self.cur_plural_2to3 = u' лата' | ||
3291 | 15 | self.frc_singular = u' сантим' | ||
3292 | 16 | # default plural form for fractions | ||
3293 | 17 | self.frc_plural = u' сантимов' | ||
3294 | 18 | self.frc_plural_2to3 = u' сантима' | ||
3295 | 19 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
3296 | 20 | self.cur_gram_gender = 'm' | ||
3297 | 21 | self.frc_gram_gender = 'm' | ||
3298 | 22 | |||
3299 | 23 | lvl() | ||
3300 | 0 | 24 | ||
3301 | === added file 'report_aeroo/ctt_languages/uk_UA/currencies/rub.py' | |||
3302 | --- report_aeroo/ctt_languages/uk_UA/currencies/rub.py 1970-01-01 00:00:00 +0000 | |||
3303 | +++ report_aeroo/ctt_languages/uk_UA/currencies/rub.py 2014-04-05 13:18:49 +0000 | |||
3304 | @@ -0,0 +1,23 @@ | |||
3305 | 1 | #!/usr/bin/python | ||
3306 | 2 | # -*- coding: utf8 -*- | ||
3307 | 3 | |||
3308 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
3309 | 5 | |||
3310 | 6 | class rub(ctt_currency): | ||
3311 | 7 | def _init_currency(self): | ||
3312 | 8 | self.language = u'uk_UA' | ||
3313 | 9 | self.code = u'RUB' | ||
3314 | 10 | self.fractions = 100 | ||
3315 | 11 | self.cur_singular = u' рубль' | ||
3316 | 12 | # default plural form for currency | ||
3317 | 13 | self.cur_plural = u' рублiв' | ||
3318 | 14 | self.cur_plural_2to4 = u' рубля' | ||
3319 | 15 | self.frc_singular = u' копійка' | ||
3320 | 16 | # default plural form for fractions | ||
3321 | 17 | self.frc_plural = u' копійок' | ||
3322 | 18 | self.frc_plural_2to4 = u' копійки' | ||
3323 | 19 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
3324 | 20 | self.cur_gram_gender = 'm' | ||
3325 | 21 | self.frc_gram_gender = 'f' | ||
3326 | 22 | |||
3327 | 23 | rub() | ||
3328 | 0 | 24 | ||
3329 | === added file 'report_aeroo/ctt_languages/uk_UA/currencies/uah.py' | |||
3330 | --- report_aeroo/ctt_languages/uk_UA/currencies/uah.py 1970-01-01 00:00:00 +0000 | |||
3331 | +++ report_aeroo/ctt_languages/uk_UA/currencies/uah.py 2014-04-05 13:18:49 +0000 | |||
3332 | @@ -0,0 +1,23 @@ | |||
3333 | 1 | #!/usr/bin/python | ||
3334 | 2 | # -*- coding: utf8 -*- | ||
3335 | 3 | |||
3336 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
3337 | 5 | |||
3338 | 6 | class uah(ctt_currency): | ||
3339 | 7 | def _init_currency(self): | ||
3340 | 8 | self.language = u'uk_UA' | ||
3341 | 9 | self.code = u'UAH' | ||
3342 | 10 | self.fractions = 100 | ||
3343 | 11 | self.cur_singular = u' гривня' | ||
3344 | 12 | # default plural form for currency | ||
3345 | 13 | self.cur_plural = u' гривень' | ||
3346 | 14 | self.cur_plural_2to4 = u' гривні' | ||
3347 | 15 | self.frc_singular = u' копійка' | ||
3348 | 16 | # default plural form for fractions | ||
3349 | 17 | self.frc_plural = u' копійок' | ||
3350 | 18 | self.frc_plural_2to4 = u' копійки' | ||
3351 | 19 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
3352 | 20 | self.cur_gram_gender = 'f' | ||
3353 | 21 | self.frc_gram_gender = 'f' | ||
3354 | 22 | |||
3355 | 23 | uah() | ||
3356 | 0 | 24 | ||
3357 | === added file 'report_aeroo/ctt_languages/uk_UA/currencies/usd.py' | |||
3358 | --- report_aeroo/ctt_languages/uk_UA/currencies/usd.py 1970-01-01 00:00:00 +0000 | |||
3359 | +++ report_aeroo/ctt_languages/uk_UA/currencies/usd.py 2014-04-05 13:18:49 +0000 | |||
3360 | @@ -0,0 +1,23 @@ | |||
3361 | 1 | #!/usr/bin/python | ||
3362 | 2 | # -*- coding: utf8 -*- | ||
3363 | 3 | |||
3364 | 4 | from report_aeroo.ctt_objects import ctt_currency | ||
3365 | 5 | |||
3366 | 6 | class usd(ctt_currency): | ||
3367 | 7 | def _init_currency(self): | ||
3368 | 8 | self.language = u'uk_UA' | ||
3369 | 9 | self.code = u'USD' | ||
3370 | 10 | self.fractions = 100 | ||
3371 | 11 | self.cur_singular = u' доллара США' | ||
3372 | 12 | # default plural form for currency | ||
3373 | 13 | self.cur_plural = u' долларов США' | ||
3374 | 14 | self.cur_plural_2to4 = u' доллара США' | ||
3375 | 15 | self.frc_singular = u' цент' | ||
3376 | 16 | # default plural form for fractions | ||
3377 | 17 | self.frc_plural = u' центов' | ||
3378 | 18 | self.frc_plural_2to4 = u' цента' | ||
3379 | 19 | # grammatical genders: f - feminine, m - masculine, n -neuter | ||
3380 | 20 | self.cur_gram_gender = 'm' | ||
3381 | 21 | self.frc_gram_gender = 'm' | ||
3382 | 22 | |||
3383 | 23 | usd() | ||
3384 | 0 | 24 | ||
3385 | === added file 'report_aeroo/ctt_objects.py' | |||
3386 | --- report_aeroo/ctt_objects.py 1970-01-01 00:00:00 +0000 | |||
3387 | +++ report_aeroo/ctt_objects.py 2014-04-05 13:18:49 +0000 | |||
3388 | @@ -0,0 +1,161 @@ | |||
3389 | 1 | #!/usr/bin/python | ||
3390 | 2 | # -*- coding: utf8 -*- | ||
3391 | 3 | ################################################################################ | ||
3392 | 4 | # Developed by Kaspars Vilkens - Alistek Ltd (c) 2011 | ||
3393 | 5 | # | ||
3394 | 6 | # Supported sum: 0 ... 999999999999.99 | ||
3395 | 7 | # Supported languages: for more reference see languages forlder | ||
3396 | 8 | # Supported currencies: see particular language for reference | ||
3397 | 9 | ################################################################################ | ||
3398 | 10 | |||
3399 | 11 | import os | ||
3400 | 12 | supported_language = {} | ||
3401 | 13 | |||
3402 | 14 | if __name__ == '__main__': | ||
3403 | 15 | from sys import exit | ||
3404 | 16 | error = '''This code is part of Report Aeroo package! | ||
3405 | 17 | Not to be used separately...''' | ||
3406 | 18 | exit(error) | ||
3407 | 19 | |||
3408 | 20 | def currency_to_text(sum, currency_code, language_code): | ||
3409 | 21 | if language_code not in supported_language: | ||
3410 | 22 | raise Exception('Not supported or no language: %s' % language_code) | ||
3411 | 23 | else: | ||
3412 | 24 | suppl = supported_language[language_code] | ||
3413 | 25 | return suppl.currency_to_text(sum, currency_code) | ||
3414 | 26 | |||
3415 | 27 | class ctt_language(object): | ||
3416 | 28 | def _init_lang(self): | ||
3417 | 29 | pass | ||
3418 | 30 | |||
3419 | 31 | def __repr__(self): | ||
3420 | 32 | return self.name | ||
3421 | 33 | |||
3422 | 34 | def __init__(self): | ||
3423 | 35 | self.supported_currency = {} | ||
3424 | 36 | self.minbound = 0 | ||
3425 | 37 | self.maxbound = 999999999999.99 | ||
3426 | 38 | currencies = self._init_lang() | ||
3427 | 39 | supported_language.update({self.name : self}) | ||
3428 | 40 | import_submodules('currency', currencies, 0) | ||
3429 | 41 | |||
3430 | 42 | def check_sum(self): | ||
3431 | 43 | if sum < self.minbound or sum > self.maxbound : | ||
3432 | 44 | raise Exception(\ | ||
3433 | 45 | """Sum out of bounds: must be from %s to %s""" % \ | ||
3434 | 46 | (str(self.minbound), str(self.maxbound))) | ||
3435 | 47 | |||
3436 | 48 | def check_currency(self): | ||
3437 | 49 | if currency not in supported_currency: | ||
3438 | 50 | raise Exception(\ | ||
3439 | 51 | """Unsupported or no currency: must be one of (%s)""" % \ | ||
3440 | 52 | ', '.join(self.supported_currency)) | ||
3441 | 53 | |||
3442 | 54 | def dtowords(self, sum_integers, gender): | ||
3443 | 55 | diginwords = u'' | ||
3444 | 56 | if sum_integers == 0: | ||
3445 | 57 | return self.wordify('0', 0, gender) | ||
3446 | 58 | elif sum_integers > 0: | ||
3447 | 59 | lengthx = len(str(sum_integers)) | ||
3448 | 60 | nrchunks = (lengthx / 3) | ||
3449 | 61 | if nrchunks < (float(lengthx) / 3) : | ||
3450 | 62 | nrchunks+=1 | ||
3451 | 63 | inc = 1 | ||
3452 | 64 | while inc <= nrchunks: | ||
3453 | 65 | startpos = (lengthx - inc * 3) | ||
3454 | 66 | chunklength = 3 | ||
3455 | 67 | if startpos < 0: | ||
3456 | 68 | chunklength += startpos | ||
3457 | 69 | startpos = 0 | ||
3458 | 70 | chunk = str(sum_integers)[startpos : startpos + chunklength] | ||
3459 | 71 | #print str(startpos)+' '+str(chunklength)+' '+ chunk | ||
3460 | 72 | if inc == 1: | ||
3461 | 73 | wordified = self.wordify(chunk, inc-1, gender) | ||
3462 | 74 | else: | ||
3463 | 75 | wordified = self.wordify(chunk, inc-1, 'm') | ||
3464 | 76 | inc += 1 | ||
3465 | 77 | spacer = '' | ||
3466 | 78 | if len(diginwords) > 0 and wordified: | ||
3467 | 79 | spacer = ' ' | ||
3468 | 80 | diginwords = wordified + spacer + diginwords | ||
3469 | 81 | return diginwords | ||
3470 | 82 | |||
3471 | 83 | |||
3472 | 84 | def currency_to_text(self, sum, currency): | ||
3473 | 85 | #--------------for currencies with 100 fractions | ||
3474 | 86 | sum = float(sum) | ||
3475 | 87 | sum = round(sum, 2) | ||
3476 | 88 | # find out digits before floating point - currency | ||
3477 | 89 | sum_cur = int(sum) | ||
3478 | 90 | # find out digits after floating point - fractions | ||
3479 | 91 | sum_frc = int(round((sum - sum_cur) * 100,0)) | ||
3480 | 92 | curr = self.supported_currency.get(currency) | ||
3481 | 93 | cur_in_words = self.dtowords(sum_cur, curr.cur_gram_gender) | ||
3482 | 94 | frc_in_words = self.dtowords(sum_frc, curr.frc_gram_gender) | ||
3483 | 95 | #------------------------------------ | ||
3484 | 96 | |||
3485 | 97 | return (cur_in_words + curr.cur_to_text(sum_cur) + ' ' + frc_in_words +\ | ||
3486 | 98 | curr.frc_to_text(sum_frc)).strip().encode('utf-8') | ||
3487 | 99 | |||
3488 | 100 | |||
3489 | 101 | class ctt_currency(object): | ||
3490 | 102 | def _init_currency(self): | ||
3491 | 103 | pass | ||
3492 | 104 | |||
3493 | 105 | def __repr__(self): | ||
3494 | 106 | return self.code | ||
3495 | 107 | |||
3496 | 108 | def __init__(self): | ||
3497 | 109 | self._init_currency() | ||
3498 | 110 | suppl = supported_language.get(self.language) | ||
3499 | 111 | suppl.supported_currency.update({self.code : self}) | ||
3500 | 112 | |||
3501 | 113 | def cur_to_text(self, sum_cur): | ||
3502 | 114 | # is the currency sum one | ||
3503 | 115 | if sum_cur == 1 or (str(sum_cur)[-1] == '1' and str(sum_cur)[-2] !='1'): | ||
3504 | 116 | return self.cur_singular | ||
3505 | 117 | # 2,3 and 4 yields different plural form, if defined | ||
3506 | 118 | elif ((sum_cur in [2, 3, 4]) or (str(sum_cur)[-1] in ['2', '3', '4'] \ | ||
3507 | 119 | and str(sum_cur)[-2] != '1')) and hasattr(self, 'cur_plural_2to4'): | ||
3508 | 120 | return self.cur_plural_2to4 | ||
3509 | 121 | # betwean 1 and 10 yields different plural form, if defined | ||
3510 | 122 | elif (sum_cur > 1 and sum_cur < 10 or (int(str(sum_cur)[-1]) > 1 \ | ||
3511 | 123 | and str(sum_cur)[-2] != '1')) and hasattr(self, 'cur_plural_2to10'): | ||
3512 | 124 | return self.cur_plural_2to10 | ||
3513 | 125 | # starting from 10 yields uses default plural form | ||
3514 | 126 | else: | ||
3515 | 127 | return self.cur_plural | ||
3516 | 128 | |||
3517 | 129 | def frc_to_text(self, sum_frc): | ||
3518 | 130 | # is the fraction sum one | ||
3519 | 131 | if sum_frc == 1 or (str(sum_frc)[-1] == '1' and str(sum_frc)[-2] !='1'): | ||
3520 | 132 | return self.frc_singular | ||
3521 | 133 | # 2,3 and 4 yields different plural form, if defined | ||
3522 | 134 | elif ((sum_frc in [2, 3, 4]) or (str(sum_frc)[-1] in ['2', '3', '4'] \ | ||
3523 | 135 | and str(sum_frc)[-2] != '1')) and hasattr(self, 'frc_plural_2to4'): | ||
3524 | 136 | return self.frc_plural_2to4 | ||
3525 | 137 | # betwean 1 and 10 yields different plural form, if defined | ||
3526 | 138 | elif (sum_frc > 1 and sum_frc < 10 or (int(str(sum_frc)[-1]) > 1 \ | ||
3527 | 139 | and str(sum_frc)[-2] != '1')) and hasattr(self, 'frc_plural_2to10'): | ||
3528 | 140 | return self.frc_plural_2to10 | ||
3529 | 141 | # starting from 10 yields uses default plural form | ||
3530 | 142 | else: | ||
3531 | 143 | return self.frc_plural | ||
3532 | 144 | |||
3533 | 145 | def __filter_names(to_import, package): | ||
3534 | 146 | folder = os.path.split(package.__file__)[0] | ||
3535 | 147 | for name in os.listdir(folder): | ||
3536 | 148 | if to_import == 'currency': | ||
3537 | 149 | if name.endswith(".py") and not name.startswith("__"): | ||
3538 | 150 | yield name[:-3] | ||
3539 | 151 | if to_import == 'language': | ||
3540 | 152 | if len(name) == 5 and not name.startswith("__"): | ||
3541 | 153 | yield name | ||
3542 | 154 | |||
3543 | 155 | def import_submodules(to_import, package, level=-1): | ||
3544 | 156 | names = list(__filter_names(to_import, package)) | ||
3545 | 157 | m = __import__(package.__name__, globals(), locals(), names, level) | ||
3546 | 158 | return dict((name, getattr(m, name)) for name in names) | ||
3547 | 159 | |||
3548 | 160 | import ctt_languages | ||
3549 | 161 | import_submodules('language', ctt_languages, 0) | ||
3550 | 0 | 162 | ||
3551 | === added file 'report_aeroo/currency_to_text.py' | |||
3552 | --- report_aeroo/currency_to_text.py 1970-01-01 00:00:00 +0000 | |||
3553 | +++ report_aeroo/currency_to_text.py 2014-04-05 13:18:49 +0000 | |||
3554 | @@ -0,0 +1,491 @@ | |||
3555 | 1 | #!/usr/bin/python | ||
3556 | 2 | # -*- coding: utf8 -*- | ||
3557 | 3 | |||
3558 | 4 | ########################################################### | ||
3559 | 5 | # Developed by Kaspars Vilkens - Alistek Ltd (c) 2011 | ||
3560 | 6 | # pep-8, unicode and doctests by Paul Stevens, paul@nfg.nl, 2010 | ||
3561 | 7 | # | ||
3562 | 8 | # Supported currencies: LVL, EUR, USD, UAH | ||
3563 | 9 | # Supported sum: 0 ... 999999999999.99 | ||
3564 | 10 | # Supported languages: lv_LV, en_US, ru_RU, uk_UA | ||
3565 | 11 | ########################################################### | ||
3566 | 12 | import string | ||
3567 | 13 | |||
3568 | 14 | supported_currency = ['LVL','EUR','USD', 'UAH'] | ||
3569 | 15 | supported_language = ['lv_LV','en_US','ru_RU', 'uk_UA'] | ||
3570 | 16 | |||
3571 | 17 | def currency_to_text(sum, currency, language): | ||
3572 | 18 | """ | ||
3573 | 19 | |||
3574 | 20 | first some simple tests | ||
3575 | 21 | |||
3576 | 22 | >>> currency_to_text(123, 'EUR', 'en_US') | ||
3577 | 23 | 'one hundred twenty three euros zero cents' | ||
3578 | 24 | |||
3579 | 25 | >>> currency_to_text(1.11, 'EUR', 'en_US') | ||
3580 | 26 | 'one euro eleven cents' | ||
3581 | 27 | |||
3582 | 28 | >>> currency_to_text(1.10, 'USD', 'en_US') | ||
3583 | 29 | 'one US dollar ten cents' | ||
3584 | 30 | |||
3585 | 31 | >>> currency_to_text(1.01, 'USD', 'en_US') | ||
3586 | 32 | 'one US dollar one cent' | ||
3587 | 33 | |||
3588 | 34 | >>> currency_to_text(1.01, 'LVL', 'lv_LV') == 'viens lats viens santīms' | ||
3589 | 35 | True | ||
3590 | 36 | |||
3591 | 37 | >>> currency_to_text(123.12, 'LVL', 'ru_RU') == 'стo двaдцать три лата двенадцать сантимов' | ||
3592 | 38 | True | ||
3593 | 39 | |||
3594 | 40 | >>> currency_to_text(123.12, 'USD', 'ru_RU') == 'стo двaдцать три доллара США двенадцать центов' | ||
3595 | 41 | True | ||
3596 | 42 | |||
3597 | 43 | |||
3598 | 44 | """ | ||
3599 | 45 | if sum < 0 or sum > 999999999999.99 : | ||
3600 | 46 | raise Exception('Sum out of bounds: must be from 0 to 999999999999.99') | ||
3601 | 47 | if currency not in supported_currency: | ||
3602 | 48 | raise Exception("""Unsupported or no currency: must be one of (%s)""" % \ | ||
3603 | 49 | string.join(supported_currency,',')) | ||
3604 | 50 | if language not in supported_language: | ||
3605 | 51 | raise Exception("""Unsupported or no language: must be one of (%s)""" % \ | ||
3606 | 52 | string.join(supported_language,',')) | ||
3607 | 53 | #--------------for currencies with 100 fractions | ||
3608 | 54 | sum = float(sum) | ||
3609 | 55 | sum = round(sum, 2) | ||
3610 | 56 | # find out digits before floating point - currency | ||
3611 | 57 | sum_cur = int(sum) | ||
3612 | 58 | # find out digits after floating point - fractions | ||
3613 | 59 | sum_frc = int(round((sum - sum_cur) * 100,0)) | ||
3614 | 60 | cur_in_words = dtowords(sum_cur, language) | ||
3615 | 61 | #print cur_in_words | ||
3616 | 62 | frc_in_words = dtowords(sum_frc, language) | ||
3617 | 63 | #print frc_in_words | ||
3618 | 64 | #------------------------------------ | ||
3619 | 65 | if language == 'lv_LV' : | ||
3620 | 66 | if sum_cur == 1 or (str(sum_cur)[-1] == '1' and str(sum_cur)[-2] != '1'): # is the currency sum one | ||
3621 | 67 | if currency == 'LVL': | ||
3622 | 68 | cur_in_words += u' lats' | ||
3623 | 69 | elif currency == 'EUR': | ||
3624 | 70 | cur_in_words += u' eiro' | ||
3625 | 71 | elif currency == 'USD': | ||
3626 | 72 | cur_in_words += u' dolārs' | ||
3627 | 73 | elif currency == 'UAH': | ||
3628 | 74 | cur_in_words += u' grivna' | ||
3629 | 75 | else: | ||
3630 | 76 | if currency == 'LVL': | ||
3631 | 77 | cur_in_words += u' lati' | ||
3632 | 78 | elif currency == 'EUR': | ||
3633 | 79 | cur_in_words += u' eiro' | ||
3634 | 80 | elif currency == 'USD': | ||
3635 | 81 | cur_in_words += u' dolāri' | ||
3636 | 82 | elif currency == 'UAH': | ||
3637 | 83 | cur_in_words += u' grivnas' | ||
3638 | 84 | |||
3639 | 85 | if sum_frc == 1 or (str(sum_frc)[-1] == '1' and str(sum_frc)[-2] != '1'): # is the fraction sum one | ||
3640 | 86 | if currency == 'LVL': | ||
3641 | 87 | frc_in_words += u' santīms' | ||
3642 | 88 | elif currency == 'EUR' or currency == 'USD' : | ||
3643 | 89 | frc_in_words += u' cents' | ||
3644 | 90 | elif currency == 'UAH': | ||
3645 | 91 | frc_in_words += u' kapeika' | ||
3646 | 92 | else: | ||
3647 | 93 | if currency == 'LVL': | ||
3648 | 94 | frc_in_words += u' santīmi' | ||
3649 | 95 | elif currency == 'EUR' or currency == 'USD': | ||
3650 | 96 | frc_in_words += u' centi' | ||
3651 | 97 | elif currency == 'UAH': | ||
3652 | 98 | frc_in_words += u' kapeikas' | ||
3653 | 99 | #------------------------------------ | ||
3654 | 100 | if language == 'en_US' : | ||
3655 | 101 | if sum_cur == 1 or (str(sum_cur)[-1] == '1' and str(sum_cur)[-2] != '1'): # is the currency sum one | ||
3656 | 102 | if currency == 'LVL': | ||
3657 | 103 | cur_in_words += u' Latvian lats' | ||
3658 | 104 | elif currency == 'EUR': | ||
3659 | 105 | cur_in_words += u' euro' | ||
3660 | 106 | elif currency == 'USD': | ||
3661 | 107 | cur_in_words += u' US dollar' | ||
3662 | 108 | else: | ||
3663 | 109 | if currency == 'LVL': | ||
3664 | 110 | cur_in_words += u' Latvian lats' | ||
3665 | 111 | elif currency == 'EUR': | ||
3666 | 112 | cur_in_words += u' euros' | ||
3667 | 113 | elif currency == 'USD': | ||
3668 | 114 | cur_in_words += u' dollars' | ||
3669 | 115 | if sum_frc == 1 or (str(sum_frc)[-1] == '1' and str(sum_frc)[-2] != '1'): # is the fraction sum one | ||
3670 | 116 | if currency == 'LVL': | ||
3671 | 117 | frc_in_words += u' santim' | ||
3672 | 118 | elif currency == 'EUR' or currency == 'USD': | ||
3673 | 119 | frc_in_words += u' cent' | ||
3674 | 120 | else: | ||
3675 | 121 | if currency == 'LVL': | ||
3676 | 122 | frc_in_words += u' santims' | ||
3677 | 123 | elif currency == 'EUR' or currency == 'USD' : | ||
3678 | 124 | frc_in_words += u' cents' | ||
3679 | 125 | #------------------------------------ | ||
3680 | 126 | if language == 'ru_RU' : | ||
3681 | 127 | if sum_cur == 1 or (str(sum_cur)[-1] == '1' and str(sum_cur)[-2] != '1'): # is the currency sum one | ||
3682 | 128 | if currency == 'LVL': | ||
3683 | 129 | cur_in_words += u' лат' | ||
3684 | 130 | elif currency == 'EUR': | ||
3685 | 131 | cur_in_words += u' евро' | ||
3686 | 132 | elif currency == 'USD': | ||
3687 | 133 | cur_in_words += u' доллар США' | ||
3688 | 134 | elif (sum_cur in [2, 3, 4]) or (str(sum_cur)[-1] in ['2', '3', '4'] and str(sum_cur)[-2] != '1'): | ||
3689 | 135 | if currency == 'LVL': | ||
3690 | 136 | cur_in_words += u' лата' | ||
3691 | 137 | elif currency == 'EUR' : | ||
3692 | 138 | cur_in_words += u' евро' | ||
3693 | 139 | elif currency == 'USD' : | ||
3694 | 140 | cur_in_words += u' доллара США' | ||
3695 | 141 | elif (sum_cur >= 5 and sum_cur <= 20) or str(sum_cur)[-1] not in [2, 3, 4]: | ||
3696 | 142 | if currency == 'LVL' : | ||
3697 | 143 | cur_in_words += u' латов' | ||
3698 | 144 | elif currency == 'EUR' : | ||
3699 | 145 | cur_in_words += u' евро' | ||
3700 | 146 | elif currency == 'USD' : | ||
3701 | 147 | cur_in_words += u' долларов США' | ||
3702 | 148 | |||
3703 | 149 | if sum_frc == 1 or (str(sum_frc)[-1] == '1' and str(sum_frc)[-2] != '1') : # is the fraction one | ||
3704 | 150 | if currency == 'LVL' : | ||
3705 | 151 | frc_in_words += u' сантим' | ||
3706 | 152 | elif currency == 'EUR' or currency == 'USD' : | ||
3707 | 153 | frc_in_words += u' цент' | ||
3708 | 154 | elif (sum_frc in [2, 3, 4]) or (str(sum_frc)[-1] in ['2', '3', '4'] and str(sum_frc)[-2] != '1') : | ||
3709 | 155 | if currency == 'LVL' : | ||
3710 | 156 | frc_in_words += u' сантима' | ||
3711 | 157 | elif currency == 'EUR' or currency == 'USD' : | ||
3712 | 158 | frc_in_words += u' цента' | ||
3713 | 159 | elif (sum_frc >= 5 and sum_frc <= 20) or str(sum_frc)[-1] not in [2, 3, 4] : | ||
3714 | 160 | if currency == 'LVL' : | ||
3715 | 161 | frc_in_words += u' сантимов' | ||
3716 | 162 | elif currency == 'EUR' or currency == 'USD' : | ||
3717 | 163 | frc_in_words += u' центов' | ||
3718 | 164 | #------------------------------------ | ||
3719 | 165 | if language == 'uk_UA' : | ||
3720 | 166 | if sum_cur == 1 or (str(sum_cur)[-1] == '1' and str(sum_cur)[-2] != '1') : # is the currency sum one | ||
3721 | 167 | if currency == 'LVL' : | ||
3722 | 168 | cur_in_words += u' лат' | ||
3723 | 169 | elif currency == 'EUR' : | ||
3724 | 170 | cur_in_words += u' евро' | ||
3725 | 171 | elif currency == 'USD' : | ||
3726 | 172 | cur_in_words += u' доллар США' | ||
3727 | 173 | elif currency == 'UAH' : | ||
3728 | 174 | cur_in_words += u' гривня' | ||
3729 | 175 | elif (sum_cur in [2, 3, 4]) or (str(sum_cur)[-1] in ['2', '3', '4'] and str(sum_cur)[-2] != '1') : | ||
3730 | 176 | if currency == 'LVL' : | ||
3731 | 177 | cur_in_words += u' лата' | ||
3732 | 178 | elif currency == 'EUR' : | ||
3733 | 179 | cur_in_words += u' евро' | ||
3734 | 180 | elif currency == 'USD' : | ||
3735 | 181 | cur_in_words += u' доллара США' | ||
3736 | 182 | elif currency == 'UAH' : | ||
3737 | 183 | cur_in_words += u' гривні' | ||
3738 | 184 | elif (sum_cur >= 5 and sum_cur <= 20) or str(sum_cur)[-1] not in [2, 3, 4] : | ||
3739 | 185 | if currency == 'LVL' : | ||
3740 | 186 | cur_in_words += u' латов' | ||
3741 | 187 | elif currency == 'EUR' : | ||
3742 | 188 | cur_in_words += u' евро' | ||
3743 | 189 | elif currency == 'USD' : | ||
3744 | 190 | cur_in_words += u' долларов США' | ||
3745 | 191 | elif currency == 'UAH' : | ||
3746 | 192 | cur_in_words += u' гривень' | ||
3747 | 193 | |||
3748 | 194 | if sum_frc == 1 or (str(sum_frc)[-1] == '1' and str(sum_frc)[-2] != '1') : # is the fraction one | ||
3749 | 195 | if currency == 'LVL' : | ||
3750 | 196 | frc_in_words += u' сантим' | ||
3751 | 197 | elif currency == 'EUR' or currency == 'USD' : | ||
3752 | 198 | frc_in_words += u' цент' | ||
3753 | 199 | elif currency == 'UAH' : | ||
3754 | 200 | frc_in_words += u' копійка' | ||
3755 | 201 | elif (sum_frc in [2, 3, 4]) or (str(sum_frc)[-1] in ['2', '3', '4'] and str(sum_frc)[-2] != '1') : | ||
3756 | 202 | if currency == 'LVL' : | ||
3757 | 203 | frc_in_words += u' сантима' | ||
3758 | 204 | elif currency == 'EUR' or currency == 'USD' : | ||
3759 | 205 | frc_in_words += u' цента' | ||
3760 | 206 | elif currency == 'UAH' : | ||
3761 | 207 | frc_in_words += u' копійки' | ||
3762 | 208 | elif (sum_frc >= 5 and sum_frc <= 20) or str(sum_frc)[-1] not in [2, 3, 4] : | ||
3763 | 209 | if currency == 'LVL' : | ||
3764 | 210 | frc_in_words += u' сантимов' | ||
3765 | 211 | elif currency == 'EUR' or currency == 'USD' : | ||
3766 | 212 | frc_in_words += u' центов' | ||
3767 | 213 | elif currency == 'UAH' : | ||
3768 | 214 | frc_in_words += u' копійок' | ||
3769 | 215 | frc_in_words = str(sum_frc) + u' коп.' | ||
3770 | 216 | |||
3771 | 217 | return (cur_in_words + ' ' + frc_in_words).strip().encode('utf-8') | ||
3772 | 218 | |||
3773 | 219 | |||
3774 | 220 | def dtowords(sum_integers, language): | ||
3775 | 221 | """ | ||
3776 | 222 | >>> dtowords(0, 'en_US') | ||
3777 | 223 | u'zero' | ||
3778 | 224 | |||
3779 | 225 | >>> dtowords(1, 'en_US') | ||
3780 | 226 | u'one' | ||
3781 | 227 | |||
3782 | 228 | >>> dtowords(11, 'en_US') | ||
3783 | 229 | u'eleven' | ||
3784 | 230 | |||
3785 | 231 | >>> dtowords(169, 'en_US') | ||
3786 | 232 | u'one hundred sixty nine' | ||
3787 | 233 | |||
3788 | 234 | >>> dtowords(12345, 'en_US') | ||
3789 | 235 | u'twelve thousand three hundred fourty five' | ||
3790 | 236 | |||
3791 | 237 | >>> dtowords(123456, 'en_US') | ||
3792 | 238 | u'one hundred twenty three thousand four hundred fifty six' | ||
3793 | 239 | |||
3794 | 240 | >>> dtowords(0, 'lv_LV') | ||
3795 | 241 | u'nulle' | ||
3796 | 242 | |||
3797 | 243 | >>> dtowords(1, 'lv_LV') | ||
3798 | 244 | u'viens' | ||
3799 | 245 | |||
3800 | 246 | >>> dtowords(11, 'lv_LV') | ||
3801 | 247 | u'vienpadsmit' | ||
3802 | 248 | |||
3803 | 249 | >>> dtowords(169, 'lv_LV').encode('utf-8') == 'simts sešdesmit deviņi' | ||
3804 | 250 | True | ||
3805 | 251 | |||
3806 | 252 | >>> dtowords(12345, 'lv_LV').encode('utf-8') == 'divpadsmit tūkstoši trīs simti četrdesmit pieci' | ||
3807 | 253 | True | ||
3808 | 254 | |||
3809 | 255 | >>> dtowords(123456, 'lv_LV').encode('utf-8') == 'simts divdesmit trīs tūkstoši četri simti piecdesmit seši' | ||
3810 | 256 | True | ||
3811 | 257 | |||
3812 | 258 | >>> dtowords(0, 'ru_RU').encode('utf-8') == 'ноль' | ||
3813 | 259 | True | ||
3814 | 260 | |||
3815 | 261 | >>> dtowords(1, 'ru_RU').encode('utf-8') == 'один' | ||
3816 | 262 | True | ||
3817 | 263 | |||
3818 | 264 | >>> dtowords(11, 'ru_RU').encode('utf-8') == 'одиннадцать' | ||
3819 | 265 | True | ||
3820 | 266 | |||
3821 | 267 | >>> dtowords(169, 'ru_RU').encode('utf-8') == 'стo шестьдесят девять' | ||
3822 | 268 | True | ||
3823 | 269 | |||
3824 | 270 | >>> dtowords(12345, 'ru_RU').encode('utf-8') == 'двенадцать тысяч триста сорок пять' | ||
3825 | 271 | True | ||
3826 | 272 | |||
3827 | 273 | >>> dtowords(123456, 'ru_RU').encode('utf-8') == 'стo двaдцать три тысячи четыреста пятьдесят шесть' | ||
3828 | 274 | True | ||
3829 | 275 | |||
3830 | 276 | |||
3831 | 277 | """ | ||
3832 | 278 | diginwords = u'' | ||
3833 | 279 | if sum_integers == 0: | ||
3834 | 280 | return wordify('0', 0, language) | ||
3835 | 281 | elif sum_integers > 0: | ||
3836 | 282 | lengthx = len(str(sum_integers)) | ||
3837 | 283 | nrchunks = (lengthx / 3) | ||
3838 | 284 | if nrchunks < (float(lengthx) / 3) : | ||
3839 | 285 | nrchunks+=1 | ||
3840 | 286 | inc = 1 | ||
3841 | 287 | while inc <= nrchunks: | ||
3842 | 288 | startpos = (lengthx - inc * 3) | ||
3843 | 289 | chunklength = 3 | ||
3844 | 290 | if startpos < 0: | ||
3845 | 291 | chunklength += startpos | ||
3846 | 292 | startpos = 0 | ||
3847 | 293 | chunk = str(sum_integers)[startpos : startpos + chunklength] | ||
3848 | 294 | #print str(startpos)+' '+str(chunklength)+' '+ chunk | ||
3849 | 295 | wordified = wordify(chunk, inc-1, language) | ||
3850 | 296 | inc += 1 | ||
3851 | 297 | spacer = '' | ||
3852 | 298 | if len(diginwords) > 0 : | ||
3853 | 299 | spacer = ' ' | ||
3854 | 300 | diginwords = wordified + spacer + diginwords | ||
3855 | 301 | return diginwords | ||
3856 | 302 | |||
3857 | 303 | def wordify(chunk, chunknr, language): | ||
3858 | 304 | #print 'chunk '+str(chunk) | ||
3859 | 305 | #print 'cunknr '+str(chunknr) | ||
3860 | 306 | words = u'' | ||
3861 | 307 | |||
3862 | 308 | if language == 'lv_LV': | ||
3863 | 309 | skaitli = [u'nulle', u'viens', u'divi', u'trīs', u'četri', u'pieci', | ||
3864 | 310 | u'seši', u'septiņi', u'astoņi', u'deviņi'] | ||
3865 | 311 | skaitlix = [u'nulle', u'vien', u'div', u'trīs', u'četr', u'piec', u'seš', | ||
3866 | 312 | u'septiņ', u'astoņ', u'deviņ'] | ||
3867 | 313 | skaitli_teens = [u'desmit', u'vienpadsmit', u'divpadsmit', u'trīspadsmit', | ||
3868 | 314 | u'četrpadsmit', u'piecpadsmit', u'sešpadsmit', | ||
3869 | 315 | u'septiņpadsmit', u'astoņpadsmit', u'deviņpadsmit'] | ||
3870 | 316 | daudzums = [u'simts', u' tūkstotis', u' miljons', u' miljards'] | ||
3871 | 317 | daudzumsx = [u' simti', u' tūkstoši', u' miljoni', u' miljardi'] | ||
3872 | 318 | |||
3873 | 319 | elif language == 'en_US': | ||
3874 | 320 | skaitli = [u'zero', u'one', u'two', u'three', u'four', u'five', u'six', | ||
3875 | 321 | u'seven', u'eight', u'nine'] | ||
3876 | 322 | skaitlix = [u'zero', u'one', u'twen', u'thir', u'four', u'fif', u'six', | ||
3877 | 323 | u'seven', u'eigh', u'nine'] | ||
3878 | 324 | skaitli_teens = [u'ten', u'eleven', u'twelve', u'thirteen', u'fourteen', | ||
3879 | 325 | u'fifteen', u'sixteen', u'seventeen', u'eighteen', u'nineteen'] | ||
3880 | 326 | daudzums = [u' hundred', u' thousand', u' million', u' billion'] | ||
3881 | 327 | daudzumsx = daudzums | ||
3882 | 328 | |||
3883 | 329 | elif language == 'ru_RU': | ||
3884 | 330 | skaitli = [u'ноль', u'один', u'два', u'три', u'четыре', u'пять', u'шесть', | ||
3885 | 331 | u'семь', u'восемь', u'девять'] | ||
3886 | 332 | skaitlix = [u'', u'один', u'двa', u'три', u'четыре', u'пять', u'шесть', | ||
3887 | 333 | u'семь', u'восемь', u'девять'] | ||
3888 | 334 | skaitli_teens = [u'десять', u'одиннадцать', u'двенадцать', u'тринадцать', | ||
3889 | 335 | u'четырнадцать', u'пятнадцать', u'шестнадцать', u'семнадцать', | ||
3890 | 336 | u'восемнадцать', u'девятнадцать'] | ||
3891 | 337 | daudzums = [u'стo', u' тысяча', u' миллион', u' миллиард'] | ||
3892 | 338 | daudzumsx = [u'сoт', u' тысяч', u' миллионов', u' миллиардов'] | ||
3893 | 339 | |||
3894 | 340 | elif language == 'uk_UA' : | ||
3895 | 341 | skaitli = [u'ноль', u'один', u'два', u'три', u'чотири', u'п\'ять', u'шість', | ||
3896 | 342 | u'сім', u'вісім', u'дев\'ять'] | ||
3897 | 343 | skaitlix = [u'', u'один', u'двa', u'три', u'чотири', u'п\'ять', u'шість', | ||
3898 | 344 | u'сім', u'вісім', u'дев\'ять'] | ||
3899 | 345 | skaitli_teens = [u'десять', u'одинадцять', u'дванадцять', u'тринадцять', | ||
3900 | 346 | u'чотирнадцять', u'п\'ятнадцять', u'шістнадцять', u'сімнадцять', | ||
3901 | 347 | u'вісімнадцять', u'дев\'ятнадцять'] | ||
3902 | 348 | daudzums = [u'стo', u' тисяча', u' мiллiон', u' мiллiард'] | ||
3903 | 349 | daudzumsx = [u'сoт', u' тисяч', u' мiллiонiв', u' мiллiардов'] | ||
3904 | 350 | digit1 = u'' | ||
3905 | 351 | digit2 = u'' | ||
3906 | 352 | digit3 = u'' | ||
3907 | 353 | chunklength = len(chunk) | ||
3908 | 354 | # placing digits in right places | ||
3909 | 355 | if chunklength == 1: | ||
3910 | 356 | digit3 = chunk[0 : 1] | ||
3911 | 357 | if chunklength == 2: | ||
3912 | 358 | digit2 = chunk[0 : 1] | ||
3913 | 359 | digit3 = chunk[1 : 2] | ||
3914 | 360 | if chunklength == 3: | ||
3915 | 361 | digit1 = chunk[0 : 1] | ||
3916 | 362 | digit2 = chunk[1 : 2] | ||
3917 | 363 | digit3 = chunk[-1] | ||
3918 | 364 | # processing zero | ||
3919 | 365 | if chunklength == 1 and digit3 == '0' : | ||
3920 | 366 | return skaitli[0] | ||
3921 | 367 | # processing hundreds | ||
3922 | 368 | if chunklength == 3 : | ||
3923 | 369 | if digit1 == '1' : | ||
3924 | 370 | if language == 'lv_LV' or language == 'ru_RU' or language == 'uk_UA': | ||
3925 | 371 | words += daudzums[0] | ||
3926 | 372 | elif language == 'en_US' : | ||
3927 | 373 | words += skaitli[int(digit1)] + daudzumsx[0] | ||
3928 | 374 | else : | ||
3929 | 375 | if language == 'lv_LV' : | ||
3930 | 376 | if int(digit1) > 1 : words += skaitli[int(digit1)] + daudzumsx[0] | ||
3931 | 377 | elif language == 'en_US' : | ||
3932 | 378 | if int(digit1) > 1 : words += skaitli[int(digit1)] + daudzumsx[0] | ||
3933 | 379 | elif language == 'ru_RU' : | ||
3934 | 380 | if int(digit1) == 2 : | ||
3935 | 381 | words += u'двести' | ||
3936 | 382 | elif int(digit1) == 3 : | ||
3937 | 383 | words += u'триста' | ||
3938 | 384 | elif int(digit1) == 4 : | ||
3939 | 385 | words += u'четыреста' | ||
3940 | 386 | elif int(digit1) >= 5 : | ||
3941 | 387 | words += skaitli[int(digit1)] + daudzumsx[0] | ||
3942 | 388 | elif language == 'uk_UA' : | ||
3943 | 389 | if int(digit1) == 2 : | ||
3944 | 390 | words += u'двісті' | ||
3945 | 391 | elif int(digit1) == 3 : | ||
3946 | 392 | words += u'триста' | ||
3947 | 393 | elif int(digit1) == 4 : | ||
3948 | 394 | words += u'чотириста' | ||
3949 | 395 | elif int(digit1) >= 5 : | ||
3950 | 396 | words += skaitli[int(digit1)] + daudzumsx[0] | ||
3951 | 397 | # processing tens | ||
3952 | 398 | if chunklength > 1: | ||
3953 | 399 | spacer = '' | ||
3954 | 400 | if len(words) > 0 : spacer = ' ' | ||
3955 | 401 | if digit2 == '1': | ||
3956 | 402 | if language == 'lv_LV' or language == 'en_US' or language == 'ru_RU' or language == 'uk_UA': | ||
3957 | 403 | words += spacer + skaitli_teens[int(digit3)] | ||
3958 | 404 | else: | ||
3959 | 405 | if language == 'lv_LV': | ||
3960 | 406 | if int(digit2) > 1 and int(digit2) > 0: | ||
3961 | 407 | words += spacer + skaitlix[int(digit2)] + u'desmit' | ||
3962 | 408 | elif language == 'en_US': | ||
3963 | 409 | if int(digit2) > 1 and int(digit2) > 0: | ||
3964 | 410 | words += spacer + skaitlix[int(digit2)] + u'ty' | ||
3965 | 411 | elif language == 'ru_RU': | ||
3966 | 412 | if int(digit2) > 1 and int(digit2) < 4: | ||
3967 | 413 | words += spacer + skaitlix[int(digit2)] + u'дцать' | ||
3968 | 414 | elif digit2 == '4': | ||
3969 | 415 | words += spacer + u'сорок' | ||
3970 | 416 | elif int(digit2) >= 5 and int(digit2) != 9: | ||
3971 | 417 | words += spacer + skaitlix[int(digit2)] + u'десят' | ||
3972 | 418 | elif digit2 == '9': | ||
3973 | 419 | words += spacer + u'девяносто' | ||
3974 | 420 | elif language == 'uk_UA' : | ||
3975 | 421 | if int(digit2) > 1 and int(digit2) < 4: | ||
3976 | 422 | words += spacer + skaitlix[int(digit2)] + u'дцять' | ||
3977 | 423 | elif digit2 == '4': | ||
3978 | 424 | words += spacer + u'сорок' | ||
3979 | 425 | elif int(digit2) >= 5 and int(digit2) != 9: | ||
3980 | 426 | words += spacer + skaitlix[int(digit2)] + u'десят' | ||
3981 | 427 | elif digit2 == '9': | ||
3982 | 428 | words += spacer + u'дев\'яносто' | ||
3983 | 429 | # processing ones | ||
3984 | 430 | if chunklength > 0 and digit2 != '1' : | ||
3985 | 431 | spacer = '' | ||
3986 | 432 | if len(words) > 0: spacer = u' ' | ||
3987 | 433 | if language == 'lv_LV' or language == 'en_US': | ||
3988 | 434 | if int(digit3) > 0: | ||
3989 | 435 | words += spacer + skaitli[int(digit3)] | ||
3990 | 436 | elif language == 'ru_RU': | ||
3991 | 437 | if chunknr == 1: | ||
3992 | 438 | if int(digit3) == 1: | ||
3993 | 439 | words += spacer + u'одна' | ||
3994 | 440 | elif int(digit3) == 2: | ||
3995 | 441 | words += spacer + u'две' | ||
3996 | 442 | elif int(digit3) >= 3 and int(digit3) != 0: | ||
3997 | 443 | words += spacer + skaitli[int(digit3)] | ||
3998 | 444 | else: | ||
3999 | 445 | if int(digit3) > 0: words += spacer + skaitli[int(digit3)] | ||
4000 | 446 | elif language == 'uk_UA' : | ||
4001 | 447 | if chunknr == 1 : | ||
4002 | 448 | if int(digit3) == 1 : words += spacer + u'одна' | ||
4003 | 449 | elif int(digit3) == 2 : words += spacer + u'дві' | ||
4004 | 450 | elif int(digit3) >= 3 and int(digit3) != 0: words += spacer + skaitli[int(digit3)] | ||
4005 | 451 | else: | ||
4006 | 452 | if int(digit3) > 0 : words += spacer + skaitli[int(digit3)] | ||
4007 | 453 | # end processing | ||
4008 | 454 | if len(words) > 0 : | ||
4009 | 455 | |||
4010 | 456 | if digit3 == '1' and chunknr > 0: | ||
4011 | 457 | return words + daudzums[chunknr] | ||
4012 | 458 | elif digit3 != '1' and chunknr > 0: | ||
4013 | 459 | if language == 'lv_LV' or language == 'en_US' : | ||
4014 | 460 | return words + daudzumsx[chunknr] | ||
4015 | 461 | elif language == 'ru_RU' : | ||
4016 | 462 | if (int(digit3) == 2 or int(digit3) == 3 or int(digit3) == 4) and digit2 != '1' : | ||
4017 | 463 | if chunknr == 1 : | ||
4018 | 464 | return words + u' тысячи' | ||
4019 | 465 | elif chunknr == 2 : | ||
4020 | 466 | return words + u' миллионa' | ||
4021 | 467 | elif chunknr == 3 : | ||
4022 | 468 | return words + u' миллиардa' | ||
4023 | 469 | else: | ||
4024 | 470 | return words + daudzumsx[chunknr] | ||
4025 | 471 | elif language == 'uk_UA' : | ||
4026 | 472 | if (int(digit3) == 2 or int(digit3) == 3 or int(digit3) == 4) and digit2 != '1' : | ||
4027 | 473 | if chunknr == 1 : | ||
4028 | 474 | return words + u' тисячі' | ||
4029 | 475 | elif chunknr == 2 : | ||
4030 | 476 | return words + u' мілліонa' | ||
4031 | 477 | elif chunknr == 3 : | ||
4032 | 478 | return words + u' мілліардa' | ||
4033 | 479 | else: | ||
4034 | 480 | return words + daudzumsx[chunknr] | ||
4035 | 481 | else: | ||
4036 | 482 | return words | ||
4037 | 483 | else: | ||
4038 | 484 | return '' | ||
4039 | 485 | |||
4040 | 486 | |||
4041 | 487 | if __name__ == '__main__': | ||
4042 | 488 | import doctest | ||
4043 | 489 | doctest.testmod() | ||
4044 | 490 | |||
4045 | 491 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
4046 | 0 | 492 | ||
4047 | === added directory 'report_aeroo/data' | |||
4048 | === added file 'report_aeroo/data/report_aeroo_data.xml' | |||
4049 | --- report_aeroo/data/report_aeroo_data.xml 1970-01-01 00:00:00 +0000 | |||
4050 | +++ report_aeroo/data/report_aeroo_data.xml 2014-04-05 13:18:49 +0000 | |||
4051 | @@ -0,0 +1,25 @@ | |||
4052 | 1 | <?xml version="1.0"?> | ||
4053 | 2 | <openerp> | ||
4054 | 3 | <data noupdate="1"> | ||
4055 | 4 | |||
4056 | 5 | <record model="report.mimetypes" id="report_mimetypes_odt_odt" > | ||
4057 | 6 | <field name="name">ODF Text Document (.odt)</field> | ||
4058 | 7 | <field name="code">oo-odt</field> | ||
4059 | 8 | <field name="compatible_types">oo-odt</field> | ||
4060 | 9 | </record> | ||
4061 | 10 | |||
4062 | 11 | <record model="report.mimetypes" id="report_mimetypes_ods_ods" > | ||
4063 | 12 | <field name="name">ODF Spreadsheet (.ods)</field> | ||
4064 | 13 | <field name="code">oo-ods</field> | ||
4065 | 14 | <field name="compatible_types">oo-ods</field> | ||
4066 | 15 | </record> | ||
4067 | 16 | |||
4068 | 17 | <record model="report.mimetypes" id="report_mimetypes_raw" > | ||
4069 | 18 | <field name="name">Generic</field> | ||
4070 | 19 | <field name="code">genshi-raw</field> | ||
4071 | 20 | <field name="compatible_types">genshi-raw</field> | ||
4072 | 21 | </record> | ||
4073 | 22 | |||
4074 | 23 | </data> | ||
4075 | 24 | </openerp> | ||
4076 | 25 | |||
4077 | 0 | 26 | ||
4078 | === added file 'report_aeroo/domain_parser.py' | |||
4079 | --- report_aeroo/domain_parser.py 1970-01-01 00:00:00 +0000 | |||
4080 | +++ report_aeroo/domain_parser.py 2014-04-05 13:18:49 +0000 | |||
4081 | @@ -0,0 +1,49 @@ | |||
4082 | 1 | ############################################################################## | ||
4083 | 2 | # | ||
4084 | 3 | # Copyright (c) 2009-2011 Alistek Ltd (http://www.alistek.com) All Rights Reserved. | ||
4085 | 4 | # General contacts <info@alistek.com> | ||
4086 | 5 | # | ||
4087 | 6 | # WARNING: This program as such is intended to be used by professional | ||
4088 | 7 | # programmers who take the whole responsability of assessing all potential | ||
4089 | 8 | # consequences resulting from its eventual inadequacies and bugs | ||
4090 | 9 | # End users who are looking for a ready-to-use solution with commercial | ||
4091 | 10 | # garantees and support are strongly adviced to contract a Free Software | ||
4092 | 11 | # Service Company | ||
4093 | 12 | # | ||
4094 | 13 | # This program is Free Software; you can redistribute it and/or | ||
4095 | 14 | # modify it under the terms of the GNU General Public License | ||
4096 | 15 | # as published by the Free Software Foundation; either version 3 | ||
4097 | 16 | # of the License, or (at your option) any later version. | ||
4098 | 17 | # | ||
4099 | 18 | # This module is GPLv3 or newer and incompatible | ||
4100 | 19 | # with OpenERP SA "AGPL + Private Use License"! | ||
4101 | 20 | # | ||
4102 | 21 | # This program is distributed in the hope that it will be useful, | ||
4103 | 22 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4104 | 23 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4105 | 24 | # GNU General Public License for more details. | ||
4106 | 25 | # | ||
4107 | 26 | # You should have received a copy of the GNU General Public License | ||
4108 | 27 | # along with this program; if not, write to the Free Software | ||
4109 | 28 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
4110 | 29 | # | ||
4111 | 30 | ############################################################################## | ||
4112 | 31 | |||
4113 | 32 | def domain2statement(domain): | ||
4114 | 33 | statement='' | ||
4115 | 34 | operator=False | ||
4116 | 35 | for d in domain: | ||
4117 | 36 | if not operator: | ||
4118 | 37 | if type(d)==str: | ||
4119 | 38 | if d=='|': | ||
4120 | 39 | operator=' or' | ||
4121 | 40 | continue | ||
4122 | 41 | else: | ||
4123 | 42 | operator=False | ||
4124 | 43 | statement+=' o.'+str(d[0])+' '+(d[1]=='=' and '==' or d[1])+' '+(isinstance(d[2], str) and '\''+d[2]+'\'' or str(d[2])) | ||
4125 | 44 | if d!=domain[-1]: | ||
4126 | 45 | statement+=operator or ' and' | ||
4127 | 46 | operator=False | ||
4128 | 47 | return statement | ||
4129 | 48 | |||
4130 | 49 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
4131 | 0 | 50 | ||
4132 | === added file 'report_aeroo/installer.py' | |||
4133 | --- report_aeroo/installer.py 1970-01-01 00:00:00 +0000 | |||
4134 | +++ report_aeroo/installer.py 2014-04-05 13:18:49 +0000 | |||
4135 | @@ -0,0 +1,79 @@ | |||
4136 | 1 | # -*- coding: utf-8 -*- | ||
4137 | 2 | ############################################################################## | ||
4138 | 3 | # | ||
4139 | 4 | # Copyright (c) 2008-2013 Alistek Ltd (http://www.alistek.com) All Rights Reserved. | ||
4140 | 5 | # General contacts <info@alistek.com> | ||
4141 | 6 | # | ||
4142 | 7 | # WARNING: This program as such is intended to be used by professional | ||
4143 | 8 | # programmers who take the whole responsability of assessing all potential | ||
4144 | 9 | # consequences resulting from its eventual inadequacies and bugs | ||
4145 | 10 | # End users who are looking for a ready-to-use solution with commercial | ||
4146 | 11 | # garantees and support are strongly adviced to contract a Free Software | ||
4147 | 12 | # Service Company | ||
4148 | 13 | # | ||
4149 | 14 | # This program is Free Software; you can redistribute it and/or | ||
4150 | 15 | # modify it under the terms of the GNU General Public License | ||
4151 | 16 | # as published by the Free Software Foundation; either version 3 | ||
4152 | 17 | # of the License, or (at your option) any later version. | ||
4153 | 18 | # | ||
4154 | 19 | # This module is GPLv3 or newer and incompatible | ||
4155 | 20 | # with OpenERP SA "AGPL + Private Use License"! | ||
4156 | 21 | # | ||
4157 | 22 | # This program is distributed in the hope that it will be useful, | ||
4158 | 23 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4159 | 24 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4160 | 25 | # GNU General Public License for more details. | ||
4161 | 26 | # | ||
4162 | 27 | # You should have received a copy of the GNU General Public License | ||
4163 | 28 | # along with this program; if not, write to the Free Software | ||
4164 | 29 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
4165 | 30 | # | ||
4166 | 31 | ############################################################################## | ||
4167 | 32 | from openerp.osv import orm, fields | ||
4168 | 33 | from openerp import netsvc | ||
4169 | 34 | from openerp import tools | ||
4170 | 35 | import os, base64 | ||
4171 | 36 | import urllib2 | ||
4172 | 37 | |||
4173 | 38 | _url = 'http://www.alistek.com/aeroo_banner/v7_0_report_aeroo.png' | ||
4174 | 39 | |||
4175 | 40 | class report_aeroo_installer(orm.TransientModel): | ||
4176 | 41 | _name = 'report.aeroo.installer' | ||
4177 | 42 | _inherit = 'res.config.installer' | ||
4178 | 43 | _logo_image = None | ||
4179 | 44 | |||
4180 | 45 | def _get_image(self, cr, uid, context=None): | ||
4181 | 46 | if self._logo_image: | ||
4182 | 47 | return self._logo_image | ||
4183 | 48 | try: | ||
4184 | 49 | im = urllib2.urlopen(_url.encode("UTF-8")) | ||
4185 | 50 | if im.headers.maintype!='image': | ||
4186 | 51 | raise TypeError(im.headers.maintype) | ||
4187 | 52 | except Exception, e: | ||
4188 | 53 | path = os.path.join('report_aeroo','config_pixmaps','module_banner.png') | ||
4189 | 54 | image_file = file_data = tools.file_open(path,'rb') | ||
4190 | 55 | try: | ||
4191 | 56 | file_data = image_file.read() | ||
4192 | 57 | self._logo_image = base64.encodestring(file_data) | ||
4193 | 58 | return self._logo_image | ||
4194 | 59 | finally: | ||
4195 | 60 | image_file.close() | ||
4196 | 61 | else: | ||
4197 | 62 | self._logo_image = base64.encodestring(im.read()) | ||
4198 | 63 | return self._logo_image | ||
4199 | 64 | |||
4200 | 65 | def _get_image_fn(self, cr, uid, ids, name, args, context=None): | ||
4201 | 66 | image = self._get_image(cr, uid, context) | ||
4202 | 67 | return dict.fromkeys(ids, image) # ok to use .fromkeys() as the image is same for all | ||
4203 | 68 | |||
4204 | 69 | _columns = { | ||
4205 | 70 | 'link':fields.char('Original developer', size=128, readonly=True), | ||
4206 | 71 | 'config_logo': fields.function(_get_image_fn, string='Image', type='binary', method=True), | ||
4207 | 72 | } | ||
4208 | 73 | |||
4209 | 74 | _defaults = { | ||
4210 | 75 | 'config_logo': _get_image, | ||
4211 | 76 | 'link':'http://www.alistek.com', | ||
4212 | 77 | } | ||
4213 | 78 | |||
4214 | 79 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
4215 | 0 | 80 | ||
4216 | === added file 'report_aeroo/installer.xml' | |||
4217 | --- report_aeroo/installer.xml 1970-01-01 00:00:00 +0000 | |||
4218 | +++ report_aeroo/installer.xml 2014-04-05 13:18:49 +0000 | |||
4219 | @@ -0,0 +1,56 @@ | |||
4220 | 1 | <openerp> | ||
4221 | 2 | <data> | ||
4222 | 3 | |||
4223 | 4 | <record id="view_report_aeroo_installer" model="ir.ui.view"> | ||
4224 | 5 | <field name="name">report.aeroo.installer.view</field> | ||
4225 | 6 | <field name="model">report.aeroo.installer</field> | ||
4226 | 7 | <field name="type">form</field> | ||
4227 | 8 | <field name="inherit_id" ref="base.res_config_installer"/> | ||
4228 | 9 | <field name="arch" type="xml"> | ||
4229 | 10 | <data> | ||
4230 | 11 | <form position="attributes" version="7.0"> | ||
4231 | 12 | <attribute name="string">Aeroo Reports Installation</attribute> | ||
4232 | 13 | </form> | ||
4233 | 14 | <footer position="replace"> | ||
4234 | 15 | <footer> | ||
4235 | 16 | <button name="action_next" type="object" string="Continue" invisible="context.get('menu',False)" class="oe_highlight"/> | ||
4236 | 17 | or | ||
4237 | 18 | <button special="cancel" string="Close" class="oe_link"/> | ||
4238 | 19 | </footer> | ||
4239 | 20 | </footer> | ||
4240 | 21 | <separator string="title" position="replace"> | ||
4241 | 22 | <p class="oe_grey"> | ||
4242 | 23 | Aeroo Reports for OpenERP is a comprehensive reporting engine based on Aeroo Library. | ||
4243 | 24 | </p> | ||
4244 | 25 | <group> | ||
4245 | 26 | <group width="25%%"> | ||
4246 | 27 | <field name="config_logo" widget="image" nolabel="1" colspan="2"/> | ||
4247 | 28 | </group> | ||
4248 | 29 | <group width="75%%"> | ||
4249 | 30 | <field name="link" widget="url"/> | ||
4250 | 31 | </group> | ||
4251 | 32 | </group> | ||
4252 | 33 | </separator> | ||
4253 | 34 | </data> | ||
4254 | 35 | </field> | ||
4255 | 36 | </record> | ||
4256 | 37 | |||
4257 | 38 | <record id="action_report_aeroo_installer" model="ir.actions.act_window"> | ||
4258 | 39 | <field name="name">Aeroo Reports Installation</field> | ||
4259 | 40 | <field name="type">ir.actions.act_window</field> | ||
4260 | 41 | <field name="res_model">report.aeroo.installer</field> | ||
4261 | 42 | <field name="view_id" ref="view_report_aeroo_installer"/> | ||
4262 | 43 | <field name="view_type">form</field> | ||
4263 | 44 | <field name="view_mode">form</field> | ||
4264 | 45 | <field name="target">new</field> | ||
4265 | 46 | </record> | ||
4266 | 47 | |||
4267 | 48 | <record id="report_aeroo_installer_todo" model="ir.actions.todo"> | ||
4268 | 49 | <field name="action_id" ref="action_report_aeroo_installer"/> | ||
4269 | 50 | <field name="restart">always</field> | ||
4270 | 51 | <field name="sequence">3</field> | ||
4271 | 52 | <field name="type">automatic</field> | ||
4272 | 53 | </record> | ||
4273 | 54 | |||
4274 | 55 | </data> | ||
4275 | 56 | </openerp> | ||
4276 | 0 | 57 | ||
4277 | === added file 'report_aeroo/report_aeroo.py' | |||
4278 | --- report_aeroo/report_aeroo.py 1970-01-01 00:00:00 +0000 | |||
4279 | +++ report_aeroo/report_aeroo.py 2014-04-05 13:18:49 +0000 | |||
4280 | @@ -0,0 +1,859 @@ | |||
4281 | 1 | # -*- coding: utf-8 -*- | ||
4282 | 2 | ############################################################################## | ||
4283 | 3 | # | ||
4284 | 4 | # Copyright (c) 2009-2013 Alistek Ltd (http://www.alistek.com) All Rights Reserved. | ||
4285 | 5 | # General contacts <info@alistek.com> | ||
4286 | 6 | # Copyright (C) 2009 Domsense s.r.l. | ||
4287 | 7 | # | ||
4288 | 8 | # WARNING: This program as such is intended to be used by professional | ||
4289 | 9 | # programmers who take the whole responsability of assessing all potential | ||
4290 | 10 | # consequences resulting from its eventual inadequacies and bugs | ||
4291 | 11 | # End users who are looking for a ready-to-use solution with commercial | ||
4292 | 12 | # garantees and support are strongly adviced to contract a Free Software | ||
4293 | 13 | # Service Company | ||
4294 | 14 | # | ||
4295 | 15 | # This program is Free Software; you can redistribute it and/or | ||
4296 | 16 | # modify it under the terms of the GNU General Public License | ||
4297 | 17 | # as published by the Free Software Foundation; either version 3 | ||
4298 | 18 | # of the License, or (at your option) any later version. | ||
4299 | 19 | # | ||
4300 | 20 | # This module is GPLv3 or newer and incompatible | ||
4301 | 21 | # with OpenERP SA "AGPL + Private Use License"! | ||
4302 | 22 | # | ||
4303 | 23 | # This program is distributed in the hope that it will be useful, | ||
4304 | 24 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4305 | 25 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4306 | 26 | # GNU General Public License for more details. | ||
4307 | 27 | # | ||
4308 | 28 | # You should have received a copy of the GNU General Public License | ||
4309 | 29 | # along with this program; if not, write to the Free Software | ||
4310 | 30 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
4311 | 31 | # | ||
4312 | 32 | ############################################################################## | ||
4313 | 33 | |||
4314 | 34 | import os, sys, traceback | ||
4315 | 35 | from tempfile import NamedTemporaryFile | ||
4316 | 36 | from openerp import report | ||
4317 | 37 | from report.report_sxw import report_sxw, report_rml, browse_record_list, _fields_process | ||
4318 | 38 | from report.pyPdf import PdfFileWriter, PdfFileReader | ||
4319 | 39 | #import zipfile | ||
4320 | 40 | try: | ||
4321 | 41 | from cStringIO import StringIO | ||
4322 | 42 | except ImportError: | ||
4323 | 43 | from StringIO import StringIO | ||
4324 | 44 | from xml.dom import minidom | ||
4325 | 45 | import base64 | ||
4326 | 46 | from openerp.osv import orm | ||
4327 | 47 | from openerp import tools | ||
4328 | 48 | from tools.translate import _ | ||
4329 | 49 | import time | ||
4330 | 50 | import re | ||
4331 | 51 | import copy | ||
4332 | 52 | import threading | ||
4333 | 53 | from random import randint | ||
4334 | 54 | try: | ||
4335 | 55 | from addons import load_information_from_description_file # for OpenERP 6.0.x | ||
4336 | 56 | except ImportError: | ||
4337 | 57 | from openerp.modules import load_information_from_description_file # for OpenERP 6.1 or 7.0 | ||
4338 | 58 | from openerp import release | ||
4339 | 59 | |||
4340 | 60 | import aeroolib | ||
4341 | 61 | from aeroolib.plugins.opendocument import Template, OOSerializer | ||
4342 | 62 | from genshi.template import NewTextTemplate | ||
4343 | 63 | from genshi import __version__ as genshi_version | ||
4344 | 64 | from openerp import pooler | ||
4345 | 65 | from openerp import netsvc | ||
4346 | 66 | from lxml import etree | ||
4347 | 67 | import logging | ||
4348 | 68 | |||
4349 | 69 | logger = logging.getLogger(__name__) | ||
4350 | 70 | |||
4351 | 71 | from .ExtraFunctions import ExtraFunctions | ||
4352 | 72 | |||
4353 | 73 | try: | ||
4354 | 74 | aeroo_lock = threading.Lock() | ||
4355 | 75 | msg = "Aeroo lock instantiated." | ||
4356 | 76 | logger.log(logging.INFO, msg) | ||
4357 | 77 | except Exception: | ||
4358 | 78 | err_msg = "Could not instantiate Aeroo lock!!!" | ||
4359 | 79 | logger.log(logging.CRITICAL, err_msg) | ||
4360 | 80 | |||
4361 | 81 | from openerp import SUPERUSER_ID | ||
4362 | 82 | |||
4363 | 83 | def _aeroo_ooo_test(cr): | ||
4364 | 84 | ''' | ||
4365 | 85 | Detect report_aeroo_ooo module | ||
4366 | 86 | ''' | ||
4367 | 87 | aeroo_ooo = False | ||
4368 | 88 | cr.execute("SELECT id, state FROM ir_module_module WHERE name='report_aeroo_ooo'") | ||
4369 | 89 | helper_module = cr.dictfetchone() | ||
4370 | 90 | if helper_module and helper_module['state'] in ('installed', 'to upgrade'): | ||
4371 | 91 | aeroo_ooo = True | ||
4372 | 92 | return aeroo_ooo | ||
4373 | 93 | |||
4374 | 94 | class Counter(object): | ||
4375 | 95 | def __init__(self, name, start=0, interval=1): | ||
4376 | 96 | self.name = name | ||
4377 | 97 | self._number = start | ||
4378 | 98 | self._interval = interval | ||
4379 | 99 | |||
4380 | 100 | def next(self, increment=True): | ||
4381 | 101 | if increment: | ||
4382 | 102 | self._number += self._interval | ||
4383 | 103 | return self._number | ||
4384 | 104 | else: | ||
4385 | 105 | return self._number + self._interval | ||
4386 | 106 | |||
4387 | 107 | def get_inc(self): | ||
4388 | 108 | return self._number | ||
4389 | 109 | |||
4390 | 110 | def prev(self, decrement=True): | ||
4391 | 111 | if decrement: | ||
4392 | 112 | self._number -= self._interval | ||
4393 | 113 | return self._number | ||
4394 | 114 | else: | ||
4395 | 115 | return self._number-self._interval | ||
4396 | 116 | |||
4397 | 117 | class AerooPrint(object): | ||
4398 | 118 | print_ids = [] # static property | ||
4399 | 119 | def __init__(self): | ||
4400 | 120 | print_id = False | ||
4401 | 121 | while(not print_id or print_id in self.print_ids): | ||
4402 | 122 | print_id = randint(1, 99999) | ||
4403 | 123 | self.print_ids.append(print_id) | ||
4404 | 124 | self.id = print_id | ||
4405 | 125 | self.subreports = [] | ||
4406 | 126 | self.epl_images = [] | ||
4407 | 127 | self.counters = {} | ||
4408 | 128 | self.start_time = 0 | ||
4409 | 129 | self.start_total_time = 0 | ||
4410 | 130 | |||
4411 | 131 | class Aeroo_report(report_sxw): | ||
4412 | 132 | |||
4413 | 133 | _logger = logging.getLogger(__name__) | ||
4414 | 134 | |||
4415 | 135 | def __init__(self, cr, name, table, rml=False, parser=False, header=True, store=False): | ||
4416 | 136 | super(Aeroo_report, self).__init__(name, table, rml, parser, header, store) | ||
4417 | 137 | self._logger.info("registering %s (%s)" % (name, table)) | ||
4418 | 138 | self.active_prints = {} | ||
4419 | 139 | self.oo_subreports = [] | ||
4420 | 140 | self.epl_images = [] | ||
4421 | 141 | self.counters = {} | ||
4422 | 142 | self.start_time = 0 | ||
4423 | 143 | |||
4424 | 144 | pool = pooler.get_pool(cr.dbname) | ||
4425 | 145 | ir_obj = pool.get('ir.actions.report.xml') | ||
4426 | 146 | name = name.startswith('report.') and name[7:] or name | ||
4427 | 147 | try: | ||
4428 | 148 | report_xml_ids = ir_obj.search(cr, SUPERUSER_ID, [('report_name', '=', name)]) | ||
4429 | 149 | if report_xml_ids: | ||
4430 | 150 | report_xml = ir_obj.browse(cr, SUPERUSER_ID, report_xml_ids[0]) | ||
4431 | 151 | else: | ||
4432 | 152 | report_xml = False | ||
4433 | 153 | |||
4434 | 154 | if report_xml and report_xml.preload_mode == 'preload': | ||
4435 | 155 | file_data = report_xml.report_sxw_content | ||
4436 | 156 | if not file_data: | ||
4437 | 157 | self._logger.warning("template is not defined in %s (%s) !" % (name, table)) | ||
4438 | 158 | template_io = None | ||
4439 | 159 | else: | ||
4440 | 160 | template_io = StringIO() | ||
4441 | 161 | template_io.write(base64.decodestring(file_data)) | ||
4442 | 162 | style_io=self.get_styles_file(cr, SUPERUSER_ID, report_xml) | ||
4443 | 163 | if template_io: | ||
4444 | 164 | self.serializer = OOSerializer(template_io, oo_styles=style_io) | ||
4445 | 165 | except Exception, e: | ||
4446 | 166 | print e | ||
4447 | 167 | |||
4448 | 168 | def getObjects_mod(self, cr, uid, ids, rep_type, context): | ||
4449 | 169 | table_obj = pooler.get_pool(cr.dbname).get(self.table) | ||
4450 | 170 | if rep_type=='aeroo': | ||
4451 | 171 | return table_obj.browse(cr, uid, ids, list_class=browse_record_list, context=context) | ||
4452 | 172 | return table_obj.browse(cr, uid, ids, list_class=browse_record_list, context=context) | ||
4453 | 173 | |||
4454 | 174 | ##### Counter functions ##### | ||
4455 | 175 | def _def_inc(self, aeroo_print): | ||
4456 | 176 | def def_inc(name, start=0, interval=1): | ||
4457 | 177 | aeroo_print.counters[name] = Counter(name, start, interval) | ||
4458 | 178 | return def_inc | ||
4459 | 179 | |||
4460 | 180 | def _get_inc(self, aeroo_print): | ||
4461 | 181 | def get_inc(name): | ||
4462 | 182 | return aeroo_print.counters[name].get_inc() | ||
4463 | 183 | return get_inc | ||
4464 | 184 | |||
4465 | 185 | def _prev(self, aeroo_print): | ||
4466 | 186 | def prev(name): | ||
4467 | 187 | return aeroo_print.counters[name].prev() | ||
4468 | 188 | return prev | ||
4469 | 189 | |||
4470 | 190 | def _next(self, aeroo_print): | ||
4471 | 191 | def next(name): | ||
4472 | 192 | return aeroo_print.counters[name].next() | ||
4473 | 193 | return next | ||
4474 | 194 | ############################# | ||
4475 | 195 | |||
4476 | 196 | def _epl_asimage(self, data, aeroo_print): | ||
4477 | 197 | from PIL import Image | ||
4478 | 198 | from math import ceil | ||
4479 | 199 | if not data: | ||
4480 | 200 | return '' | ||
4481 | 201 | img = Image.open(StringIO(base64.decodestring(data))) | ||
4482 | 202 | if img.format!='BMP': | ||
4483 | 203 | return '' | ||
4484 | 204 | data = base64.decodestring(data)[62:] | ||
4485 | 205 | line_len = int(ceil(img.size[0]/32.0)*4) | ||
4486 | 206 | temp_data = '' | ||
4487 | 207 | for n in range(img.size[1]): | ||
4488 | 208 | curr_pos = n*line_len | ||
4489 | 209 | temp_data = data[curr_pos:curr_pos+line_len][:int(img.size[0]/8)] + temp_data | ||
4490 | 210 | |||
4491 | 211 | new_data = '' | ||
4492 | 212 | for d in temp_data: | ||
4493 | 213 | new_data += chr(ord(d)^255) | ||
4494 | 214 | aeroo_print.epl_images.append(new_data) | ||
4495 | 215 | return img.size | ||
4496 | 216 | |||
4497 | 217 | def _epl2_gw(self, aeroo_print): | ||
4498 | 218 | def epl2_gw(start_x, start_y, data): | ||
4499 | 219 | if not data: | ||
4500 | 220 | return None | ||
4501 | 221 | size_x, size_y = self._epl_asimage(data, aeroo_print) | ||
4502 | 222 | return 'GW'+str(start_x)+','+str(start_y)+','+str(int(size_x/8))+','+str(size_y)+',<binary_data>' | ||
4503 | 223 | return epl2_gw | ||
4504 | 224 | |||
4505 | 225 | def _include_document(self, print_id, aeroo_ooo=False): | ||
4506 | 226 | def include_document(data, silent=False): | ||
4507 | 227 | if not aeroo_ooo: | ||
4508 | 228 | return _("Error! Include document not available!") | ||
4509 | 229 | import binascii, urllib2 | ||
4510 | 230 | temp_file = NamedTemporaryFile(suffix='.odt', prefix='aeroo-report-', delete=False) | ||
4511 | 231 | if os.path.isfile(data): | ||
4512 | 232 | fd = file(data, 'rb') | ||
4513 | 233 | data = fd.read() | ||
4514 | 234 | else: | ||
4515 | 235 | error = False | ||
4516 | 236 | try: | ||
4517 | 237 | url_file = urllib2.urlopen(data) | ||
4518 | 238 | data = url_file.read() | ||
4519 | 239 | except urllib2.HTTPError, e: | ||
4520 | 240 | os.unlink(temp_file.name) | ||
4521 | 241 | error = _('HTTP Error %s! File not found:') % e.getcode() + ' %s' % data | ||
4522 | 242 | except urllib2.URLError, e: | ||
4523 | 243 | os.unlink(temp_file.name) | ||
4524 | 244 | error = _('Error!')+' %s' % e | ||
4525 | 245 | except IOError, e: | ||
4526 | 246 | os.unlink(temp_file.name) | ||
4527 | 247 | error = _('Error!')+' %s' % e | ||
4528 | 248 | except Exception, e: | ||
4529 | 249 | try: | ||
4530 | 250 | data = base64.decodestring(data) | ||
4531 | 251 | except binascii.Error: | ||
4532 | 252 | os.unlink(temp_file.name) | ||
4533 | 253 | error = _('Error! File not found:')+' %s' % data | ||
4534 | 254 | if error: | ||
4535 | 255 | if not silent: | ||
4536 | 256 | return error | ||
4537 | 257 | else: | ||
4538 | 258 | return None | ||
4539 | 259 | try: | ||
4540 | 260 | temp_file.write(data) | ||
4541 | 261 | finally: | ||
4542 | 262 | temp_file.close() | ||
4543 | 263 | #self.oo_subreports[print_id].append(temp_file.name) | ||
4544 | 264 | self.active_prints[print_id].subreports.append(temp_file.name) | ||
4545 | 265 | return "<insert_doc('%s')>" % temp_file.name | ||
4546 | 266 | return include_document | ||
4547 | 267 | |||
4548 | 268 | def _subreport(self, cr, uid, aeroo_print, output='odt', aeroo_ooo=False, context={}): | ||
4549 | 269 | pool = pooler.get_pool(cr.dbname) | ||
4550 | 270 | ir_obj = pool.get('ir.actions.report.xml') | ||
4551 | 271 | #### for odt documents #### | ||
4552 | 272 | def odt_subreport(name=None, obj=None): | ||
4553 | 273 | if not aeroo_ooo: | ||
4554 | 274 | return _("Error! Subreports not available!") | ||
4555 | 275 | report_xml_ids = ir_obj.search(cr, uid, [('report_name', '=', name)], context=context) | ||
4556 | 276 | if report_xml_ids: | ||
4557 | 277 | service = netsvc.Service._services['report.%s' % name] | ||
4558 | 278 | report_xml = ir_obj.browse(cr, uid, report_xml_ids[0], context=context) | ||
4559 | 279 | data = {'model': obj._table_name, 'id': obj.id, 'report_type': 'aeroo', 'in_format': 'oo-odt'} | ||
4560 | 280 | ### Get new printing object ### | ||
4561 | 281 | sub_aeroo_print = AerooPrint() | ||
4562 | 282 | service.active_prints[sub_aeroo_print.id] = sub_aeroo_print | ||
4563 | 283 | context['print_id'] = sub_aeroo_print.id | ||
4564 | 284 | ############################### | ||
4565 | 285 | sub_aeroo_print.start_time = time.time() | ||
4566 | 286 | report, output = service.create_aeroo_report(cr, uid, \ | ||
4567 | 287 | [obj.id], data, report_xml, context=context, output='odt') # change for OpenERP 6.0 - Service class usage | ||
4568 | 288 | |||
4569 | 289 | ### Delete printing object ### | ||
4570 | 290 | AerooPrint.print_ids.remove(sub_aeroo_print.id) | ||
4571 | 291 | del service.active_prints[sub_aeroo_print.id] | ||
4572 | 292 | ############################## | ||
4573 | 293 | with NamedTemporaryFile(suffix='.odt', prefix='aeroo-report-', delete=False) as temp_file: | ||
4574 | 294 | temp_file.write(report) | ||
4575 | 295 | |||
4576 | 296 | #self.oo_subreports[print_id].append(temp_file.name) | ||
4577 | 297 | aeroo_print.subreports.append(temp_file.name) | ||
4578 | 298 | |||
4579 | 299 | return "<insert_doc('%s')>" % temp_file.name | ||
4580 | 300 | return None | ||
4581 | 301 | #### for text documents #### | ||
4582 | 302 | def raw_subreport(name=None, obj=None): | ||
4583 | 303 | report_xml_ids = ir_obj.search(cr, uid, [('report_name', '=', name)], context=context) | ||
4584 | 304 | if report_xml_ids: | ||
4585 | 305 | report_xml = ir_obj.browse(cr, uid, report_xml_ids[0], context=context) | ||
4586 | 306 | data = {'model': obj._table_name, 'id': obj.id, 'report_type': 'aeroo', 'in_format': 'genshi-raw'} | ||
4587 | 307 | report, output = netsvc.Service._services['report.%s' % name].create_genshi_raw_report(cr, uid, \ | ||
4588 | 308 | [obj.id], data, report_xml, context=context, output=output) # change for OpenERP 6.0 - Service class usage | ||
4589 | 309 | return report | ||
4590 | 310 | return None | ||
4591 | 311 | |||
4592 | 312 | if output=='odt': | ||
4593 | 313 | return odt_subreport | ||
4594 | 314 | elif output=='raw': | ||
4595 | 315 | return raw_subreport | ||
4596 | 316 | |||
4597 | 317 | def set_xml_data_fields(self, objects, parser): | ||
4598 | 318 | xml_data_fields = parser.localcontext.get('xml_data_fields', False) | ||
4599 | 319 | if xml_data_fields: | ||
4600 | 320 | for field in xml_data_fields: | ||
4601 | 321 | for o in objects: | ||
4602 | 322 | if getattr(o, field): | ||
4603 | 323 | xml_data = base64.decodestring(getattr(o, field)) | ||
4604 | 324 | xmldoc = minidom.parseString(xml_data) | ||
4605 | 325 | setattr(o, field, xmldoc.firstChild) | ||
4606 | 326 | return objects | ||
4607 | 327 | |||
4608 | 328 | def get_other_template(self, cr, uid, data, parser): | ||
4609 | 329 | if hasattr(parser, 'get_template'): | ||
4610 | 330 | pool = pooler.get_pool(cr.dbname) | ||
4611 | 331 | record = pool.get(data['model']).browse(cr, uid, data['id'], {}) | ||
4612 | 332 | template = parser.get_template(cr, uid, record) | ||
4613 | 333 | return template | ||
4614 | 334 | else: | ||
4615 | 335 | return False | ||
4616 | 336 | |||
4617 | 337 | def get_styles_file(self, cr, uid, report_xml, company=None, context=None): | ||
4618 | 338 | pool = pooler.get_pool(cr.dbname) | ||
4619 | 339 | style_io=None | ||
4620 | 340 | if report_xml.styles_mode!='default': | ||
4621 | 341 | if report_xml.styles_mode=='global': | ||
4622 | 342 | company_id = company or pool.get('res.users')._get_company(cr, uid, context=context) | ||
4623 | 343 | style_content = pool.get('res.company').browse(cr, uid, company_id, context=context).stylesheet_id | ||
4624 | 344 | style_content = style_content and style_content.report_styles or False | ||
4625 | 345 | elif report_xml.styles_mode=='specified': | ||
4626 | 346 | style_content = report_xml.stylesheet_id | ||
4627 | 347 | style_content = style_content and style_content.report_styles or False | ||
4628 | 348 | if style_content: | ||
4629 | 349 | style_io = StringIO() | ||
4630 | 350 | style_io.write(base64.decodestring(style_content)) | ||
4631 | 351 | return style_io | ||
4632 | 352 | |||
4633 | 353 | def create_genshi_raw_report(self, cr, uid, ids, data, report_xml, context=None, output='raw', tmpl=False): | ||
4634 | 354 | def preprocess(data, aeroo_print): | ||
4635 | 355 | aeroo_print.epl_images.reverse() | ||
4636 | 356 | while aeroo_print.epl_images: | ||
4637 | 357 | img = aeroo_print.epl_images.pop() | ||
4638 | 358 | data = data.replace('<binary_data>', img, 1) | ||
4639 | 359 | return data.replace('\n', '\r\n') | ||
4640 | 360 | |||
4641 | 361 | print_id = context.get('print_id', False) | ||
4642 | 362 | aeroo_print = self.active_prints[print_id] # Aeroo print object | ||
4643 | 363 | if not aeroo_print.start_time: | ||
4644 | 364 | aeroo_print.start_time = time.time() | ||
4645 | 365 | if not context: | ||
4646 | 366 | context={} | ||
4647 | 367 | context = context.copy() | ||
4648 | 368 | objects = self.getObjects_mod(cr, uid, ids, report_xml.report_type, context) | ||
4649 | 369 | oo_parser = self.parser(cr, uid, self.name2, context=context) | ||
4650 | 370 | oo_parser.localcontext.update(context) | ||
4651 | 371 | oo_parser.set_context(objects, data, ids, report_xml.report_type) | ||
4652 | 372 | self.set_xml_data_fields(oo_parser.objects, oo_parser) # Get/Set XML | ||
4653 | 373 | oo_parser.localcontext['data'] = data | ||
4654 | 374 | oo_parser.localcontext['user_lang'] = context.get('lang', False) | ||
4655 | 375 | if len(objects)>0: | ||
4656 | 376 | oo_parser.localcontext['o'] = objects[0] | ||
4657 | 377 | xfunc = ExtraFunctions(cr, uid, report_xml.id, oo_parser.localcontext) | ||
4658 | 378 | oo_parser.localcontext.update(xfunc.functions) | ||
4659 | 379 | file_data = tmpl or self.get_other_template(cr, uid, data, oo_parser) or report_xml.report_sxw_content # Get other Tamplate | ||
4660 | 380 | if not file_data or file_data=='False': | ||
4661 | 381 | raise orm.except_orm(_('Error!'), _('No template found!')) | ||
4662 | 382 | ################################################ | ||
4663 | 383 | if not file_data: | ||
4664 | 384 | self._logger.info("End process %s (%s), elapsed time: %s" % (self.name, self.table, time.time() - aeroo_print.start_time)) # debug mode | ||
4665 | 385 | return False, output | ||
4666 | 386 | |||
4667 | 387 | print_id = context.get('print_id', False) | ||
4668 | 388 | aeroo_print = self.active_prints[print_id] | ||
4669 | 389 | |||
4670 | 390 | oo_parser.localcontext['include_subreport'] = self._subreport(cr, uid, aeroo_print, output='raw', aeroo_ooo=False, context=context) | ||
4671 | 391 | oo_parser.localcontext['epl2_gw'] = self._epl2_gw(aeroo_print) | ||
4672 | 392 | deferred = context.get('deferred_process') | ||
4673 | 393 | oo_parser.localcontext['progress_update'] = deferred and deferred.progress_update or (lambda:True) | ||
4674 | 394 | |||
4675 | 395 | aeroo_print.epl_images = [] | ||
4676 | 396 | basic = NewTextTemplate(source=base64.decodestring(file_data)) | ||
4677 | 397 | if genshi_version<='0.6': | ||
4678 | 398 | data = preprocess(basic.generate(**oo_parser.localcontext).render().decode('utf8').encode(report_xml.charset), aeroo_print) | ||
4679 | 399 | else: | ||
4680 | 400 | data = preprocess(basic.generate(**oo_parser.localcontext).render().encode(report_xml.charset), aeroo_print) | ||
4681 | 401 | |||
4682 | 402 | if report_xml.content_fname: | ||
4683 | 403 | output = report_xml.content_fname | ||
4684 | 404 | self._logger.info("End process %s (%s), elapsed time: %s" % (self.name, self.table, time.time() - aeroo_print.start_time)) # debug mode | ||
4685 | 405 | return data, output | ||
4686 | 406 | |||
4687 | 407 | def _generate_doc(self, DC, data, report_xml, print_id): | ||
4688 | 408 | with aeroo_lock: | ||
4689 | 409 | DC.putDocument(data) | ||
4690 | 410 | #subreports = self.oo_subreports.get(print_id) | ||
4691 | 411 | aeroo_print = self.active_prints.get(print_id, False) | ||
4692 | 412 | if aeroo_print: | ||
4693 | 413 | DC.insertSubreports(aeroo_print.subreports) | ||
4694 | 414 | #self.oo_subreports = [] | ||
4695 | 415 | #del self.oo_subreports[print_id] | ||
4696 | 416 | if report_xml.out_format.code=='oo-dbf': | ||
4697 | 417 | data = DC.saveByStream(report_xml.out_format.filter_name, "78") | ||
4698 | 418 | else: | ||
4699 | 419 | data = DC.saveByStream(report_xml.out_format.filter_name) | ||
4700 | 420 | DC.closeDocument() | ||
4701 | 421 | return data | ||
4702 | 422 | |||
4703 | 423 | def _raise_exception(self, e, print_id): | ||
4704 | 424 | tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) | ||
4705 | 425 | self._logger.error(_("Report generation error!")+'\n'+tb_s) | ||
4706 | 426 | #subreports = self.oo_subreports.get(print_id, []) | ||
4707 | 427 | aeroo_print = self.active_prints.get(print_id, []) | ||
4708 | 428 | if aeroo_print: | ||
4709 | 429 | for sub_report in aeroo_print.subreports: | ||
4710 | 430 | if os.path.isfile(sub_report): | ||
4711 | 431 | os.unlink(sub_report) | ||
4712 | 432 | raise Exception(_("Aeroo Reports: Error while generating the report."), e, str(e), _("For more reference inspect error logs.")) | ||
4713 | 433 | |||
4714 | 434 | def create_aeroo_report(self, cr, uid, ids, data, report_xml, context=None, output='odt'): | ||
4715 | 435 | """ Returns an aeroo report generated with aeroolib | ||
4716 | 436 | """ | ||
4717 | 437 | pool = pooler.get_pool(cr.dbname) | ||
4718 | 438 | if not context: | ||
4719 | 439 | context={} | ||
4720 | 440 | context = context.copy() | ||
4721 | 441 | if self.name=='report.printscreen.list': | ||
4722 | 442 | context['model'] = data['model'] | ||
4723 | 443 | context['ids'] = ids | ||
4724 | 444 | |||
4725 | 445 | print_id = context.get('print_id', False) | ||
4726 | 446 | aeroo_print = self.active_prints[print_id] # Aeroo print object | ||
4727 | 447 | aeroo_print.subreports = [] | ||
4728 | 448 | #self.oo_subreports[print_id] = [] | ||
4729 | 449 | objects = self.getObjects_mod(cr, uid, ids, report_xml.report_type, context) or [] | ||
4730 | 450 | oo_parser = self.parser(cr, uid, self.name2, context=context) | ||
4731 | 451 | oo_parser.localcontext.update(context) | ||
4732 | 452 | oo_parser.set_context(objects, data, ids, report_xml.report_type) | ||
4733 | 453 | self.set_xml_data_fields(objects, oo_parser) # Get/Set XML | ||
4734 | 454 | |||
4735 | 455 | oo_parser.localcontext['data'] = data | ||
4736 | 456 | oo_parser.localcontext['user_lang'] = context.get('lang', False) | ||
4737 | 457 | if len(objects)>0: | ||
4738 | 458 | oo_parser.localcontext['o'] = objects[0] | ||
4739 | 459 | xfunc = ExtraFunctions(cr, uid, report_xml.id, oo_parser.localcontext) | ||
4740 | 460 | oo_parser.localcontext.update(xfunc.functions) | ||
4741 | 461 | |||
4742 | 462 | #company_id = objects and 'company_id' in objects[0]._table._columns.keys() and \ | ||
4743 | 463 | # objects[0].company_id and objects[0].company_id.id or False # for object company usage | ||
4744 | 464 | company_id = False | ||
4745 | 465 | style_io=self.get_styles_file(cr, uid, report_xml, company=company_id, context=context) | ||
4746 | 466 | |||
4747 | 467 | if report_xml.tml_source in ('file', 'database'): | ||
4748 | 468 | if not report_xml.report_sxw_content or report_xml.report_sxw_content=='False': | ||
4749 | 469 | raise orm.except_orm(_('Error!'), _('No template found!')) | ||
4750 | 470 | file_data = base64.decodestring(report_xml.report_sxw_content) | ||
4751 | 471 | else: | ||
4752 | 472 | file_data = self.get_other_template(cr, uid, data, oo_parser) | ||
4753 | 473 | if not file_data and not report_xml.report_sxw_content: | ||
4754 | 474 | self._logger.info("End process %s (%s), elapsed time: %s" % (self.name, self.table, time.time() - aeroo_print.start_time)) # debug mode | ||
4755 | 475 | return False, output | ||
4756 | 476 | #elif file_data: | ||
4757 | 477 | # template_io = StringIO() | ||
4758 | 478 | # template_io.write(file_data or report_xml.report_sxw_content) | ||
4759 | 479 | # basic = Template(source=template_io, styles=style_io) | ||
4760 | 480 | else: | ||
4761 | 481 | if report_xml.preload_mode == 'preload' and hasattr(self, 'serializer'): | ||
4762 | 482 | serializer = copy.copy(self.serializer) | ||
4763 | 483 | serializer.apply_style(style_io) | ||
4764 | 484 | template_io = serializer.template | ||
4765 | 485 | else: | ||
4766 | 486 | template_io = StringIO() | ||
4767 | 487 | template_io.write(file_data or base64.decodestring(report_xml.report_sxw_content) ) | ||
4768 | 488 | serializer = OOSerializer(template_io, oo_styles=style_io) | ||
4769 | 489 | try: | ||
4770 | 490 | basic = Template(source=template_io, serializer=serializer) | ||
4771 | 491 | except Exception, e: | ||
4772 | 492 | self._raise_exception(e, print_id) | ||
4773 | 493 | |||
4774 | 494 | #if not file_data: | ||
4775 | 495 | # return False, output | ||
4776 | 496 | |||
4777 | 497 | #basic = Template(source=template_io, serializer=serializer) | ||
4778 | 498 | |||
4779 | 499 | aeroo_ooo = context.get('aeroo_ooo', False) | ||
4780 | 500 | oo_parser.localcontext['include_subreport'] = self._subreport(cr, uid, aeroo_print, output='odt', aeroo_ooo=aeroo_ooo, context=context) | ||
4781 | 501 | oo_parser.localcontext['include_document'] = self._include_document(aeroo_ooo, print_id) | ||
4782 | 502 | deferred = context.get('deferred_process') | ||
4783 | 503 | oo_parser.localcontext['progress_update'] = deferred and deferred.progress_update or (lambda:True) | ||
4784 | 504 | ####### Add counter functons to localcontext ####### | ||
4785 | 505 | oo_parser.localcontext.update({'def_inc':self._def_inc(aeroo_print), | ||
4786 | 506 | 'get_inc':self._get_inc(aeroo_print), | ||
4787 | 507 | 'prev':self._prev(aeroo_print), | ||
4788 | 508 | 'next':self._next(aeroo_print)}) | ||
4789 | 509 | |||
4790 | 510 | user_name = pool.get('res.users').browse(cr, uid, uid, {}).name | ||
4791 | 511 | model_id = pool.get('ir.model').search(cr, uid, [('model','=',context.get('active_model', data['model']) or data['model'])])[0] | ||
4792 | 512 | model_name = pool.get('ir.model').browse(cr, uid, model_id).name | ||
4793 | 513 | |||
4794 | 514 | #basic = Template(source=None, filepath=odt_path) | ||
4795 | 515 | |||
4796 | 516 | basic.Serializer.add_title(model_name) | ||
4797 | 517 | basic.Serializer.add_creation_user(user_name) | ||
4798 | 518 | module_info = load_information_from_description_file('report_aeroo') | ||
4799 | 519 | version = module_info['version'] | ||
4800 | 520 | basic.Serializer.add_generator_info('Aeroo Lib/%s Aeroo Reports/%s' % (aeroolib.__version__, version)) | ||
4801 | 521 | basic.Serializer.add_custom_property('Aeroo Reports %s' % version, 'Generator') | ||
4802 | 522 | basic.Serializer.add_custom_property('OpenERP %s' % release.version, 'Software') | ||
4803 | 523 | basic.Serializer.add_custom_property(module_info['website'], 'URL') | ||
4804 | 524 | basic.Serializer.add_creation_date(time.strftime('%Y-%m-%dT%H:%M:%S')) | ||
4805 | 525 | |||
4806 | 526 | try: | ||
4807 | 527 | data = basic.generate(**oo_parser.localcontext).render().getvalue() | ||
4808 | 528 | except orm.except_orm, e: | ||
4809 | 529 | raise | ||
4810 | 530 | except Exception, e: | ||
4811 | 531 | self._raise_exception(e, print_id) | ||
4812 | 532 | |||
4813 | 533 | ######### OpenOffice extras ######### | ||
4814 | 534 | DC = netsvc.Service._services.get('openoffice') | ||
4815 | 535 | if output!=report_xml.in_format[3:] or aeroo_print.subreports: | ||
4816 | 536 | if aeroo_ooo and DC: | ||
4817 | 537 | try: | ||
4818 | 538 | data = self._generate_doc(DC, data, report_xml, print_id) | ||
4819 | 539 | except Exception, e: | ||
4820 | 540 | self._logger.error(_("OpenOffice.org related error!")+'\n'+str(e)) | ||
4821 | 541 | if DC._restart_ooo(): | ||
4822 | 542 | # We try again | ||
4823 | 543 | try: | ||
4824 | 544 | data = self._generate_doc(DC, data, report_xml, print_id) | ||
4825 | 545 | except Exception, e: | ||
4826 | 546 | self._logger.error(_("OpenOffice.org related error!")+'\n'+str(e)) | ||
4827 | 547 | if not report_xml.fallback_false: | ||
4828 | 548 | output=report_xml.in_format[3:] | ||
4829 | 549 | elif not report_xml.fallback_false: | ||
4830 | 550 | output=report_xml.in_format[3:] | ||
4831 | 551 | aeroo_print.subreports = [] | ||
4832 | 552 | else: | ||
4833 | 553 | if report_xml.fallback_false: | ||
4834 | 554 | if not aeroo_ooo: | ||
4835 | 555 | raise orm.except_orm(_('OpenOffice.org related error!'), _('Module "report_aeroo_ooo" not installed.')) | ||
4836 | 556 | elif not DC: | ||
4837 | 557 | raise orm.except_orm(_('OpenOffice.org related error!'), _('Can not connect to OpenOffice.org.')) | ||
4838 | 558 | else: | ||
4839 | 559 | self._logger.warning("PDF generator temporarily offline, please wait a minute") | ||
4840 | 560 | output=report_xml.in_format[3:] | ||
4841 | 561 | elif output in ('pdf', 'doc', 'xls'): | ||
4842 | 562 | output=report_xml.in_format[3:] | ||
4843 | 563 | ##################################### | ||
4844 | 564 | |||
4845 | 565 | if report_xml.content_fname: | ||
4846 | 566 | output = report_xml.content_fname | ||
4847 | 567 | self._logger.info("End process %s (%s), elapsed time: %s" % (self.name, self.table, time.time() - aeroo_print.start_time)) | ||
4848 | 568 | return data, output | ||
4849 | 569 | |||
4850 | 570 | # override needed to keep the attachments' storing procedure | ||
4851 | 571 | def create_single_pdf(self, cr, uid, ids, data, report_xml, context=None): | ||
4852 | 572 | if not context: | ||
4853 | 573 | context={} | ||
4854 | 574 | if report_xml.report_type == 'aeroo': | ||
4855 | 575 | if report_xml.out_format.code.startswith('oo-'): | ||
4856 | 576 | output = report_xml.out_format.code[3:] | ||
4857 | 577 | return self.create_aeroo_report(cr, uid, ids, data, report_xml, context=context, output=output) | ||
4858 | 578 | elif report_xml.out_format.code =='genshi-raw': | ||
4859 | 579 | return self.create_genshi_raw_report(cr, uid, ids, data, report_xml, context=context, output='raw') | ||
4860 | 580 | logo = None | ||
4861 | 581 | context = context.copy() | ||
4862 | 582 | title = report_xml.name | ||
4863 | 583 | rml = report_xml.report_rml_content | ||
4864 | 584 | oo_parser = self.parser(cr, uid, self.name2, context=context) | ||
4865 | 585 | objs = self.getObjects_mod(cr, uid, ids, report_xml.report_type, context) | ||
4866 | 586 | oo_parser.set_context(objs, data, ids, report_xml.report_type) | ||
4867 | 587 | processed_rml = self.preprocess_rml(etree.XML(rml),report_xml.report_type) | ||
4868 | 588 | if report_xml.header: | ||
4869 | 589 | oo_parser._add_header(processed_rml) | ||
4870 | 590 | if oo_parser.logo: | ||
4871 | 591 | logo = base64.decodestring(oo_parser.logo) | ||
4872 | 592 | create_doc = self.generators[report_xml.report_type] | ||
4873 | 593 | pdf = create_doc(etree.tostring(processed_rml),oo_parser.localcontext,logo,title.encode('utf8')) | ||
4874 | 594 | return (pdf, report_xml.report_type) | ||
4875 | 595 | |||
4876 | 596 | def _get_attachment_create_vals(self, cr, uid, report_xml, vals, context=None): | ||
4877 | 597 | if context is None: | ||
4878 | 598 | context = {} | ||
4879 | 599 | pool = pooler.get_pool(cr.dbname) | ||
4880 | 600 | report_obj = pool.get('ir.actions.report.xml') | ||
4881 | 601 | vals = report_obj._get_attachment_create_vals(cr, uid, report_xml, vals, context=context) | ||
4882 | 602 | return vals | ||
4883 | 603 | |||
4884 | 604 | def create_source_pdf(self, cr, uid, ids, data, report_xml, context=None): | ||
4885 | 605 | if not context: | ||
4886 | 606 | context={} | ||
4887 | 607 | pool = pooler.get_pool(cr.dbname) | ||
4888 | 608 | attach = report_xml.attachment | ||
4889 | 609 | aeroo_ooo = _aeroo_ooo_test(cr) # Detect report_aeroo_ooo module | ||
4890 | 610 | context['aeroo_ooo'] = aeroo_ooo | ||
4891 | 611 | print_id = context.get('print_id', False) | ||
4892 | 612 | aeroo_print = self.active_prints[print_id] # Aeroo print object | ||
4893 | 613 | if attach or aeroo_ooo and report_xml.process_sep: | ||
4894 | 614 | objs = self.getObjects_mod(cr, uid, ids, report_xml.report_type, context) | ||
4895 | 615 | deferred = context.get('deferred_process') | ||
4896 | 616 | results = [] | ||
4897 | 617 | for obj in objs: | ||
4898 | 618 | aeroo_print.start_time = time.time() | ||
4899 | 619 | if deferred: | ||
4900 | 620 | deferred.progress_update() | ||
4901 | 621 | aname = attach and eval(attach, {'object':obj, 'time':time}) or False | ||
4902 | 622 | result = False | ||
4903 | 623 | if report_xml.attachment_use and aname and context.get('attachment_use', True): | ||
4904 | 624 | #aids = pool.get('ir.attachment').search(cr, uid, [('datas_fname','=',aname+'.pdf'),('res_model','=',self.table),('res_id','=',obj.id)]) | ||
4905 | 625 | #if aids: | ||
4906 | 626 | # brow_rec = pool.get('ir.attachment').browse(cr, uid, aids[0]) | ||
4907 | 627 | # if not brow_rec.datas: | ||
4908 | 628 | # continue | ||
4909 | 629 | # d = base64.decodestring(brow_rec.datas) | ||
4910 | 630 | # results.append((d,'pdf')) | ||
4911 | 631 | # continue | ||
4912 | 632 | cr.execute("SELECT id, datas_fname FROM ir_attachment WHERE datas_fname ilike %s and res_model=%s and res_id=%s LIMIT 1", (aname+'.%',self.table,obj.id)) | ||
4913 | 633 | search_res = cr.dictfetchone() | ||
4914 | 634 | if search_res: | ||
4915 | 635 | brow_rec = pool.get('ir.attachment').browse(cr, uid, search_res['id']) | ||
4916 | 636 | if not brow_rec.datas: | ||
4917 | 637 | continue | ||
4918 | 638 | d = base64.decodestring(brow_rec.datas) | ||
4919 | 639 | extension = search_res['datas_fname'].split('.')[1] | ||
4920 | 640 | results.append((d,extension)) | ||
4921 | 641 | continue | ||
4922 | 642 | result = self.create_single_pdf(cr, uid, [obj.id], data, report_xml, context) | ||
4923 | 643 | if not result: | ||
4924 | 644 | return False | ||
4925 | 645 | try: | ||
4926 | 646 | if attach and aname: | ||
4927 | 647 | name = aname+'.'+result[1] | ||
4928 | 648 | datas = base64.encodestring(result[0]) | ||
4929 | 649 | ctx = dict(context) | ||
4930 | 650 | ctx.pop('default_type', None) | ||
4931 | 651 | vals = { | ||
4932 | 652 | 'name': aname, | ||
4933 | 653 | 'datas': datas, | ||
4934 | 654 | 'file_size': len(datas), | ||
4935 | 655 | 'datas_fname': name, | ||
4936 | 656 | 'res_model': self.table, | ||
4937 | 657 | 'res_id': obj.id, | ||
4938 | 658 | 'type': 'binary', | ||
4939 | 659 | } | ||
4940 | 660 | attachment_vals = self._get_attachment_create_vals( | ||
4941 | 661 | cr, uid, report_xml, vals, context=ctx) | ||
4942 | 662 | pool.get('ir.attachment').create(cr, uid, attachment_vals, context=ctx) | ||
4943 | 663 | cr.commit() | ||
4944 | 664 | except Exception,e: | ||
4945 | 665 | tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) | ||
4946 | 666 | self._logger.error(str(e)) | ||
4947 | 667 | results.append(result) | ||
4948 | 668 | if results and len(results)==1: | ||
4949 | 669 | return results[0] | ||
4950 | 670 | if results: | ||
4951 | 671 | not_pdf = filter(lambda r: r[1]!='pdf', results) | ||
4952 | 672 | if not_pdf: | ||
4953 | 673 | raise orm.except_orm(_('Error!'), _('Unsupported combination of formats!')) | ||
4954 | 674 | #if results[0][1]=='pdf': | ||
4955 | 675 | output = PdfFileWriter() | ||
4956 | 676 | for r in results: | ||
4957 | 677 | reader = PdfFileReader(StringIO(r[0])) | ||
4958 | 678 | for page in range(reader.getNumPages()): | ||
4959 | 679 | output.addPage(reader.getPage(page)) | ||
4960 | 680 | s = StringIO() | ||
4961 | 681 | output.write(s) | ||
4962 | 682 | return s.getvalue(), results[0][1] | ||
4963 | 683 | return self.create_single_pdf(cr, uid, ids, data, report_xml, context) | ||
4964 | 684 | |||
4965 | 685 | def create_source_odt(self, cr, uid, ids, data, report_xml, context=None): | ||
4966 | 686 | if not context: | ||
4967 | 687 | context={} | ||
4968 | 688 | pool = pooler.get_pool(cr.dbname) | ||
4969 | 689 | results = [] | ||
4970 | 690 | attach = report_xml.attachment | ||
4971 | 691 | aeroo_ooo = _aeroo_ooo_test(cr) # Detect report_aeroo_ooo module | ||
4972 | 692 | context['aeroo_ooo'] = aeroo_ooo | ||
4973 | 693 | print_id = context.get('print_id', False) | ||
4974 | 694 | aeroo_print = self.active_prints[print_id] # Aeroo print object | ||
4975 | 695 | if attach or aeroo_ooo and report_xml.process_sep: | ||
4976 | 696 | objs = self.getObjects_mod(cr, uid, ids, report_xml.report_type, context) | ||
4977 | 697 | deferred = context.get('deferred_process') | ||
4978 | 698 | for obj in objs: | ||
4979 | 699 | aeroo_print.start_time = time.time() | ||
4980 | 700 | if deferred: | ||
4981 | 701 | deferred.progress_update() | ||
4982 | 702 | aname = attach and eval(attach, {'object':obj, 'time':time}) or False | ||
4983 | 703 | result = False | ||
4984 | 704 | if report_xml.attachment_use and aname and context.get('attachment_use', True): | ||
4985 | 705 | #aids = pool.get('ir.attachment').search(cr, uid, [('datas_fname','=',aname+'.odt'),('res_model','=',self.table),('res_id','=',obj.id)]) | ||
4986 | 706 | #if aids: | ||
4987 | 707 | # brow_rec = pool.get('ir.attachment').browse(cr, uid, aids[0]) | ||
4988 | 708 | # if not brow_rec.datas: | ||
4989 | 709 | # continue | ||
4990 | 710 | # d = base64.decodestring(brow_rec.datas) | ||
4991 | 711 | # results.append((d,'odt')) | ||
4992 | 712 | # continue | ||
4993 | 713 | cr.execute("SELECT id, datas_fname FROM ir_attachment WHERE datas_fname ilike %s and res_model=%s and res_id=%s LIMIT 1", (aname+'.%',self.table,obj.id)) | ||
4994 | 714 | search_res = cr.dictfetchone() | ||
4995 | 715 | if search_res: | ||
4996 | 716 | brow_rec = pool.get('ir.attachment').browse(cr, uid, search_res['id']) | ||
4997 | 717 | if not brow_rec.datas: | ||
4998 | 718 | continue | ||
4999 | 719 | d = base64.decodestring(brow_rec.datas) | ||
5000 | 720 | extension = search_res['datas_fname'].split('.')[1] |