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