Merge lp:~s-momin-serpentcs/account-fstr/account-fstr into lp:account-fstr/6.0
- account-fstr
- Merge into trunk
Proposed by
Serpent Consulting Services
Status: | Needs review |
---|---|
Proposed branch: | lp:~s-momin-serpentcs/account-fstr/account-fstr |
Merge into: | lp:account-fstr/6.0 |
Diff against target: |
1151 lines (+1064/-0) (has conflicts) 16 files modified
account_fstr/__init__.py (+26/-0) account_fstr/__openerp__.py (+49/-0) account_fstr/account_account.py (+63/-0) account_fstr/account_account_view.xml (+23/-0) account_fstr/account_fstr_category.py (+178/-0) account_fstr/account_fstr_menu.xml (+31/-0) account_fstr/account_fstr_report.xml (+15/-0) account_fstr/account_fstr_view.xml (+154/-0) account_fstr/account_fstr_wizard_view.xml (+42/-0) account_fstr/reports/__init__.py (+20/-0) account_fstr/reports/account_fstr_report.py (+171/-0) account_fstr/reports/account_fstr_report.rml (+134/-0) account_fstr/reports/sm_kit.py (+10/-0) account_fstr/security/ir.model.access.csv (+2/-0) account_fstr/wizard/__init__.py (+20/-0) account_fstr/wizard/account_fstr_wizard.py (+126/-0) Conflict adding file account_fstr. Moved existing file to account_fstr.moved. |
To merge this branch: | bzr merge lp:~s-momin-serpentcs/account-fstr/account-fstr |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Enapps Committers | Pending | ||
Review via email: mp+153174@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
- 2. By sirajahmad
-
[IMP] account_fstr: Added a state field in form view, added a constraints on parent_node field
Unmerged revisions
- 2. By sirajahmad
-
[IMP] account_fstr: Added a state field in form view, added a constraints on parent_node field
- 1. By sirajahmad
-
[mod]modify module account_fstr from 6.1 to 7.0
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory 'account_fstr' |
2 | === renamed directory 'account_fstr' => 'account_fstr.moved' |
3 | === added file 'account_fstr/__init__.py' |
4 | --- account_fstr/__init__.py 1970-01-01 00:00:00 +0000 |
5 | +++ account_fstr/__init__.py 2013-04-02 11:54:22 +0000 |
6 | @@ -0,0 +1,26 @@ |
7 | +# -*- encoding: utf-8 -*- |
8 | +############################################################################## |
9 | +# |
10 | +# OpenERP, Open Source Management Solution |
11 | +# Copyright (C) |
12 | +# 2010 Colin MacMillan - Publicus Solutions Ltd. |
13 | +# All Rights Reserved |
14 | +# |
15 | +# This program is free software: you can redistribute it and/or modify |
16 | +# it under the terms of the GNU Affero General Public License as |
17 | +# published by the Free Software Foundation, either version 3 of the |
18 | +# License, or (at your option) any later version. |
19 | +# |
20 | +# This program is distributed in the hope that it will be useful, |
21 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
22 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23 | +# GNU Affero General Public License for more details. |
24 | +# |
25 | +# You should have received a copy of the GNU Affero General Public License |
26 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
27 | +# |
28 | +############################################################################## |
29 | +import account_fstr_category |
30 | +import wizard |
31 | +import reports |
32 | +import account_account |
33 | |
34 | === added file 'account_fstr/__openerp__.py' |
35 | --- account_fstr/__openerp__.py 1970-01-01 00:00:00 +0000 |
36 | +++ account_fstr/__openerp__.py 2013-04-02 11:54:22 +0000 |
37 | @@ -0,0 +1,49 @@ |
38 | +# -*- encoding: utf-8 -*- |
39 | +############################################################################## |
40 | +# |
41 | +# OpenERP, Open Source Management Solution |
42 | +# Copyright (C) |
43 | +# 2011 Colin MacMillan - Enapps Ltd. |
44 | +# All Rights Reserved |
45 | +# |
46 | +# This program is free software: you can redistribute it and/or modify |
47 | +# it under the terms of the GNU Affero General Public License as |
48 | +# published by the Free Software Foundation, either version 3 of the |
49 | +# License, or (at your option) any later version. |
50 | +# |
51 | +# This program is distributed in the hope that it will be useful, |
52 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
53 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
54 | +# GNU Affero General Public License for more details. |
55 | +# |
56 | +# You should have received a copy of the GNU Affero General Public License |
57 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
58 | +# |
59 | +############################################################################## |
60 | + |
61 | +{ |
62 | + 'name' : 'Financial Statement Template reporting module', |
63 | + 'version' : '1.1', |
64 | + 'depends' : ['base', 'account'], |
65 | + 'author' : 'Enapps Ltd.', |
66 | + 'description': '''This module provides functionality to create customised financial statements. Examples of a financial statement would be a trial balance, balance sheet, profit and loss, etc. Any report that is produced by organising sets of accounts can be created using this module. |
67 | + |
68 | +User documentation can be found here - www.publicus-solutions.com/blog/post1 |
69 | + |
70 | +Compatible with OpenERP v. 6.0,6.1 and 7.0 |
71 | + |
72 | +''', |
73 | + 'website' : 'http://www.enapps.co.uk/', |
74 | + "category": 'Accounting & Finance', |
75 | + 'demo' : [], |
76 | + 'data' : [ |
77 | + 'security/ir.model.access.csv', |
78 | + 'account_fstr_wizard_view.xml', |
79 | + 'account_fstr_view.xml', |
80 | + 'account_fstr_menu.xml', |
81 | + 'account_account_view.xml', |
82 | + ], |
83 | + 'active': False, |
84 | + 'installable': True, |
85 | + 'images': ['images/fstr_form.png',], |
86 | +} |
87 | |
88 | === added file 'account_fstr/account_account.py' |
89 | --- account_fstr/account_account.py 1970-01-01 00:00:00 +0000 |
90 | +++ account_fstr/account_account.py 2013-04-02 11:54:22 +0000 |
91 | @@ -0,0 +1,63 @@ |
92 | +# -*- coding: utf-8 -*- |
93 | +############################################################################## |
94 | +# |
95 | +# Copyright (C) 2011 Enapps LTD (<http://www.enapps.co.uk>). |
96 | +# |
97 | +# This program is free software: you can redistribute it and/or modify |
98 | +# it under the terms of the GNU Affero General Public License as |
99 | +# published by the Free Software Foundation, either version 3 of the |
100 | +# License, or (at your option) any later version. |
101 | +# |
102 | +# This program is distributed in the hope that it will be useful, |
103 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
104 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
105 | +# GNU Affero General Public License for more details. |
106 | +# |
107 | +# You should have received a copy of the GNU Affero General Public License |
108 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
109 | +# |
110 | +############################################################################## |
111 | +from openerp.osv import fields, osv |
112 | +from openerp.tools.translate import _ |
113 | +from openerp import netsvc |
114 | +import time |
115 | +from openerp.addons.decimal_precision import decimal_precision as dp |
116 | + |
117 | +class account_account(osv.osv): |
118 | + _name = "account.account" |
119 | + _inherit = "account.account" |
120 | + |
121 | + _columns = { |
122 | + 'category_ids': fields.many2many('account_fstr.category', 'account_fstr_category_account', 'category_id', 'account_id', 'Categories'), |
123 | + } |
124 | + |
125 | + def test_category_list(self, cr, uid, ids, category_ids, context={}): |
126 | + category_ids = category_ids[0][2] |
127 | + warning = {} |
128 | + warning_category_names = [] |
129 | + category_pool = self.pool.get('account_fstr.category') |
130 | + for account in self.browse(cr, uid, ids, context=context): |
131 | + progenitors = [ctgry.progenitor_id.id for ctgry in account.category_ids] |
132 | + current_category_ids = [ctgry.id for ctgry in account.category_ids] |
133 | + new_categories = list(set(category_ids) - set(current_category_ids)) |
134 | + new_categories_objs = category_pool.browse(cr, uid, new_categories, context=context) |
135 | + if len(new_categories_objs) > len(set([ctgry.progenitor_id.id for ctgry in new_categories_objs])): |
136 | + warning.update({ |
137 | + 'title': 'Alert', |
138 | + 'message': "You cant add one account to more than one category within the same repoting template", |
139 | + }) |
140 | + return {'value': {'category_ids': current_category_ids}, 'warning': warning} |
141 | + for category in new_categories_objs: |
142 | + if category.progenitor_id.id in progenitors: |
143 | + warning_category_names.append("%s / %s " % (category.progenitor_id.name, category.name)) |
144 | + category_ids.remove(category.id) |
145 | + if warning_category_names: |
146 | + warning.update({ |
147 | + 'title': 'Alert', |
148 | + 'message': "Categories %s already exist for current account" % (", ".join(warning_category_names)), |
149 | + }) |
150 | + return {'value': {'category_ids': category_ids}, 'warning': warning} |
151 | + |
152 | +account_account() |
153 | + |
154 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
155 | |
156 | === added file 'account_fstr/account_account_view.xml' |
157 | --- account_fstr/account_account_view.xml 1970-01-01 00:00:00 +0000 |
158 | +++ account_fstr/account_account_view.xml 2013-04-02 11:54:22 +0000 |
159 | @@ -0,0 +1,23 @@ |
160 | +<?xml version="1.0" encoding="utf-8"?> |
161 | +<openerp> |
162 | + <data> |
163 | + |
164 | + <record id="view_account_form" model="ir.ui.view"> |
165 | + <field name="name">account.account.form</field> |
166 | + <field name="model">account.account</field> |
167 | + <field name="inherit_id" ref="account.view_account_form" /> |
168 | + <field name="arch" type="xml"> |
169 | + <xpath expr='//group[@groups="base.group_multi_currency"]' |
170 | + position="after"> |
171 | + <group> |
172 | + <field name="category_ids" colspan="6" nolabel="1" |
173 | + domain="[('state', '=', 'normal')]" attrs="{'invisible': [('type', '=', 'view')]}" |
174 | + on_change="test_category_list(category_ids)" /> |
175 | + </group> |
176 | + |
177 | + </xpath> |
178 | + </field> |
179 | + </record> |
180 | + |
181 | + </data> |
182 | +</openerp> |
183 | |
184 | === added file 'account_fstr/account_fstr_category.py' |
185 | --- account_fstr/account_fstr_category.py 1970-01-01 00:00:00 +0000 |
186 | +++ account_fstr/account_fstr_category.py 2013-04-02 11:54:22 +0000 |
187 | @@ -0,0 +1,178 @@ |
188 | +# -*- encoding: utf-8 -*- |
189 | +############################################################################## |
190 | +# |
191 | +# OpenERP, Open Source Management Solution |
192 | +# Copyright (C) |
193 | +# 2010 Colin MacMillan - Enapps Ltd. |
194 | +# All Rights Reserved |
195 | +# |
196 | +# This program is free software: you can redistribute it and/or modify |
197 | +# it under the terms of the GNU Affero General Public License as |
198 | +# published by the Free Software Foundation, either version 3 of the |
199 | +# License, or (at your option) any later version. |
200 | +# |
201 | +# This program is distributed in the hope that it will be useful, |
202 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
203 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
204 | +# GNU Affero General Public License for more details. |
205 | +# |
206 | +# You should have received a copy of the GNU Affero General Public License |
207 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
208 | +# |
209 | +############################################################################## |
210 | + |
211 | +from openerp.osv import fields, osv |
212 | +from openerp.addons.decimal_precision import decimal_precision as dp |
213 | +from wizard import account_fstr_wizard |
214 | +from openerp.tools.translate import _ |
215 | + |
216 | +class account_fstr_category(osv.osv): |
217 | + _name = "account_fstr.category" |
218 | + _description = "Financial Statement template category" |
219 | + _order = "sequence, id" |
220 | + |
221 | + |
222 | + def __compute(self, cr, uid, ids, field_names, arg=None, context=None, |
223 | + query='', query_params=()): |
224 | + res = {} |
225 | + for category_obj in self.browse(cr, uid, ids, context=context): |
226 | + res.update({category_obj.id: self.__compute_balance_for_caregory(cr, uid, category_obj, context=context)}) |
227 | + return res |
228 | + |
229 | + def __compute_balance_for_caregory(self, cr, uid, category_obj, context={}): |
230 | + result = 0 |
231 | + if category_obj.state == 'normal': |
232 | + for account_obj in category_obj.account_ids: |
233 | + result += account_obj.balance |
234 | + else: |
235 | + for child_category_obj in category_obj.child_id: |
236 | + result += self.__compute_balance_for_caregory(cr, uid, child_category_obj, context=context) |
237 | + return result |
238 | + |
239 | + def _get_progenitor_id(self, cr, uid, ids, field_names, arg=None, context={}): |
240 | + res = {} |
241 | + for category_obj in self.browse(cr, uid, ids, context=context): |
242 | + res.update({category_obj.id: self._get_progenitor_id_in_recurse(cr, uid, category_obj, context=context) }) |
243 | + return res |
244 | + |
245 | + def _get_progenitor_id_in_recurse(self, cr, uid, category_obj, context={}): |
246 | + result = None |
247 | + if not (category_obj.parent_id and category_obj.parent_id.id): |
248 | + result = category_obj.id |
249 | + else: |
250 | + result = self._get_progenitor_id_in_recurse(cr, uid, category_obj.parent_id, context=context) |
251 | + return result |
252 | + |
253 | + def _get_childs(self, cr, uid, ids, context={}): |
254 | + return self.search(cr, uid, [('id', 'child_of', ids)], context=context) |
255 | + |
256 | + _columns = { |
257 | + 'name': fields.char('Category Title name', size=32, required=True, select=True), |
258 | + 'digits_round': fields.integer('Digits round', required=True), |
259 | + 'company_id': fields.many2one('res.company', 'Company', ondelete='set null'), |
260 | + 'name_end': fields.char('Category End/Total name', size=128,), |
261 | + 'display_total': fields.boolean('Display End/Total'), |
262 | + 'parent_id': fields.many2one('account_fstr.category', 'Parent node', ondelete='cascade', select=True), |
263 | + 'sequence': fields.integer('Sequence'), |
264 | + 'consolidate_total': fields.boolean('Consolidate total', help="Selecting Consolidate total will print this category total as a single summed figure and will not list out each individual account"), |
265 | + 'display_heading': fields.boolean('Display title'), |
266 | + 'bold_title': fields.boolean('Bold'), |
267 | + 'italic_title': fields.boolean('Italic'), |
268 | + 'underline_title': fields.boolean('Unnderline'), |
269 | + 'bold_end': fields.boolean('Bold'), |
270 | + 'italic_end': fields.boolean('Italic'), |
271 | + 'underline_end': fields.boolean('Unnderline'), |
272 | + 'inversed_sign': fields.boolean('Inversed sign'), |
273 | + 'child_id': fields.one2many('account_fstr.category', 'parent_id', 'Consolidated Children', select=True), |
274 | + 'account_ids': fields.many2many('account.account', 'account_fstr_category_account', 'account_id', 'category_id', 'Accounts', select=True), |
275 | + 'indent_title': fields.integer('Indent Title, (pt)'), |
276 | + 'indent_end': fields.integer('Indent End, (pt)'), |
277 | + 'top_spacing_title': fields.integer('Top spacing Title, (pt)'), |
278 | + 'top_spacing_end': fields.integer('Top spacing End, (pt)'), |
279 | + 'bottom_spacing_title': fields.integer('Bottom spacing Title, (pt)'), |
280 | + 'bottom_spacing_end': fields.integer('Bottom spacing End, (pt)'), |
281 | + 'state': fields.selection([('view','View'),('root','Root'),('normal','Normal')], 'Type', select=True,), |
282 | + 'balance': fields.function(__compute, digits_compute=dp.get_precision('Account'), method=True, string='Balance', store=False, type='float'), |
283 | + 'printable': fields.boolean('Printable', help="Select to allow category to display in print list"), |
284 | + 'progenitor_id': fields.function(_get_progenitor_id, method=True, |
285 | + string='Root', type='many2one', |
286 | + obj='account_fstr.category', |
287 | + store={ 'account_fstr.category': (_get_childs, ['parent_id'], 1)}, select=True), |
288 | + |
289 | + |
290 | + } |
291 | + |
292 | + _defaults = { |
293 | + 'state': 'normal', |
294 | + 'indent_title': 10, |
295 | + 'indent_end': 10, |
296 | + 'top_spacing_title': 0, |
297 | + 'digits_round': 0, |
298 | + } |
299 | + |
300 | + def _check_recursion(self, cr, uid, ids, context=None): |
301 | + level = 100 |
302 | + while len(ids): |
303 | + cr.execute('select distinct parent_id from account_fstr_category where id IN %s',(tuple(ids),)) |
304 | + ids = filter(None, map(lambda x:x[0], cr.fetchall())) |
305 | + if not level: |
306 | + return False |
307 | + level -= 1 |
308 | + return True |
309 | + |
310 | + _constraints = [ |
311 | + (_check_recursion, 'Error ! You cannot create recursive.', ['parent_id']), |
312 | + ] |
313 | + |
314 | + def print_template(self, cr, uid, ids, context={}): |
315 | + return account_fstr_wizard.account_fstr_wizard.print_template(cr, uid, ids, context={}) |
316 | + |
317 | + |
318 | + def _get_selected_accounts(self, cr, uid, progenitor_id, current_category_id, context={}): |
319 | + result = [] |
320 | + category_ids = self.search(cr, uid, [('progenitor_id', '=', progenitor_id)], context=context) |
321 | + for category_obj in self.browse(cr, uid, category_ids, context=context): |
322 | + if category_obj.id != current_category_id: |
323 | + result.extend([category.id for category in category_obj.account_ids]) |
324 | + return result |
325 | + |
326 | + def test_account_list(self, cr, uid, ids, progenitor_id, account_ids): |
327 | + warning = {} |
328 | + warning_account_names = [] |
329 | + current_account_ids = [] |
330 | + all_account_ids_for_template = self._get_selected_accounts(cr, uid, |
331 | + progenitor_id, |
332 | + ids) |
333 | + updated_account_ids = account_ids[0][2] |
334 | + for account_obj in self.pool.get('account.account').browse(cr, uid, updated_account_ids): |
335 | + if not (account_obj.id in all_account_ids_for_template): |
336 | + current_account_ids.append(account_obj.id) |
337 | + else: |
338 | + warning_account_names.append(account_obj.name) |
339 | + if warning_account_names: |
340 | + warning.update({ |
341 | + 'title': 'Alert', |
342 | + 'message': "Accounts %s already exist in current template" % (", ".join(warning_account_names)), |
343 | + }) |
344 | + return {'value': {'account_ids': current_account_ids,}, 'warning': warning} |
345 | + |
346 | + def view_exception_accounts(self, cr, uid, ids, context={}): |
347 | + account_list = self._get_selected_accounts(cr, uid, ids[0], ids, context=context) |
348 | + model_data_pool = self.pool.get('ir.model.data') |
349 | + model_data_ids = model_data_pool.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_account_list')], context=context) |
350 | + resource_id = model_data_pool.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] |
351 | + return { |
352 | + 'name': "Exception Accounts", |
353 | + 'view_mode': 'form', |
354 | + 'view_type': 'form', |
355 | + 'views': [(resource_id, 'tree'),], |
356 | + 'res_model': 'account.account', |
357 | + 'type': 'ir.actions.act_window', |
358 | + 'nodestroy': True, |
359 | + 'domain': [('type', '!=', 'view'), ('id', 'not in', account_list)] |
360 | + } |
361 | + |
362 | + |
363 | +account_fstr_category() |
364 | + |
365 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
366 | |
367 | === added file 'account_fstr/account_fstr_menu.xml' |
368 | --- account_fstr/account_fstr_menu.xml 1970-01-01 00:00:00 +0000 |
369 | +++ account_fstr/account_fstr_menu.xml 2013-04-02 11:54:22 +0000 |
370 | @@ -0,0 +1,31 @@ |
371 | +<?xml version="1.0" encoding="utf-8"?> |
372 | +<openerp> |
373 | + <data> |
374 | + |
375 | + <menuitem icon="terp-stock_format-default" |
376 | + id="parent_menu_account_fstr" |
377 | + name="Financial Statement template reporting" |
378 | + parent="account.menu_finance" |
379 | + sequence="10"/> |
380 | + |
381 | + <menuitem action="action_account_fstr_category_form" |
382 | + id="menu_account_fstr_category_form" |
383 | + icon="STOCK_PREFERENCES" |
384 | + name="Financial Statement categories form" |
385 | + parent="parent_menu_account_fstr" /> |
386 | + |
387 | + <menuitem action="action_account_fstr_category_tree" |
388 | + id="menu_account_fstr_category_tree" |
389 | + icon="STOCK_PREFERENCES" |
390 | + name="Financial Statement categories tree" |
391 | + parent="parent_menu_account_fstr" /> |
392 | + |
393 | + <menuitem action="action_account_fstr_wizard" |
394 | + id="menu_account_fstr_wizard_form" |
395 | + icon="STOCK_PRINT" |
396 | + name="Print/Preview financial statements" |
397 | + parent="parent_menu_account_fstr" /> |
398 | + |
399 | + </data> |
400 | +</openerp> |
401 | + |
402 | |
403 | === added file 'account_fstr/account_fstr_report.xml' |
404 | --- account_fstr/account_fstr_report.xml 1970-01-01 00:00:00 +0000 |
405 | +++ account_fstr/account_fstr_report.xml 2013-04-02 11:54:22 +0000 |
406 | @@ -0,0 +1,15 @@ |
407 | +<?xml version="1.0" encoding="utf-8"?> |
408 | +<openerp> |
409 | + <data> |
410 | + <report |
411 | + id="report_account_fstr" |
412 | + string="Aged reval report" |
413 | + model="account_fstr.category" |
414 | + name="account_fstr.report" |
415 | + rml="account_fstr/reports/account_fstr_report.rml" |
416 | + header="True" |
417 | + multi="True" |
418 | + /> |
419 | + |
420 | + </data> |
421 | +</openerp> |
422 | |
423 | === added file 'account_fstr/account_fstr_view.xml' |
424 | --- account_fstr/account_fstr_view.xml 1970-01-01 00:00:00 +0000 |
425 | +++ account_fstr/account_fstr_view.xml 2013-04-02 11:54:22 +0000 |
426 | @@ -0,0 +1,154 @@ |
427 | +<?xml version="1.0" encoding="utf-8"?> |
428 | +<openerp> |
429 | + <data> |
430 | + |
431 | + <!--Category --> |
432 | + |
433 | + <record id="view_account_fstr_category_search" model="ir.ui.view"> |
434 | + <field name="name">view.account_fstr.category.search</field> |
435 | + <field name="model">account_fstr.category</field> |
436 | + <field name="arch" type="xml"> |
437 | + <search string="Search Categories"> |
438 | + <group col="10" colspan="4"> |
439 | + <field name="name" /> |
440 | + <field name="parent_id" /> |
441 | + <field name="progenitor_id" select="1" /> |
442 | + </group> |
443 | + <group expand="1" string="Group By..."> |
444 | + <filter string="Parent" name="fparent" icon="terp-personal" |
445 | + domain="[]" context="{'group_by':'parent_id'}" /> |
446 | + <filter string="Temlate" name="ftemplate" icon="terp-personal" |
447 | + domain="[]" context="{'group_by':'progenitor_id'}" /> |
448 | + </group> |
449 | + </search> |
450 | + </field> |
451 | + </record> |
452 | + |
453 | + <record id="view_account_fstr_category_form" model="ir.ui.view"> |
454 | + <field name="name">account_fstr.category.form</field> |
455 | + <field name="model">account_fstr.category</field> |
456 | + <field name="arch" type="xml"> |
457 | + <form string="Financial Statement category" version="7.0"> |
458 | + <header> |
459 | + <!--<field name="state" widget="statusbar" nolabel="1" |
460 | + statusbar_visible="view,root,normal" |
461 | + statusbar_colors="{"proforma":"blue","proforma2":"blue"}" /> --> |
462 | + <button icon="gtk-print" string="Print/Preview" |
463 | + name="%(action_account_fstr_wizard)d" type="action" states="normal" /> |
464 | + <button icon="gtk-find" string="Exception accounts" name="view_exception_accounts" |
465 | + type="object" states="normal" /> |
466 | + </header> |
467 | + <sheet> |
468 | + <notebook> |
469 | + <page string="Configurations"> |
470 | + <label string="Category Title name" /> |
471 | + <field name="name" colspan="2" style="width: 30em" /> |
472 | + <group colspan="2" col="4"> |
473 | + <group string="Category Title" colspan="1" col="2"> |
474 | + <field name="display_heading" /> |
475 | + <field name="bold_title" /> |
476 | + <field name="italic_title" /> |
477 | + <field name="underline_title" /> |
478 | + </group> |
479 | + <group string="Spacing" colspan="1" col="2"> |
480 | + <field name="indent_title" /> |
481 | + <field name="top_spacing_title" /> |
482 | + <field name="bottom_spacing_title" /> |
483 | + </group> |
484 | + </group> |
485 | + <label string="Category End/Total name" /> |
486 | + <field name="name_end" colspan="2" style="width: 30em" /> |
487 | + <group colspan="2" col="4"> |
488 | + <group string="Category End/Total" colspan="1" col="2"> |
489 | + <field name="display_total" /> |
490 | + <field name="bold_end" /> |
491 | + <field name="italic_end" /> |
492 | + <field name="underline_end" /> |
493 | + <field name="consolidate_total" /> |
494 | + </group> |
495 | + <group string="Spacing" colspan="1" col="2"> |
496 | + <field name="indent_end" /> |
497 | + <field name="top_spacing_end" /> |
498 | + <field name="bottom_spacing_end" /> |
499 | + </group> |
500 | + </group> |
501 | + <separator string="Settings" colspan="4" /> |
502 | + <group> |
503 | + <field name="company_id" style="width: 30em" /> |
504 | + <field name="parent_id" style="width: 30em" /> |
505 | + <field name="state" style="width: 30em" /> |
506 | + </group> |
507 | + <group> |
508 | + <field name="progenitor_id" colspan="2" invisible="True" /> |
509 | + <field name="digits_round" colspan="2" style="width: 30em" /> |
510 | + <field name="sequence" style="width: 10em" /> |
511 | + <field name="inversed_sign" colspan="1" /> |
512 | + </group> |
513 | + <group colspan="2" string="Print Options"> |
514 | + <field name="printable" /> |
515 | + </group> |
516 | + </page> |
517 | + <page string="Accounts"> |
518 | + <separator colspan="4" /> |
519 | + <field name="account_ids" colspan="4" |
520 | + attrs="{'invisible':[('state','!=','normal')]}" domain="[('type', '!=', 'view')]" |
521 | + on_change="test_account_list(progenitor_id, account_ids)" |
522 | + nolabel="1" /> |
523 | + </page> |
524 | + </notebook> |
525 | + </sheet> |
526 | + </form> |
527 | + </field> |
528 | + </record> |
529 | + |
530 | + <record id="view_account_fstr_category_tree" model="ir.ui.view"> |
531 | + <field name="name">account_fstr.category.tree</field> |
532 | + <field name="model">account_fstr.category</field> |
533 | + <field name="field_parent">child_id</field> |
534 | + <field name="arch" type="xml"> |
535 | + <tree colors="ForestGreen:state=='root';blue:state=='view'" |
536 | + string="Financial Statement category"> |
537 | + <field name="name" select="1" /> |
538 | + <field name="company_id" /> |
539 | + <field name="name_end" /> |
540 | + <field name="balance" /> |
541 | + <field name="display_total" /> |
542 | + <field name="progenitor_id" select="1" /> |
543 | + <field name="parent_id" select="1" /> |
544 | + <field name="digits_round" select="1" /> |
545 | + <field name="sequence" /> |
546 | + <field name="indent_title" /> |
547 | + <field name="top_spacing_title" /> |
548 | + <field name="consolidate_total" /> |
549 | + <field name="display_heading" /> |
550 | + <field name="bold_title" /> |
551 | + <field name="italic_title" colspan="1" /> |
552 | + <field name="underline_title" colspan="1" /> |
553 | + <field name="inversed_sign" /> |
554 | + <field name="state" /> |
555 | + <field name="account_ids" /> |
556 | + </tree> |
557 | + </field> |
558 | + </record> |
559 | + |
560 | + <record id="action_account_fstr_category_tree" model="ir.actions.act_window"> |
561 | + <field name="name">Financial Statement category</field> |
562 | + <field name="type">ir.actions.act_window</field> |
563 | + <field name="res_model">account_fstr.category</field> |
564 | + <field name="view_mode">tree</field> |
565 | + <field name="view_type">tree</field> |
566 | + <field name="view_id" ref="view_account_fstr_category_tree" /> |
567 | + <field name="domain">[('parent_id','=',False)]</field> |
568 | + </record> |
569 | + |
570 | + <record id="action_account_fstr_category_form" model="ir.actions.act_window"> |
571 | + <field name="name">Financial Statement category</field> |
572 | + <field name="type">ir.actions.act_window</field> |
573 | + <field name="res_model">account_fstr.category</field> |
574 | + <field name="view_mode">tree,form</field> |
575 | + <field name="view_type">form</field> |
576 | + <field name="view_id" ref="view_account_fstr_category_tree" /> |
577 | + <field name="search_view_id" ref="view_account_fstr_category_search" /> |
578 | + </record> |
579 | + </data> |
580 | +</openerp> |
581 | |
582 | === added file 'account_fstr/account_fstr_wizard_view.xml' |
583 | --- account_fstr/account_fstr_wizard_view.xml 1970-01-01 00:00:00 +0000 |
584 | +++ account_fstr/account_fstr_wizard_view.xml 2013-04-02 11:54:22 +0000 |
585 | @@ -0,0 +1,42 @@ |
586 | +<?xml version="1.0" encoding="utf-8"?> |
587 | +<openerp> |
588 | + <data> |
589 | + <record id="view_account_fstr_wizard_form" model="ir.ui.view"> |
590 | + <field name="name">account_fstr.wizard.form</field> |
591 | + <field name="model">account_fstr.wizard</field> |
592 | + <field name="arch" type="xml"> |
593 | + <form string="Account charts"> |
594 | + <group colspan="4"> |
595 | + <field name="fiscalyear" on_change="onchange_fiscalyear(fiscalyear)" widget="selection"/> |
596 | + <field name="target_move"/> |
597 | + <label align="0.7" colspan="4" string="(If you do not select Fiscal year it will take all open fiscal years)"/> |
598 | + <separator string="Periods" colspan="4"/> |
599 | + <field name="period_from" widget="selection"/> |
600 | + <field name="period_to" widget="selection"/> |
601 | + <separator colspan="4"/> |
602 | + <field name="root_node" domain="[('printable','=','1')]"/> |
603 | + <field name="hide_zero"/> |
604 | + </group> |
605 | + <separator string="" colspan="4"/> |
606 | + <group colspan="4" col="6"> |
607 | + <button icon="gtk-cancel" special="cancel" string="Cancel"/> |
608 | + <button icon="terp-gtk-go-back-rtl" string="Preview" name="open_window" type="object"/> |
609 | + <button icon="gtk-print" string="Print" name="print_template" type="object"/> |
610 | + </group> |
611 | + </form> |
612 | + </field> |
613 | + </record> |
614 | + |
615 | + <record id="action_account_fstr_wizard" model="ir.actions.act_window"> |
616 | + <field name="name">Temlate Print/Preview</field> |
617 | + <field name="view_id" ref="view_account_fstr_wizard_form"/> |
618 | + <field name="view_type">form</field> |
619 | + <field name="view_mode">form</field> |
620 | + <field name="res_model">account_fstr.wizard</field> |
621 | + <field name="target">new</field> |
622 | + </record> |
623 | + |
624 | + <report id="account_fstr_report" string="Print Template" model="account_fstr.category" name="account_fstr.report" rml="account_fstr/reports/account_fstr_report.rml"/> |
625 | + |
626 | + </data> |
627 | +</openerp> |
628 | |
629 | === added directory 'account_fstr/images' |
630 | === added file 'account_fstr/images/fstr_form.png' |
631 | Binary files account_fstr/images/fstr_form.png 1970-01-01 00:00:00 +0000 and account_fstr/images/fstr_form.png 2013-04-02 11:54:22 +0000 differ |
632 | === added directory 'account_fstr/reports' |
633 | === added file 'account_fstr/reports/__init__.py' |
634 | --- account_fstr/reports/__init__.py 1970-01-01 00:00:00 +0000 |
635 | +++ account_fstr/reports/__init__.py 2013-04-02 11:54:22 +0000 |
636 | @@ -0,0 +1,20 @@ |
637 | +############################################################################## |
638 | +# |
639 | +# Copyright (C) 2011 Enapps LTD (<http://www.enapps.co.uk>). |
640 | +# All Rights Reserved |
641 | +# |
642 | +# This program is free software: you can redistribute it and/or modify |
643 | +# it under the terms of the GNU Affero General Public License as |
644 | +# published by the Free Software Foundation, either version 3 of the |
645 | +# License, or (at your option) any later version. |
646 | +# |
647 | +# This program is distributed in the hope that it will be useful, |
648 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
649 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
650 | +# GNU Affero General Public License for more details. |
651 | +# |
652 | +# You should have received a copy of the GNU Affero General Public License |
653 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
654 | +# |
655 | +############################################################################## |
656 | +import account_fstr_report |
657 | |
658 | === added file 'account_fstr/reports/account_fstr_report.py' |
659 | --- account_fstr/reports/account_fstr_report.py 1970-01-01 00:00:00 +0000 |
660 | +++ account_fstr/reports/account_fstr_report.py 2013-04-02 11:54:22 +0000 |
661 | @@ -0,0 +1,171 @@ |
662 | +# -*- encoding: utf-8 -*- |
663 | +############################################################################## |
664 | +# |
665 | +# Copyright (C) 2011 Enapps LTD (<http://www.enapps.co.uk>). |
666 | +# All Rights Reserved |
667 | +# |
668 | +# This program is free software: you can redistribute it and/or modify |
669 | +# it under the terms of the GNU Affero General Public License as |
670 | +# published by the Free Software Foundation, either version 3 of the |
671 | +# License, or (at your option) any later version. |
672 | +# |
673 | +# This program is distributed in the hope that it will be useful, |
674 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
675 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
676 | +# GNU Affero General Public License for more details. |
677 | +# |
678 | +# You should have received a copy of the GNU Affero General Public License |
679 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
680 | +# |
681 | +############################################################################## |
682 | + |
683 | +import time |
684 | +from openerp.report import report_sxw |
685 | +from openerp import pooler |
686 | +from account.report.common_report_header import common_report_header |
687 | +from sm_kit import groupe_digits |
688 | + |
689 | + |
690 | +class account_fstr_report(report_sxw.rml_parse, common_report_header): |
691 | + |
692 | + _name = 'account_fstr.category.report' |
693 | + |
694 | + date_end = None |
695 | + root_node_obj = None |
696 | + |
697 | + def __init__(self, cr, uid, name, context): |
698 | + super(account_fstr_report, self).__init__(cr, uid, name, context) |
699 | + category_id = context.get('active_id') |
700 | + if context.get('active_model') == 'account_fstr.wizard': |
701 | + category_id = context.get('account_fstr_root_node')[0] |
702 | + self.root_node_obj = pooler.get_pool(cr.dbname).get('account_fstr.category').browse(cr, uid, category_id, context=context) |
703 | + self.category_pool = pooler.get_pool(cr.dbname).get('account_fstr.category') |
704 | + ids = context['active_ids'] |
705 | + self.localcontext.update({ |
706 | + 'time': time, |
707 | + 'template_data': self._get_template_data(cr, uid, ids, [], self.root_node_obj, context=context), |
708 | + 'date_end': '', |
709 | + 'digits_round': '0' * (self.root_node_obj.digits_round - 2) |
710 | + }) |
711 | + |
712 | + def _get_root_id(self): |
713 | + if self.root_node_obj: |
714 | + return self.root_node_obj |
715 | + else: |
716 | + return None |
717 | + |
718 | + def _get_template_data(self, cr, uid, ids, statements, category_id, context={}): |
719 | + category_obj = self.category_pool.browse(cr, uid, category_id, context=context) |
720 | + name = category_obj.name |
721 | + result = [self._get_statement(cr, uid, ids, [], self._get_root_id(), -1, context=context), self._get_root_id().balance] |
722 | + result = self._digits_rounding(cr, uid, ids, result, context=context) |
723 | + return { |
724 | + 'name': name, |
725 | + 'statements': result, |
726 | + 'lang': context['lang'], |
727 | + } |
728 | + def _digits_rounding(self, cr, uid, ids, statements, context={}): |
729 | + digits_round = self.root_node_obj.digits_round |
730 | + statements[1] = self._account_round(statements[1], digits_round) |
731 | + for statement_id in range(len(statements[0])): |
732 | + statements[0][statement_id]['total_amount'] = self._account_round(statements[0][statement_id]['total_amount'], digits_round) |
733 | + return statements |
734 | + |
735 | + def _account_round(self, number, digits_round): |
736 | + if number == ' ': |
737 | + return number |
738 | + if number == None: |
739 | + return ' ' |
740 | + number = (round(float(number), 2 - digits_round)) |
741 | + if digits_round <= 2: |
742 | + format_string = "%%.%if" % (2 - digits_round,) |
743 | + elif digits_round > 2: |
744 | + number = int(number / (10 ** (digits_round - 2))) |
745 | + format_string = "%i" |
746 | + result = groupe_digits(format_string % number) |
747 | + if result == "-0": |
748 | + result = "0" |
749 | + return result |
750 | + |
751 | + def _get_statement(self, cr, uid, ids, statements_list, category_obj, parent_indent, context={}): |
752 | + indent = category_obj.indent_title + parent_indent |
753 | + font_name_title = 'Helvetica' |
754 | + font_name_end = 'Helvetica' |
755 | + |
756 | + # Category Name - bold/italic |
757 | + if category_obj.bold_title or category_obj.italic_title: |
758 | + font_name_title += '-' |
759 | + if category_obj.bold_title: |
760 | + font_name_title += 'Bold' |
761 | + if category_obj.italic_title: |
762 | + font_name_title += 'Oblique' |
763 | + |
764 | + # Category End Name - bold/italic |
765 | + if category_obj.bold_end or category_obj.italic_end: |
766 | + font_name_end += '-' |
767 | + if category_obj.bold_end: |
768 | + font_name_end += 'Bold' |
769 | + if category_obj.italic_end: |
770 | + font_name_end += 'Oblique' |
771 | + |
772 | + total_amount = 0 |
773 | + internal_statements = [] |
774 | + |
775 | + if category_obj.state == 'normal': |
776 | + for account_statement_obj in category_obj.account_ids: |
777 | + account_total_amount = account_statement_obj.balance |
778 | + |
779 | + # skip iterations where amount = 0 and hide_zero box ticked |
780 | + if 'hide_zero' in context: |
781 | + hide_zero = int(context['hide_zero']) |
782 | + if hide_zero == 1 and account_total_amount == 0.0: |
783 | + continue |
784 | + |
785 | + if category_obj.inversed_sign: |
786 | + account_total_amount = -account_total_amount |
787 | + internal_statements.append({ |
788 | + 'name': "%s\t%s" % (account_statement_obj.code, account_statement_obj.name,), |
789 | + 'indent': indent + 10, |
790 | + 'top_spacing': None, |
791 | + 'bottom_spacing': None, |
792 | + 'font_name': 'Helvetica', |
793 | + 'underline': False, |
794 | + 'total_amount': account_total_amount, |
795 | + }) |
796 | + total_amount += account_total_amount |
797 | + internal_statements = sorted(internal_statements, key=lambda statement: statement['name']) |
798 | + |
799 | + elif category_obj.state != 'normal': |
800 | + for child_category in sorted(category_obj.child_id, key=lambda child_obj: child_obj.sequence): |
801 | + internal_statements = self._get_statement(cr, uid, ids, internal_statements, child_category, indent, context=context) |
802 | + total_amount = category_obj.balance |
803 | + if category_obj.inversed_sign: |
804 | + total_amount = -total_amount |
805 | + # Categroy Title |
806 | + if category_obj.display_heading: |
807 | + statements_list.append({ |
808 | + 'name': category_obj.name, |
809 | + 'indent': category_obj.indent_title + category_obj.top_spacing_title, |
810 | + 'top_spacing': category_obj.top_spacing_title, |
811 | + 'bottom_spacing': category_obj.bottom_spacing_title, |
812 | + 'font_name': font_name_title, |
813 | + 'underline': category_obj.underline_title, |
814 | + 'total_amount': total_amount if category_obj.consolidate_total else ' ', |
815 | + }) |
816 | + if not category_obj.consolidate_total: |
817 | + statements_list.extend(internal_statements) |
818 | + # Category End Name |
819 | + if category_obj.display_total: |
820 | + statements_list.append({ |
821 | + 'name': category_obj.name_end, |
822 | + 'indent': category_obj.indent_end, |
823 | + 'top_spacing': category_obj.top_spacing_end, |
824 | + 'bottom_spacing': category_obj.bottom_spacing_end, |
825 | + 'font_name': font_name_end, |
826 | + 'underline': category_obj.underline_end, |
827 | + 'total_amount': total_amount, |
828 | + }) |
829 | + return statements_list |
830 | + |
831 | +report_sxw.report_sxw('report.account_fstr.report', 'account_fstr.category', |
832 | + 'addons/account_fstr/reports/account_fstr_report.rml', parser=account_fstr_report, header="True") |
833 | |
834 | === added file 'account_fstr/reports/account_fstr_report.rml' |
835 | --- account_fstr/reports/account_fstr_report.rml 1970-01-01 00:00:00 +0000 |
836 | +++ account_fstr/reports/account_fstr_report.rml 2013-04-02 11:54:22 +0000 |
837 | @@ -0,0 +1,134 @@ |
838 | +<?xml version="1.0"?> |
839 | +<document filename="test.pdf"> |
840 | + <template pageSize="(595.0,842.0)" title="Account Statements report" author="Publicus Solutions Ltd." allowSplitting="20"> |
841 | + <pageTemplate id="first"> |
842 | + <frame id="first" x1="42.0" y1="42.0" width="511" height="758"/> |
843 | + </pageTemplate> |
844 | + </template> |
845 | + <stylesheet> |
846 | + <blockTableStyle id="Standard_Outline"> |
847 | + <blockAlignment value="LEFT"/> |
848 | + <blockValign value="TOP"/> |
849 | + </blockTableStyle> |
850 | + <blockTableStyle id="Table7"> |
851 | + <blockAlignment value="LEFT"/> |
852 | + <blockValign value="TOP"/> |
853 | + <lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/> |
854 | + <lineStyle kind="LINEAFTER" colorName="#000000" start="0,0" stop="0,-1"/> |
855 | + <lineStyle kind="LINEAFTER" colorName="#000000" start="-1,0" stop="-1,-1"/> |
856 | + <lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="-1,0"/> |
857 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/> |
858 | + <lineStyle kind="LINEBEFORE" colorName="#000000" start="0,1" stop="0,-1"/> |
859 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/> |
860 | + <lineStyle kind="LINEBEFORE" colorName="#000000" start="1,1" stop="1,-1"/> |
861 | + <lineStyle kind="LINEAFTER" colorName="#000000" start="1,1" stop="1,-1"/> |
862 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/> |
863 | + </blockTableStyle> |
864 | + <blockTableStyle id="Table_title"> |
865 | + <blockAlignment value="LEFT"/> |
866 | + <blockValign value="TOP"/> |
867 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/> |
868 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="-1,-1"/> |
869 | + </blockTableStyle> |
870 | + <blockTableStyle id="Table_futter"> |
871 | + <blockAlignment value="LEFT"/> |
872 | + <blockValign value="TOP"/> |
873 | + <lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="-1,0"/> |
874 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/> |
875 | + </blockTableStyle> |
876 | + <initialize> |
877 | + <paraStyle name="all" alignment="justify"/> |
878 | + </initialize> |
879 | + <paraStyle name="P1" fontName="Helvetica"/> |
880 | + <paraStyle name="P2" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/> |
881 | + <paraStyle name="P3" fontName="Helvetica-Bold" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/> |
882 | + <paraStyle name="P4" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> |
883 | + <paraStyle name="P4c" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> |
884 | + <paraStyle name="P4l" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
885 | + <paraStyle name="P5" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> |
886 | + <paraStyle name="P5l" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
887 | + <paraStyle name="P5lb" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
888 | + <paraStyle name="P5rb" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> |
889 | + <paraStyle name="P5c" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> |
890 | + <paraStyle name="P7" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/> |
891 | + <paraStyle name="Standard" fontName="Helvetica"/> |
892 | + <paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/> |
893 | + <paraStyle name="Heading" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="12.0" spaceAfter="6.0"/> |
894 | + <paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/> |
895 | + <paraStyle name="Table Contents" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/> |
896 | + <paraStyle name="Table Heading" fontName="Helvetica" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/> |
897 | + <paraStyle name="Caption" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/> |
898 | + <paraStyle name="Index" fontName="Helvetica"/> |
899 | + <paraStyle name="Footer" fontName="Helvetica"/> |
900 | + <paraStyle name="Horizontal Line" fontName="Helvetica" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/> |
901 | + <paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/> |
902 | + <paraStyle name="Heading 9" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/> |
903 | + <paraStyle name="terp_tblheader_General" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/> |
904 | + <paraStyle name="terp_tblheader_Details" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
905 | + <paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
906 | + <paraStyle name="terp_default_Bold_8" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
907 | + <paraStyle name="terp_tblheader_General_Centre" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/> |
908 | + <paraStyle name="terp_tblheader_General_Right" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/> |
909 | + <paraStyle name="terp_tblheader_Details_Centre" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> |
910 | + <paraStyle name="terp_tblheader_Details_Right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> |
911 | + <paraStyle name="terp_default_Right_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> |
912 | + <paraStyle name="terp_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> |
913 | + <paraStyle name="terp_header_Right" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/> |
914 | + <paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/> |
915 | + <paraStyle name="terp_default_address" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
916 | + <paraStyle name="terp_default_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
917 | + <paraStyle name="terp_default_Bold_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
918 | + <paraStyle name="terp_default_Centre_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> |
919 | + <paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> |
920 | + <paraStyle name="terp_default_2" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
921 | + <images/> |
922 | + </stylesheet> |
923 | + <story> |
924 | + <para style="P7"> [[ setLang([[ template_data['lang']) ]] [[ template_data['name'] ]]</para> |
925 | + <blockTable colWidths="255.0,255.0" repeatRows="1"> |
926 | + <tr> |
927 | + <td> |
928 | + <para style="P4l">[[ not data['fiscalyear'] and removeParentNode('para')]][[ data['fiscalyear'] ]]</para> |
929 | + </td> |
930 | + <td> |
931 | + <para style="P4">[[ not (data['period_from'] and data['period_to']) and removeParentNode('para')]]Periods: from [[ data['period_from'] ]] to [[ data['period_to'] ]]</para> |
932 | + </td> |
933 | + </tr> |
934 | + </blockTable> |
935 | + <blockTable colWidths="413.0,97.0" repeatRows="1"> |
936 | + <tr> |
937 | + <td> |
938 | + <para style="P4l"></para> |
939 | + </td> |
940 | + <td> |
941 | + <para style="P4">[[ user.company_id.currency_id.name ]] [[ digits_round ]]</para> |
942 | + </td> |
943 | + </tr> |
944 | + <tr> |
945 | + <td> |
946 | + <para style="P4"> |
947 | + <font face="Helvetica">[[ repeatIn(template_data['statements'][0], 'o') ]]</font> |
948 | + </para> |
949 | + <para style="P5l"> |
950 | + [[ setTag('para', 'para', {'spaceBefore': "%s" % (o['top_spacing'],), 'leftIndent': "%s" % (o['indent'],), 'fontName': o['font_name'],}) ]] |
951 | + <u>[[ not (o['underline']) and (setTag('u', 'font', {})) ]] [[ o['name'] ]]</u> |
952 | + </para> |
953 | + <para style="P5l"> |
954 | + [[ setTag('para', 'para', {'spaceAfter': "%s" % (o['bottom_spacing'],),}) ]] |
955 | + </para> |
956 | + </td> |
957 | + <td> |
958 | + <para style="P5"> |
959 | + [[ setTag('para', 'para', {'leftIndent': "%s" % (o['indent'],), 'fontName': o['font_name'],}) ]] |
960 | + [[ o['total_amount'] ]] |
961 | + </para> |
962 | + <para style="P5l"> |
963 | + [[ setTag('para', 'para', {'spaceAfter': "%s" % (o['bottom_spacing'],),}) ]] |
964 | + </para> |
965 | + </td> |
966 | + </tr> |
967 | + </blockTable> |
968 | + |
969 | + </story> |
970 | +</document> |
971 | + |
972 | |
973 | === added file 'account_fstr/reports/sm_kit.py' |
974 | --- account_fstr/reports/sm_kit.py 1970-01-01 00:00:00 +0000 |
975 | +++ account_fstr/reports/sm_kit.py 2013-04-02 11:54:22 +0000 |
976 | @@ -0,0 +1,10 @@ |
977 | +import re |
978 | + |
979 | +def groupe_digits(digite, separator=','): |
980 | + digite = str(digite) |
981 | + if '.' in digite: |
982 | + re_obj = re.compile(r'(?<=\d)(?=(?:\d\d\d)+\.)') |
983 | + else: |
984 | + re_obj = re.compile(r'(?<=\d)(?=(?:\d\d\d)+$)') |
985 | + result = re_obj.sub(separator, digite) |
986 | + return result |
987 | |
988 | === added directory 'account_fstr/security' |
989 | === added file 'account_fstr/security/ir.model.access.csv' |
990 | --- account_fstr/security/ir.model.access.csv 1970-01-01 00:00:00 +0000 |
991 | +++ account_fstr/security/ir.model.access.csv 2013-04-02 11:54:22 +0000 |
992 | @@ -0,0 +1,2 @@ |
993 | +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" |
994 | +"access_account_fstr_category","account_fstr.category","model_account_fstr_category","account.group_account_manager",1,1,1,1 |
995 | |
996 | === added directory 'account_fstr/wizard' |
997 | === added file 'account_fstr/wizard/__init__.py' |
998 | --- account_fstr/wizard/__init__.py 1970-01-01 00:00:00 +0000 |
999 | +++ account_fstr/wizard/__init__.py 2013-04-02 11:54:22 +0000 |
1000 | @@ -0,0 +1,20 @@ |
1001 | +############################################################################## |
1002 | +# |
1003 | +# Copyright (C) 2011 Enapps LTD (<http://www.enapps.co.uk>). |
1004 | +# All Rights Reserved |
1005 | +# |
1006 | +# This program is free software: you can redistribute it and/or modify |
1007 | +# it under the terms of the GNU Affero General Public License as |
1008 | +# published by the Free Software Foundation, either version 3 of the |
1009 | +# License, or (at your option) any later version. |
1010 | +# |
1011 | +# This program is distributed in the hope that it will be useful, |
1012 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1013 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1014 | +# GNU Affero General Public License for more details. |
1015 | +# |
1016 | +# You should have received a copy of the GNU Affero General Public License |
1017 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
1018 | +# |
1019 | +############################################################################## |
1020 | +import account_fstr_wizard |
1021 | |
1022 | === added file 'account_fstr/wizard/account_fstr_wizard.py' |
1023 | --- account_fstr/wizard/account_fstr_wizard.py 1970-01-01 00:00:00 +0000 |
1024 | +++ account_fstr/wizard/account_fstr_wizard.py 2013-04-02 11:54:22 +0000 |
1025 | @@ -0,0 +1,126 @@ |
1026 | +# -*- coding: utf-8 -*- |
1027 | +############################################################################## |
1028 | +# |
1029 | +# Copyright (C) 2011 Enapps LTD (<http://www.enapps.co.uk>). |
1030 | +# |
1031 | +# This program is free software: you can redistribute it and/or modify |
1032 | +# it under the terms of the GNU Affero General Public License as |
1033 | +# published by the Free Software Foundation, either version 3 of the |
1034 | +# License, or (at your option) any later version. |
1035 | +# |
1036 | +# This program is distributed in the hope that it will be useful, |
1037 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1038 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1039 | +# GNU Affero General Public License for more details. |
1040 | +# |
1041 | +# You should have received a copy of the GNU Affero General Public License |
1042 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
1043 | +# |
1044 | +############################################################################## |
1045 | + |
1046 | +from openerp.osv import fields, osv |
1047 | + |
1048 | +class account_fstr_wizard(osv.osv_memory): |
1049 | + |
1050 | + _name = 'account_fstr.wizard' |
1051 | + _description = "Template Print/Preview" |
1052 | + _columns = { |
1053 | + 'fiscalyear': fields.many2one('account.fiscalyear', \ |
1054 | + 'Fiscal year', \ |
1055 | + help = 'Keep empty for all open fiscal years'), |
1056 | + 'period_from': fields.many2one('account.period', 'Start period'), |
1057 | + 'period_to': fields.many2one('account.period', 'End period'), |
1058 | + 'target_move': fields.selection([('posted', 'All Posted Entries'), |
1059 | + ('all', 'All Entries'), |
1060 | + ], 'Target Moves', required = True), |
1061 | + 'root_node': fields.many2one('account_fstr.category', 'Root node', required=True,), |
1062 | + 'hide_zero': fields.boolean('Hide accounts with a zero balance'), |
1063 | + } |
1064 | + |
1065 | + def default_get(self, cr, uid, fields, context={}): |
1066 | + result = super(osv.osv_memory, self).default_get(cr, uid, fields, context=context) |
1067 | + result['root_node']= context.get('active_id', None) |
1068 | + return result |
1069 | + |
1070 | + def onchange_fiscalyear(self, cr, uid, ids, fiscalyear_id=False, context=None): |
1071 | + res = {} |
1072 | + res['value'] = {} |
1073 | + if fiscalyear_id: |
1074 | + start_period = end_period = False |
1075 | + cr.execute(''' |
1076 | + SELECT * FROM (SELECT p.id |
1077 | + FROM account_period p |
1078 | + LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id) |
1079 | + WHERE f.id = %s |
1080 | + ORDER BY p.date_start ASC |
1081 | + LIMIT 1) AS period_start |
1082 | + UNION |
1083 | + SELECT * FROM (SELECT p.id |
1084 | + FROM account_period p |
1085 | + LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id) |
1086 | + WHERE f.id = %s |
1087 | + AND p.date_start < NOW() |
1088 | + ORDER BY p.date_stop DESC |
1089 | + LIMIT 1) AS period_stop''', (fiscalyear_id, fiscalyear_id)) |
1090 | + periods = [i[0] for i in cr.fetchall()] |
1091 | + if periods and len(periods) > 1: |
1092 | + start_period = periods[0] |
1093 | + end_period = periods[1] |
1094 | + res['value'] = {'period_from': start_period, 'period_to': end_period} |
1095 | + return res |
1096 | + |
1097 | + def open_window(self, cr, uid, ids, context=None): |
1098 | + """ |
1099 | + Opens chart of Accounts |
1100 | + @param cr: the current row, from the database cursor, |
1101 | + @param uid: the current user’s ID for security checks, |
1102 | + @param ids: List of account chart’s IDs |
1103 | + @return: dictionary of Open account chart window on given fiscalyear and all Entries or posted entries |
1104 | + """ |
1105 | + mod_obj = self.pool.get('ir.model.data') |
1106 | + act_obj = self.pool.get('ir.actions.act_window') |
1107 | + period_obj = self.pool.get('account.period') |
1108 | + fy_obj = self.pool.get('account.fiscalyear') |
1109 | + if context is None: |
1110 | + context = {} |
1111 | + data = self.read(cr, uid, ids, [], context=context)[0] |
1112 | + result = mod_obj.get_object_reference(cr, uid, 'account_fstr', 'action_account_fstr_category_tree') |
1113 | + id = result and result[1] or False |
1114 | + result = act_obj.read(cr, uid, [id], context=context)[0] |
1115 | + result['periods'] = [] |
1116 | + if data['period_from'] and data['period_to']: |
1117 | + result['periods'] = period_obj.build_ctx_periods(cr, uid, data['period_from'][0], data['period_to'][0]) |
1118 | + result['context'] = str({'fiscalyear': data['fiscalyear'][0], 'periods': result['periods'], 'state': data['target_move']}) |
1119 | + if data['fiscalyear']: |
1120 | + result['name'] += ':' + fy_obj.read(cr, uid, [data['fiscalyear'][0]], context=context)[0]['code'] |
1121 | + result['domain'] = [('id', '=', data['root_node'][0])] |
1122 | + return result |
1123 | + |
1124 | + def print_template(self, cr, uid, ids, context={}): |
1125 | + period_obj = self.pool.get('account.period') |
1126 | + data = self.read(cr, uid, ids, [], context=context)[0] |
1127 | + data_obj = self.browse(cr, uid, ids, context=context)[0] |
1128 | + datas = {'periods': [], 'ids': ids} |
1129 | + if data['period_from'] and data['period_to']: |
1130 | + context['periods'] = period_obj.build_ctx_periods(cr, uid, data['period_from'][0], data['period_to'][0]) |
1131 | + datas['context'] = str({'fiscalyear': data['fiscalyear'], 'periods': datas['periods'], \ |
1132 | + 'state': data['target_move']}) |
1133 | + datas['period_from'] = data_obj.period_from.name |
1134 | + datas['period_to'] = data_obj.period_to.name |
1135 | + datas['fiscalyear'] = data_obj.fiscalyear.name |
1136 | + context['account_fstr_root_node'] = data['root_node'] |
1137 | + context['hide_zero'] = data['hide_zero'] |
1138 | + return { |
1139 | + 'type': 'ir.actions.report.xml', |
1140 | + 'report_name': 'account_fstr.report', |
1141 | + 'datas': datas, |
1142 | + 'context': context, |
1143 | + } |
1144 | + |
1145 | + _defaults = { |
1146 | + 'target_move': 'posted' |
1147 | + } |
1148 | + |
1149 | +account_fstr_wizard() |
1150 | + |
1151 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |