Merge lp:~camptocamp/account-consolidation/7.0-account_consolidation-migr into lp:~account-core-editors/account-consolidation/7.0
- 7.0-account_consolidation-migr
- Merge into 7.0
Proposed by
Guewen Baconnier @ Camptocamp
Status: | Merged |
---|---|
Merge reported by: | Joël Grand-Guillaume @ camptocamp |
Merged at revision: | not available |
Proposed branch: | lp:~camptocamp/account-consolidation/7.0-account_consolidation-migr |
Merge into: | lp:~account-core-editors/account-consolidation/7.0 |
Diff against target: |
2360 lines (+873/-850) 12 files modified
account_consolidation/__openerp__.py (+36/-35) account_consolidation/account.py (+47/-53) account_consolidation/account_view.xml (+5/-5) account_consolidation/company.py (+29/-40) account_consolidation/demo/consolidation_demo.xml (+17/-19) account_consolidation/test/consolidation_checks.yml (+4/-3) account_consolidation/test/test_data.yml (+147/-147) account_consolidation/wizard/consolidation_base.py (+186/-158) account_consolidation/wizard/consolidation_check.py (+66/-84) account_consolidation/wizard/consolidation_check_view.xml (+35/-24) account_consolidation/wizard/consolidation_consolidate.py (+262/-252) account_consolidation/wizard/consolidation_consolidate_view.xml (+39/-30) |
To merge this branch: | bzr merge lp:~camptocamp/account-consolidation/7.0-account_consolidation-migr |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexandre Fayolle - camptocamp | Approve | ||
Review via email: mp+142453@code.launchpad.net |
Commit message
[MIGR] Migration of account_
Description of the change
Migration of the 'account_
Updated:
* views
* python formatting / style
* tests
* license changed from GPLv2 to AGPLv3
To post a comment you must log in.
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote : | # |
review:
Needs Fixing
(code review, no test)
- 26. By Guewen Baconnier @ Camptocamp
-
[FIX] unclear docstring
- 27. By Guewen Baconnier @ Camptocamp
-
[FIX] currency rate type should return an id instead of a browse record, fix the docstring as well
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
I fixed both issues.
You are right for the second one, it was a bug.
Thanks for your review!
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote : | # |
OK for merge then
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'account_consolidation/__openerp__.py' | |||
2 | --- account_consolidation/__openerp__.py 2013-01-04 10:28:46 +0000 | |||
3 | +++ account_consolidation/__openerp__.py 2013-01-09 09:53:22 +0000 | |||
4 | @@ -1,47 +1,49 @@ | |||
5 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
6 | 2 | ############################################################################## | 2 | ############################################################################## |
7 | 3 | # | 3 | # |
33 | 4 | # Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com) | 4 | # Author: Guewen Baconnier |
34 | 5 | # All Right Reserved | 5 | # Copyright 2011-2013 Camptocamp SA |
35 | 6 | # | 6 | # |
36 | 7 | # Author : Guewen Baconnier (Camptocamp) | 7 | # This program is free software: you can redistribute it and/or modify |
37 | 8 | # | 8 | # it under the terms of the GNU Affero General Public License as |
38 | 9 | # WARNING: This program as such is intended to be used by professional | 9 | # published by the Free Software Foundation, either version 3 of the |
39 | 10 | # programmers who take the whole responsability of assessing all potential | 10 | # License, or (at your option) any later version. |
40 | 11 | # consequences resulting from its eventual inadequacies and bugs | 11 | # |
41 | 12 | # End users who are looking for a ready-to-use solution with commercial | 12 | # This program is distributed in the hope that it will be useful, |
42 | 13 | # garantees and support are strongly adviced to contract a Free Software | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
43 | 14 | # Service Company | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
44 | 15 | # | 15 | # GNU Affero General Public License for more details. |
45 | 16 | # This program is Free Software; you can redistribute it and/or | 16 | # |
46 | 17 | # modify it under the terms of the GNU General Public License | 17 | # You should have received a copy of the GNU Affero General Public License |
47 | 18 | # as published by the Free Software Foundation; either version 2 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
23 | 19 | # of the License, or (at your option) any later version. | ||
24 | 20 | # | ||
25 | 21 | # This program is distributed in the hope that it will be useful, | ||
26 | 22 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
27 | 23 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
28 | 24 | # GNU General Public License for more details. | ||
29 | 25 | # | ||
30 | 26 | # You should have received a copy of the GNU General Public License | ||
31 | 27 | # along with this program; if not, write to the Free Software | ||
32 | 28 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
48 | 29 | # | 19 | # |
49 | 30 | ############################################################################## | 20 | ############################################################################## |
50 | 31 | 21 | ||
51 | 32 | |||
52 | 33 | { | 22 | { |
53 | 34 | "name" : "Account Consolidation", | 23 | "name" : "Account Consolidation", |
55 | 35 | "version" : "0.0", | 24 | "version" : "1.0", |
56 | 36 | "author" : "Camptocamp", | 25 | "author" : "Camptocamp", |
57 | 26 | 'license': 'AGPL-3', | ||
58 | 37 | "category" : "Generic Modules/Accounting", | 27 | "category" : "Generic Modules/Accounting", |
59 | 38 | "description": | 28 | "description": |
60 | 39 | """ | 29 | """ |
66 | 40 | Account consolidation module. Coding in progress... | 30 | Account consolidation |
67 | 41 | 31 | ===================== | |
68 | 42 | Some explanations to do... | 32 | |
69 | 43 | 33 | Introduction | |
70 | 44 | - Difference between debit/credit is balanced on the debit/credit default account of the journal? | 34 | ------------ |
71 | 35 | |||
72 | 36 | Consolidate chart of accounts on subsidiaries | ||
73 | 37 | in a virtual chart of accounts of the holding. | ||
74 | 38 | |||
75 | 39 | Installation | ||
76 | 40 | ------------ | ||
77 | 41 | The `account_reversal` module is required, | ||
78 | 42 | it can be found on the account-financial-tools_ | ||
79 | 43 | project | ||
80 | 44 | |||
81 | 45 | .. _account-financial-tools: https://launchpad.net/account-financial-tools | ||
82 | 46 | |||
83 | 45 | """, | 47 | """, |
84 | 46 | "website": "http://www.camptocamp.com", | 48 | "website": "http://www.camptocamp.com", |
85 | 47 | "depends" : [ | 49 | "depends" : [ |
86 | @@ -49,13 +51,12 @@ | |||
87 | 49 | 'account', | 51 | 'account', |
88 | 50 | 'account_reversal', | 52 | 'account_reversal', |
89 | 51 | ], | 53 | ], |
90 | 52 | "init_xml" : [], | ||
91 | 53 | "demo_xml" : [ | 54 | "demo_xml" : [ |
92 | 54 | 'demo/consolidation_demo.xml', | 55 | 'demo/consolidation_demo.xml', |
93 | 55 | 'demo/chart_a_demo.xml', | 56 | 'demo/chart_a_demo.xml', |
94 | 56 | 'demo/chart_b_demo.xml', | 57 | 'demo/chart_b_demo.xml', |
95 | 57 | ], | 58 | ], |
97 | 58 | "update_xml" : [ | 59 | "data" : [ |
98 | 59 | 'company_view.xml', | 60 | 'company_view.xml', |
99 | 60 | 'account_view.xml', | 61 | 'account_view.xml', |
100 | 61 | 'wizard/consolidation_check_view.xml', | 62 | 'wizard/consolidation_check_view.xml', |
101 | @@ -68,5 +69,5 @@ | |||
102 | 68 | 'test/consolidation_consolidate.yml', | 69 | 'test/consolidation_consolidate.yml', |
103 | 69 | ], | 70 | ], |
104 | 70 | "active": False, | 71 | "active": False, |
106 | 71 | "installable": False, | 72 | "installable": True, |
107 | 72 | } | 73 | } |
108 | 73 | 74 | ||
109 | === modified file 'account_consolidation/account.py' | |||
110 | --- account_consolidation/account.py 2011-08-29 14:04:57 +0000 | |||
111 | +++ account_consolidation/account.py 2013-01-09 09:53:22 +0000 | |||
112 | @@ -1,77 +1,71 @@ | |||
113 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
114 | 2 | ############################################################################## | 2 | ############################################################################## |
115 | 3 | # | 3 | # |
140 | 4 | # Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com) | 4 | # Author: Guewen Baconnier |
141 | 5 | # | 5 | # Copyright 2011-2013 Camptocamp SA |
142 | 6 | # Author : Guewen Baconnier (Camptocamp) | 6 | # |
143 | 7 | # | 7 | # This program is free software: you can redistribute it and/or modify |
144 | 8 | # WARNING: This program as such is intended to be used by professional | 8 | # it under the terms of the GNU Affero General Public License as |
145 | 9 | # programmers who take the whole responsability of assessing all potential | 9 | # published by the Free Software Foundation, either version 3 of the |
146 | 10 | # consequences resulting from its eventual inadequacies and bugs | 10 | # License, or (at your option) any later version. |
147 | 11 | # End users who are looking for a ready-to-use solution with commercial | 11 | # |
148 | 12 | # garantees and support are strongly adviced to contract a Free Software | 12 | # This program is distributed in the hope that it will be useful, |
149 | 13 | # Service Company | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
150 | 14 | # | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
151 | 15 | # This program is Free Software; you can redistribute it and/or | 15 | # GNU Affero General Public License for more details. |
152 | 16 | # modify it under the terms of the GNU General Public License | 16 | # |
153 | 17 | # as published by the Free Software Foundation; either version 2 | 17 | # You should have received a copy of the GNU Affero General Public License |
154 | 18 | # of the License, or (at your option) any later version. | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
131 | 19 | # | ||
132 | 20 | # This program is distributed in the hope that it will be useful, | ||
133 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
134 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
135 | 23 | # GNU General Public License for more details. | ||
136 | 24 | # | ||
137 | 25 | # You should have received a copy of the GNU General Public License | ||
138 | 26 | # along with this program; if not, write to the Free Software | ||
139 | 27 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
155 | 28 | # | 19 | # |
156 | 29 | ############################################################################## | 20 | ############################################################################## |
157 | 30 | 21 | ||
162 | 31 | from osv import osv, fields | 22 | from openerp.osv import orm, fields |
163 | 32 | 23 | ||
164 | 33 | 24 | ||
165 | 34 | class account_account(osv.osv): | 25 | class account_account(orm.Model): |
166 | 35 | _inherit = 'account.account' | 26 | _inherit = 'account.account' |
167 | 36 | 27 | ||
168 | 37 | _columns = { | 28 | _columns = { |
177 | 38 | 'consolidation_rate_type_id': fields.many2one('res.currency.rate.type', | 29 | 'consolidation_rate_type_id': fields.many2one( |
178 | 39 | 'Consolidation Currency Rate Type', | 30 | 'res.currency.rate.type', |
179 | 40 | help="Currency rate type used on this account for the consolidation, Leave empty to use the rate type of the account type."), | 31 | 'Consolidation Currency Rate Type', |
180 | 41 | 'consolidation_mode': fields.selection([('', ''), | 32 | help="Currency rate type used on this account " |
181 | 42 | ('ytd', 'YTD'), | 33 | "for the consolidation. " |
182 | 43 | ('period', 'Period Movements'), | 34 | "Leave empty to use the rate type of the account type."), |
183 | 44 | ], | 35 | 'consolidation_mode': fields.selection( |
184 | 45 | 'Consolidation Mode'), | 36 | [('ytd', 'YTD'), |
185 | 37 | ('period', 'Period Movements')], | ||
186 | 38 | 'Consolidation Mode'), | ||
187 | 46 | } | 39 | } |
188 | 47 | 40 | ||
193 | 48 | account_account() | 41 | |
194 | 49 | 42 | class account_account_type(orm.Model): | |
191 | 50 | |||
192 | 51 | class account_account_type(osv.osv): | ||
195 | 52 | _inherit = 'account.account.type' | 43 | _inherit = 'account.account.type' |
196 | 53 | 44 | ||
197 | 54 | _columns = { | 45 | _columns = { |
204 | 55 | 'consolidation_rate_type_id': fields.many2one('res.currency.rate.type', | 46 | 'consolidation_rate_type_id': fields.many2one( |
205 | 56 | 'Consolidation Currency Rate Type', | 47 | 'res.currency.rate.type', |
206 | 57 | help="Currency rate type used on this account type for the consolidation, Leave empty to use the 'spot' rate type."), | 48 | 'Consolidation Currency Rate Type', |
207 | 58 | 'consolidation_mode': fields.selection([('ytd', 'YTD'), | 49 | help="Currency rate type used on this account type " |
208 | 59 | ('period', 'Period Movements'),], | 50 | "for the consolidation. " |
209 | 60 | 'Consolidation Mode'), | 51 | "Leave empty to use the 'spot' rate type."), |
210 | 52 | 'consolidation_mode': fields.selection( | ||
211 | 53 | [('ytd', 'YTD'), | ||
212 | 54 | ('period', 'Period Movements')], | ||
213 | 55 | 'Consolidation Mode'), | ||
214 | 61 | } | 56 | } |
215 | 62 | 57 | ||
216 | 63 | _defaults = { | 58 | _defaults = { |
217 | 64 | 'consolidation_mode': 'ytd', | 59 | 'consolidation_mode': 'ytd', |
218 | 65 | } | 60 | } |
219 | 66 | 61 | ||
224 | 67 | account_account_type() | 62 | |
225 | 68 | 63 | class account_move(orm.Model): | |
222 | 69 | |||
223 | 70 | class account_move(osv.osv): | ||
226 | 71 | _inherit = 'account.move' | 64 | _inherit = 'account.move' |
227 | 72 | 65 | ||
228 | 73 | _columns = { | 66 | _columns = { |
230 | 74 | 'consol_company_id': fields.many2one('res.company', 'Consolidated from Company', readonly=True), | 67 | 'consol_company_id': fields.many2one( |
231 | 68 | 'res.company', | ||
232 | 69 | 'Consolidated from Company', | ||
233 | 70 | readonly=True), | ||
234 | 75 | } | 71 | } |
235 | 76 | |||
236 | 77 | account_move() | ||
237 | 78 | 72 | ||
238 | === modified file 'account_consolidation/account_view.xml' | |||
239 | --- account_consolidation/account_view.xml 2011-08-29 14:04:57 +0000 | |||
240 | +++ account_consolidation/account_view.xml 2013-01-09 09:53:22 +0000 | |||
241 | @@ -9,8 +9,8 @@ | |||
242 | 9 | <field name="type">form</field> | 9 | <field name="type">form</field> |
243 | 10 | <field name="arch" type="xml"> | 10 | <field name="arch" type="xml"> |
244 | 11 | <data> | 11 | <data> |
247 | 12 | <xpath expr="/form/notebook/page[@string='General Information']/group[2]" position="after"> | 12 | <xpath expr="//field[@name='note']" position="after"> |
248 | 13 | <group col="2" colspan="2"> | 13 | <group> |
249 | 14 | <separator string="Consolidation" colspan="2"/> | 14 | <separator string="Consolidation" colspan="2"/> |
250 | 15 | <field name="consolidation_rate_type_id" widget="selection"/> | 15 | <field name="consolidation_rate_type_id" widget="selection"/> |
251 | 16 | <field name="consolidation_mode"/> | 16 | <field name="consolidation_mode"/> |
252 | @@ -20,7 +20,7 @@ | |||
253 | 20 | </data> | 20 | </data> |
254 | 21 | </field> | 21 | </field> |
255 | 22 | </record> | 22 | </record> |
257 | 23 | 23 | ||
258 | 24 | <record id="view_account_type_consolidation_form" model="ir.ui.view"> | 24 | <record id="view_account_type_consolidation_form" model="ir.ui.view"> |
259 | 25 | <field name="name">account.account.type.consolidation.form</field> | 25 | <field name="name">account.account.type.consolidation.form</field> |
260 | 26 | <field name="model">account.account.type</field> | 26 | <field name="model">account.account.type</field> |
261 | @@ -44,11 +44,11 @@ | |||
262 | 44 | <field name="type">form</field> | 44 | <field name="type">form</field> |
263 | 45 | <field name="arch" type="xml"> | 45 | <field name="arch" type="xml"> |
264 | 46 | <field name="company_id" position="after"> | 46 | <field name="company_id" position="after"> |
266 | 47 | <field name="consol_company_id" attrs="{'invisible': [('consol_company_id', '=', False)]}"/> | 47 | <field name="consol_company_id" |
267 | 48 | attrs="{'invisible': [('consol_company_id', '=', False)]}"/> | ||
268 | 48 | </field> | 49 | </field> |
269 | 49 | </field> | 50 | </field> |
270 | 50 | </record> | 51 | </record> |
271 | 51 | 52 | ||
272 | 52 | </data> | 53 | </data> |
273 | 53 | </openerp> | 54 | </openerp> |
274 | 54 | |||
275 | 55 | 55 | ||
276 | === modified file 'account_consolidation/company.py' | |||
277 | --- account_consolidation/company.py 2011-08-19 07:16:03 +0000 | |||
278 | +++ account_consolidation/company.py 2013-01-09 09:53:22 +0000 | |||
279 | @@ -1,44 +1,33 @@ | |||
315 | 1 | # -*- coding: utf-8 -*- | 1 | # -* coding: utf-8 -*- |
316 | 2 | ############################################################################## | 2 | ############################################################################## |
317 | 3 | # | 3 | # |
318 | 4 | # Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com) | 4 | # Author: Guewen Baconnier |
319 | 5 | # All Right Reserved | 5 | # Copyright 2011-2013 Camptocamp SA |
320 | 6 | # | 6 | # |
321 | 7 | # Author : Guewen Baconnier (Camptocamp) | 7 | # This program is free software: you can redistribute it and/or modify |
322 | 8 | # | 8 | # it under the terms of the GNU Affero General Public License as |
323 | 9 | # WARNING: This program as such is intended to be used by professional | 9 | # published by the Free Software Foundation, either version 3 of the |
324 | 10 | # programmers who take the whole responsability of assessing all potential | 10 | # License, or (at your option) any later version. |
325 | 11 | # consequences resulting from its eventual inadequacies and bugs | 11 | # |
326 | 12 | # End users who are looking for a ready-to-use solution with commercial | 12 | # This program is distributed in the hope that it will be useful, |
327 | 13 | # garantees and support are strongly adviced to contract a Free Software | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
328 | 14 | # Service Company | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
329 | 15 | # | 15 | # GNU Affero General Public License for more details. |
330 | 16 | # This program is Free Software; you can redistribute it and/or | 16 | # |
331 | 17 | # modify it under the terms of the GNU General Public License | 17 | # You should have received a copy of the GNU Affero General Public License |
332 | 18 | # as published by the Free Software Foundation; either version 2 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
333 | 19 | # of the License, or (at your option) any later version. | 19 | # |
334 | 20 | # | 20 | ############################################################################## |
335 | 21 | # This program is distributed in the hope that it will be useful, | 21 | |
336 | 22 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | from openerp.osv import orm, fields |
337 | 23 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 23 | |
338 | 24 | # GNU General Public License for more details. | 24 | |
339 | 25 | # | 25 | class res_company(orm.Model): |
305 | 26 | # You should have received a copy of the GNU General Public License | ||
306 | 27 | # along with this program; if not, write to the Free Software | ||
307 | 28 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
308 | 29 | # | ||
309 | 30 | ############################################################################## | ||
310 | 31 | |||
311 | 32 | from osv import osv, fields | ||
312 | 33 | |||
313 | 34 | |||
314 | 35 | class res_company(osv.osv): | ||
340 | 36 | _inherit = 'res.company' | 26 | _inherit = 'res.company' |
341 | 37 | 27 | ||
342 | 38 | _columns = { | 28 | _columns = { |
346 | 39 | 'consolidation_chart_account_id': fields.many2one('account.account', | 29 | 'consolidation_chart_account_id': fields.many2one( |
347 | 40 | 'Chart of Accounts for Consolidation', | 30 | 'account.account', |
348 | 41 | domain=[('parent_id', '=', False)]), | 31 | 'Chart of Accounts for Consolidation', |
349 | 32 | domain=[('parent_id', '=', False)]), | ||
350 | 42 | } | 33 | } |
351 | 43 | |||
352 | 44 | res_company() | ||
353 | 45 | 34 | ||
354 | === modified file 'account_consolidation/demo/consolidation_demo.xml' | |||
355 | --- account_consolidation/demo/consolidation_demo.xml 2012-04-18 14:35:42 +0000 | |||
356 | +++ account_consolidation/demo/consolidation_demo.xml 2013-01-09 09:53:22 +0000 | |||
357 | @@ -183,7 +183,7 @@ | |||
358 | 183 | <field name="company_id" ref="subsidiary_a"/> | 183 | <field name="company_id" ref="subsidiary_a"/> |
359 | 184 | </record> | 184 | </record> |
360 | 185 | 185 | ||
362 | 186 | <record id="period_b_1" model="account.period"> | 186 | <record id="period_b_1" model="account.period"> |
363 | 187 | <field eval="'01/'+time.strftime('%Y')" name="code"/> | 187 | <field eval="'01/'+time.strftime('%Y')" name="code"/> |
364 | 188 | <field eval="'01/'+time.strftime('%Y')" name="name"/> | 188 | <field eval="'01/'+time.strftime('%Y')" name="name"/> |
365 | 189 | <field eval="True" name="special"/> | 189 | <field eval="True" name="special"/> |
366 | @@ -292,25 +292,23 @@ | |||
367 | 292 | <field name="company_id" ref="subsidiary_b"/> | 292 | <field name="company_id" ref="subsidiary_b"/> |
368 | 293 | </record> | 293 | </record> |
369 | 294 | 294 | ||
379 | 295 | <record id="account_journal_sale0" model="account.journal"> | 295 | <record id="account_journal_sale0" model="account.journal"> |
380 | 296 | <field name="code">SALE</field> | 296 | <field name="code">SALE</field> |
381 | 297 | <field name="name">SALE</field> | 297 | <field name="name">SALE</field> |
382 | 298 | <field name="view_id" ref="account.account_sp_journal_view"/> | 298 | <field name="company_id" ref="account_consolidation.subsidiary_a"/> |
383 | 299 | <field name="company_id" ref="account_consolidation.subsidiary_a"/> | 299 | <field name="sequence_id" ref="account.sequence_sale_journal"/> |
384 | 300 | <field name="sequence_id" ref="account.sequence_sale_journal"/> | 300 | <field eval="1" name="allow_date"/> |
385 | 301 | <field eval="1" name="allow_date"/> | 301 | <field name="type">sale</field> |
386 | 302 | <field name="type">sale</field> | 302 | </record> |
378 | 303 | </record> | ||
387 | 304 | 303 | ||
397 | 305 | <record id="account_journal_sale1" model="account.journal"> | 304 | <record id="account_journal_sale1" model="account.journal"> |
398 | 306 | <field name="code">SALE</field> | 305 | <field name="code">SALE</field> |
399 | 307 | <field name="name">SALE</field> | 306 | <field name="name">SALE</field> |
400 | 308 | <field name="view_id" ref="account.account_sp_journal_view"/> | 307 | <field name="company_id" ref="account_consolidation.subsidiary_b"/> |
401 | 309 | <field name="company_id" ref="account_consolidation.subsidiary_b"/> | 308 | <field name="sequence_id" ref="account.sequence_sale_journal"/> |
402 | 310 | <field name="sequence_id" ref="account.sequence_sale_journal"/> | 309 | <field eval="1" name="allow_date"/> |
403 | 311 | <field eval="1" name="allow_date"/> | 310 | <field name="type">sale</field> |
404 | 312 | <field name="type">sale</field> | 311 | </record> |
396 | 313 | </record> | ||
405 | 314 | 312 | ||
406 | 315 | </data> | 313 | </data> |
407 | 316 | </openerp> | 314 | </openerp> |
408 | 317 | 315 | ||
409 | === modified file 'account_consolidation/test/consolidation_checks.yml' | |||
410 | --- account_consolidation/test/consolidation_checks.yml 2011-08-19 13:08:01 +0000 | |||
411 | +++ account_consolidation/test/consolidation_checks.yml 2013-01-09 09:53:22 +0000 | |||
412 | @@ -42,7 +42,8 @@ | |||
413 | 42 | raise | 42 | raise |
414 | 43 | 43 | ||
415 | 44 | - | 44 | - |
417 | 45 | In order to test the consolidation checks on misconfigured periods, I use the wizard on FY2012 | 45 | In order to test the consolidation checks on misconfigured periods, I use the wizard on the next year |
418 | 46 | which is misconfigured | ||
419 | 46 | - | 47 | - |
420 | 47 | !record {model: account.consolidation.check, id: conso_check_period_1}: | 48 | !record {model: account.consolidation.check, id: conso_check_period_1}: |
421 | 48 | fiscalyear_id: account_fiscalyear_fy0 | 49 | fiscalyear_id: account_fiscalyear_fy0 |
422 | @@ -79,8 +80,8 @@ | |||
423 | 79 | name: Virtual Account Spare | 80 | name: Virtual Account Spare |
424 | 80 | parent_id: account_consolidation.virtual_chart_subsidiary_a | 81 | parent_id: account_consolidation.virtual_chart_subsidiary_a |
425 | 81 | type: consolidation | 82 | type: consolidation |
428 | 82 | user_type: account.account_type_expense | 83 | user_type: account.data_account_type_expense |
429 | 83 | 84 | ||
430 | 84 | - | 85 | - |
431 | 85 | In order to test the consolidation checks on misconfigured charts, I use the wizard | 86 | In order to test the consolidation checks on misconfigured charts, I use the wizard |
432 | 86 | - | 87 | - |
433 | 87 | 88 | ||
434 | === modified file 'account_consolidation/test/test_data.yml' | |||
435 | --- account_consolidation/test/test_data.yml 2011-08-19 13:08:01 +0000 | |||
436 | +++ account_consolidation/test/test_data.yml 2013-01-09 09:53:22 +0000 | |||
437 | @@ -3,14 +3,14 @@ | |||
438 | 3 | - | 3 | - |
439 | 4 | !record {model: account.move, id: account_move_0}: | 4 | !record {model: account.move, id: account_move_0}: |
440 | 5 | company_id: subsidiary_b | 5 | company_id: subsidiary_b |
442 | 6 | date: '2011-01-02' | 6 | date: !eval "'%s-01-02' % datetime.now().year" |
443 | 7 | journal_id: account_journal_sale1 | 7 | journal_id: account_journal_sale1 |
444 | 8 | line_id: | 8 | line_id: |
445 | 9 | - company_id: subsidiary_b | 9 | - company_id: subsidiary_b |
446 | 10 | account_id: a_sale_b | 10 | account_id: a_sale_b |
447 | 11 | amount_currency: 0.0 | 11 | amount_currency: 0.0 |
448 | 12 | credit: 0.0 | 12 | credit: 0.0 |
450 | 13 | date: '2011-01-01' | 13 | date: !eval "'%s-01-02' % datetime.now().year" |
451 | 14 | debit: 1240.0 | 14 | debit: 1240.0 |
452 | 15 | journal_id: account_journal_sale1 | 15 | journal_id: account_journal_sale1 |
453 | 16 | name: Entry 0 | 16 | name: Entry 0 |
454 | @@ -22,7 +22,7 @@ | |||
455 | 22 | account_id: cog_b | 22 | account_id: cog_b |
456 | 23 | amount_currency: 0.0 | 23 | amount_currency: 0.0 |
457 | 24 | credit: 1240.0 | 24 | credit: 1240.0 |
459 | 25 | date: '2011-01-01' | 25 | date: !eval "'%s-01-02' % datetime.now().year" |
460 | 26 | debit: 0.0 | 26 | debit: 0.0 |
461 | 27 | journal_id: account_journal_sale1 | 27 | journal_id: account_journal_sale1 |
462 | 28 | name: Entry 0 | 28 | name: Entry 0 |
463 | @@ -40,14 +40,14 @@ | |||
464 | 40 | - | 40 | - |
465 | 41 | !record {model: account.move, id: account_move_1}: | 41 | !record {model: account.move, id: account_move_1}: |
466 | 42 | company_id: account_consolidation.subsidiary_a | 42 | company_id: account_consolidation.subsidiary_a |
468 | 43 | date: '2011-01-20' | 43 | date: !eval "'%s-01-20' % datetime.now().year" |
469 | 44 | journal_id: account_journal_sale0 | 44 | journal_id: account_journal_sale0 |
470 | 45 | line_id: | 45 | line_id: |
471 | 46 | - account_id: account_consolidation.a_sale_a | 46 | - account_id: account_consolidation.a_sale_a |
472 | 47 | amount_currency: 0.0 | 47 | amount_currency: 0.0 |
473 | 48 | company_id: account_consolidation.subsidiary_a | 48 | company_id: account_consolidation.subsidiary_a |
474 | 49 | credit: 0.0 | 49 | credit: 0.0 |
476 | 50 | date: '2011-01-20' | 50 | date: !eval "'%s-01-20' % datetime.now().year" |
477 | 51 | debit: 40.0 | 51 | debit: 40.0 |
478 | 52 | journal_id: account_journal_sale0 | 52 | journal_id: account_journal_sale0 |
479 | 53 | name: Entry 1 | 53 | name: Entry 1 |
480 | @@ -59,7 +59,7 @@ | |||
481 | 59 | amount_currency: 0.0 | 59 | amount_currency: 0.0 |
482 | 60 | company_id: account_consolidation.subsidiary_a | 60 | company_id: account_consolidation.subsidiary_a |
483 | 61 | credit: 40.0 | 61 | credit: 40.0 |
485 | 62 | date: '2011-01-20' | 62 | date: !eval "'%s-01-20' % datetime.now().year" |
486 | 63 | debit: 0.0 | 63 | debit: 0.0 |
487 | 64 | journal_id: account_journal_sale0 | 64 | journal_id: account_journal_sale0 |
488 | 65 | name: Entry 1 | 65 | name: Entry 1 |
489 | @@ -77,14 +77,14 @@ | |||
490 | 77 | - | 77 | - |
491 | 78 | !record {model: account.move, id: account_move_2}: | 78 | !record {model: account.move, id: account_move_2}: |
492 | 79 | company_id: account_consolidation.subsidiary_a | 79 | company_id: account_consolidation.subsidiary_a |
494 | 80 | date: '2011-02-23' | 80 | date: !eval "'%s-02-23' % datetime.now().year" |
495 | 81 | journal_id: account_journal_sale0 | 81 | journal_id: account_journal_sale0 |
496 | 82 | line_id: | 82 | line_id: |
497 | 83 | - account_id: account_consolidation.a_sale_a | 83 | - account_id: account_consolidation.a_sale_a |
498 | 84 | amount_currency: 0.0 | 84 | amount_currency: 0.0 |
499 | 85 | company_id: account_consolidation.subsidiary_a | 85 | company_id: account_consolidation.subsidiary_a |
500 | 86 | credit: 0.0 | 86 | credit: 0.0 |
502 | 87 | date: '2011-02-01' | 87 | date: !eval "'%s-02-23' % datetime.now().year" |
503 | 88 | debit: 200.0 | 88 | debit: 200.0 |
504 | 89 | journal_id: account_journal_sale0 | 89 | journal_id: account_journal_sale0 |
505 | 90 | name: Entry 2 | 90 | name: Entry 2 |
506 | @@ -96,7 +96,7 @@ | |||
507 | 96 | amount_currency: 0.0 | 96 | amount_currency: 0.0 |
508 | 97 | company_id: account_consolidation.subsidiary_a | 97 | company_id: account_consolidation.subsidiary_a |
509 | 98 | credit: 200.0 | 98 | credit: 200.0 |
511 | 99 | date: '2011-02-01' | 99 | date: !eval "'%s-02-23' % datetime.now().year" |
512 | 100 | debit: 0.0 | 100 | debit: 0.0 |
513 | 101 | journal_id: account_journal_sale0 | 101 | journal_id: account_journal_sale0 |
514 | 102 | name: Entry 2 | 102 | name: Entry 2 |
515 | @@ -114,14 +114,14 @@ | |||
516 | 114 | - | 114 | - |
517 | 115 | !record {model: account.move, id: account_move_3}: | 115 | !record {model: account.move, id: account_move_3}: |
518 | 116 | company_id: account_consolidation.subsidiary_a | 116 | company_id: account_consolidation.subsidiary_a |
520 | 117 | date: '2011-01-15' | 117 | date: !eval "'%s-01-15' % datetime.now().year" |
521 | 118 | journal_id: account_journal_sale0 | 118 | journal_id: account_journal_sale0 |
522 | 119 | line_id: | 119 | line_id: |
523 | 120 | - account_id: account_consolidation.cog_a | 120 | - account_id: account_consolidation.cog_a |
524 | 121 | amount_currency: 0.0 | 121 | amount_currency: 0.0 |
525 | 122 | company_id: account_consolidation.subsidiary_a | 122 | company_id: account_consolidation.subsidiary_a |
526 | 123 | credit: 300.0 | 123 | credit: 300.0 |
528 | 124 | date: '2011-01-01' | 124 | date: !eval "'%s-01-15' % datetime.now().year" |
529 | 125 | debit: 0.0 | 125 | debit: 0.0 |
530 | 126 | journal_id: account_journal_sale0 | 126 | journal_id: account_journal_sale0 |
531 | 127 | name: Entry 3 | 127 | name: Entry 3 |
532 | @@ -133,7 +133,7 @@ | |||
533 | 133 | amount_currency: 0.0 | 133 | amount_currency: 0.0 |
534 | 134 | company_id: account_consolidation.subsidiary_a | 134 | company_id: account_consolidation.subsidiary_a |
535 | 135 | credit: 0.0 | 135 | credit: 0.0 |
537 | 136 | date: '2011-01-01' | 136 | date: !eval "'%s-01-15' % datetime.now().year" |
538 | 137 | debit: 300.0 | 137 | debit: 300.0 |
539 | 138 | journal_id: account_journal_sale0 | 138 | journal_id: account_journal_sale0 |
540 | 139 | name: Entry 3 | 139 | name: Entry 3 |
541 | @@ -150,94 +150,94 @@ | |||
542 | 150 | Creating a account.fiscalyear record with a missing period for january | 150 | Creating a account.fiscalyear record with a missing period for january |
543 | 151 | - | 151 | - |
544 | 152 | !record {model: account.fiscalyear, id: account_fiscalyear_fy0}: | 152 | !record {model: account.fiscalyear, id: account_fiscalyear_fy0}: |
546 | 153 | code: FY2012 | 153 | code: !eval "'FY%s' % (datetime.now().year + 1)" |
547 | 154 | company_id: base.main_company | 154 | company_id: base.main_company |
551 | 155 | date_start: '2012-01-01' | 155 | date_start: !eval "'%s-01-01' % (datetime.now().year + 1)" |
552 | 156 | date_stop: '2012-12-31' | 156 | date_stop: !eval "'%s-12-31' % (datetime.now().year + 1)" |
553 | 157 | name: FY2012 | 157 | name: !eval "'FY%s' % (datetime.now().year + 1)" |
554 | 158 | period_ids: | 158 | period_ids: |
556 | 159 | - code: 00/2012 | 159 | - code: !eval "'00/%s' % (datetime.now().year + 1)" |
557 | 160 | company_id: base.main_company | 160 | company_id: base.main_company |
560 | 161 | date_start: '2012-01-01' | 161 | date_start: !eval "'%s-01-01' % (datetime.now().year + 1)" |
561 | 162 | date_stop: '2012-01-01' | 162 | date_stop: !eval "'%s-01-01' % (datetime.now().year + 1)" |
562 | 163 | name: Opening Period | 163 | name: Opening Period |
563 | 164 | special: true | 164 | special: true |
624 | 165 | - code: 01/2012 | 165 | - code: !eval "'01/%s' % (datetime.now().year + 1)" |
625 | 166 | company_id: base.main_company | 166 | company_id: base.main_company |
626 | 167 | date_start: '2012-01-01' | 167 | date_start: !eval "'%s-01-01' % (datetime.now().year + 1)" |
627 | 168 | date_stop: '2012-01-31' | 168 | date_stop: !eval "'%s-01-31' % (datetime.now().year + 1)" |
628 | 169 | name: 01/2012 | 169 | name: !eval "'01/%s' % (datetime.now().year + 1)" |
629 | 170 | - code: 02/2012 | 170 | - code: !eval "'02/%s' % (datetime.now().year + 1)" |
630 | 171 | company_id: base.main_company | 171 | company_id: base.main_company |
631 | 172 | date_start: '2012-02-01' | 172 | date_start: !eval "'%s-02-01' % (datetime.now().year + 1)" |
632 | 173 | date_stop: '2012-02-29' | 173 | date_stop: !eval "'%s-02-%s' % ((datetime.now().year + 1), (datetime((datetime.now().year + 1), 3, 1) - timedelta(days=1)).day)" |
633 | 174 | name: 02/2012 | 174 | name: !eval "'02/%s' % (datetime.now().year + 1)" |
634 | 175 | - code: 03/2012 | 175 | - code: !eval "'03/%s' % (datetime.now().year + 1)" |
635 | 176 | company_id: base.main_company | 176 | company_id: base.main_company |
636 | 177 | date_start: '2012-03-01' | 177 | date_start: !eval "'%s-03-01' % (datetime.now().year + 1)" |
637 | 178 | date_stop: '2012-03-31' | 178 | date_stop: !eval "'%s-03-31' % (datetime.now().year + 1)" |
638 | 179 | name: 03/2012 | 179 | name: !eval "'03/%s' % (datetime.now().year + 1)" |
639 | 180 | - code: 04/2012 | 180 | - code: !eval "'04/%s' % (datetime.now().year + 1)" |
640 | 181 | company_id: base.main_company | 181 | company_id: base.main_company |
641 | 182 | date_start: '2012-04-01' | 182 | date_start: !eval "'%s-04-01' % (datetime.now().year + 1)" |
642 | 183 | date_stop: '2012-04-30' | 183 | date_stop: !eval "'%s-04-30' % (datetime.now().year + 1)" |
643 | 184 | name: 04/2012 | 184 | name: !eval "'04/%s' % (datetime.now().year + 1)" |
644 | 185 | - code: 05/2012 | 185 | - code: !eval "'05/%s' % (datetime.now().year + 1)" |
645 | 186 | company_id: base.main_company | 186 | company_id: base.main_company |
646 | 187 | date_start: '2012-05-01' | 187 | date_start: !eval "'%s-05-01' % (datetime.now().year + 1)" |
647 | 188 | date_stop: '2012-05-31' | 188 | date_stop: !eval "'%s-05-31' % (datetime.now().year + 1)" |
648 | 189 | name: 05/2012 | 189 | name: !eval "'05/%s' % (datetime.now().year + 1)" |
649 | 190 | - code: 06/2012 | 190 | - code: !eval "'06/%s' % (datetime.now().year + 1)" |
650 | 191 | company_id: base.main_company | 191 | company_id: base.main_company |
651 | 192 | date_start: '2012-06-01' | 192 | date_start: !eval "'%s-06-01' % (datetime.now().year + 1)" |
652 | 193 | date_stop: '2012-06-30' | 193 | date_stop: !eval "'%s-06-30' % (datetime.now().year + 1)" |
653 | 194 | name: 06/2012 | 194 | name: !eval "'06/%s' % (datetime.now().year + 1)" |
654 | 195 | - code: 07/2012 | 195 | - code: !eval "'07/%s' % (datetime.now().year + 1)" |
655 | 196 | company_id: base.main_company | 196 | company_id: base.main_company |
656 | 197 | date_start: '2012-07-01' | 197 | date_start: !eval "'%s-07-01' % (datetime.now().year + 1)" |
657 | 198 | date_stop: '2012-07-31' | 198 | date_stop: !eval "'%s-07-31' % (datetime.now().year + 1)" |
658 | 199 | name: 07/2012 | 199 | name: !eval "'07/%s' % (datetime.now().year + 1)" |
659 | 200 | - code: 08/2012 | 200 | - code: !eval "'08/%s' % (datetime.now().year + 1)" |
660 | 201 | company_id: base.main_company | 201 | company_id: base.main_company |
661 | 202 | date_start: '2012-08-01' | 202 | date_start: !eval "'%s-08-01' % (datetime.now().year + 1)" |
662 | 203 | date_stop: '2012-08-31' | 203 | date_stop: !eval "'%s-08-31' % (datetime.now().year + 1)" |
663 | 204 | name: 08/2012 | 204 | name: !eval "'08/%s' % (datetime.now().year + 1)" |
664 | 205 | - code: 09/2012 | 205 | - code: !eval "'09/%s' % (datetime.now().year + 1)" |
665 | 206 | company_id: base.main_company | 206 | company_id: base.main_company |
666 | 207 | date_start: '2012-09-01' | 207 | date_start: !eval "'%s-09-01' % (datetime.now().year + 1)" |
667 | 208 | date_stop: '2012-09-30' | 208 | date_stop: !eval "'%s-09-30' % (datetime.now().year + 1)" |
668 | 209 | name: 09/2012 | 209 | name: !eval "'09/%s' % (datetime.now().year + 1)" |
669 | 210 | - code: 10/2012 | 210 | - code: !eval "'10/%s' % (datetime.now().year + 1)" |
670 | 211 | company_id: base.main_company | 211 | company_id: base.main_company |
671 | 212 | date_start: '2012-10-01' | 212 | date_start: !eval "'%s-10-01' % (datetime.now().year + 1)" |
672 | 213 | date_stop: '2012-10-31' | 213 | date_stop: !eval "'%s-10-31' % (datetime.now().year + 1)" |
673 | 214 | name: 10/2012 | 214 | name: !eval "'10/%s' % (datetime.now().year + 1)" |
674 | 215 | - code: 11/2012 | 215 | - code: !eval "'11/%s' % (datetime.now().year + 1)" |
675 | 216 | company_id: base.main_company | 216 | company_id: base.main_company |
676 | 217 | date_start: '2012-11-01' | 217 | date_start: !eval "'%s-11-01' % (datetime.now().year + 1)" |
677 | 218 | date_stop: '2012-11-30' | 218 | date_stop: !eval "'%s-11-30' % (datetime.now().year + 1)" |
678 | 219 | name: 11/2012 | 219 | name: !eval "'11/%s' % (datetime.now().year + 1)" |
679 | 220 | - code: 12/2012 | 220 | - code: !eval "'12/%s' % (datetime.now().year + 1)" |
680 | 221 | company_id: base.main_company | 221 | company_id: base.main_company |
681 | 222 | date_start: '2012-12-01' | 222 | date_start: !eval "'%s-12-01' % (datetime.now().year + 1)" |
682 | 223 | date_stop: '2012-12-31' | 223 | date_stop: !eval "'%s-12-31' % (datetime.now().year + 1)" |
683 | 224 | name: 12/2012 | 224 | name: !eval "'12/%s' % (datetime.now().year + 1)" |
684 | 225 | 225 | ||
685 | 226 | 226 | ||
686 | 227 | - | 227 | - |
687 | 228 | Creating a account.fiscalyear record with a period in december but with different dates than the holding | 228 | Creating a account.fiscalyear record with a period in december but with different dates than the holding |
688 | 229 | - | 229 | - |
689 | 230 | !record {model: account.fiscalyear, id: account_fiscalyear_fy1}: | 230 | !record {model: account.fiscalyear, id: account_fiscalyear_fy1}: |
691 | 231 | code: FY2012 | 231 | code: !eval "'FY%s' % (datetime.now().year + 1)" |
692 | 232 | company_id: account_consolidation.subsidiary_b | 232 | company_id: account_consolidation.subsidiary_b |
696 | 233 | date_start: '2012-01-01' | 233 | date_start: !eval "'%s-01-01' % (datetime.now().year + 1)" |
697 | 234 | date_stop: '2012-12-31' | 234 | date_stop: !eval "'%s-12-31' % (datetime.now().year + 1)" |
698 | 235 | name: FY2012 | 235 | name: !eval "'FY%s' % (datetime.now().year + 1)" |
699 | 236 | period_ids: | 236 | period_ids: |
700 | 237 | - code: diff_dates | 237 | - code: diff_dates |
701 | 238 | company_id: account_consolidation.subsidiary_b | 238 | company_id: account_consolidation.subsidiary_b |
704 | 239 | date_start: '2012-12-15' | 239 | date_start: !eval "'%s-12-15' % (datetime.now().year + 1)" |
705 | 240 | date_stop: '2012-12-31' | 240 | date_stop: !eval "'%s-12-31' % (datetime.now().year + 1)" |
706 | 241 | name: diff_dates | 241 | name: diff_dates |
707 | 242 | 242 | ||
708 | 243 | 243 | ||
709 | @@ -245,70 +245,70 @@ | |||
710 | 245 | Creating a account.fiscalyear record on subsidiary with a period for january (missing on holding) | 245 | Creating a account.fiscalyear record on subsidiary with a period for january (missing on holding) |
711 | 246 | - | 246 | - |
712 | 247 | !record {model: account.fiscalyear, id: account_fiscalyear_fy2}: | 247 | !record {model: account.fiscalyear, id: account_fiscalyear_fy2}: |
714 | 248 | code: FY2012 | 248 | code: !eval "'FY%s' % (datetime.now().year + 1)" |
715 | 249 | company_id: account_consolidation.subsidiary_a | 249 | company_id: account_consolidation.subsidiary_a |
719 | 250 | date_start: '2012-01-01' | 250 | date_start: !eval "'%s-01-01' % (datetime.now().year + 1)" |
720 | 251 | date_stop: '2012-12-31' | 251 | date_stop: !eval "'%s-12-31' % (datetime.now().year + 1)" |
721 | 252 | name: FY2012 | 252 | name: !eval "'FY%s' % (datetime.now().year + 1)" |
722 | 253 | period_ids: | 253 | period_ids: |
724 | 254 | - code: 00/2012 | 254 | - code: !eval "'00/%s' % (datetime.now().year + 1)" |
725 | 255 | company_id: account_consolidation.subsidiary_a | 255 | company_id: account_consolidation.subsidiary_a |
728 | 256 | date_start: '2012-01-01' | 256 | date_start: !eval "'%s-01-01' % (datetime.now().year + 1)" |
729 | 257 | date_stop: '2012-01-01' | 257 | date_stop: !eval "'%s-01-01' % (datetime.now().year + 1)" |
730 | 258 | name: Opening Period | 258 | name: Opening Period |
731 | 259 | special: true | 259 | special: true |
787 | 260 | - code: 01/2012 | 260 | - code: !eval "'01/%s' % (datetime.now().year + 1)" |
788 | 261 | company_id: account_consolidation.subsidiary_a | 261 | company_id: account_consolidation.subsidiary_a |
789 | 262 | date_start: '2012-01-01' | 262 | date_start: !eval "'%s-01-01' % (datetime.now().year + 1)" |
790 | 263 | date_stop: '2012-01-31' | 263 | date_stop: !eval "'%s-01-31' % (datetime.now().year + 1)" |
791 | 264 | name: 01/2012 | 264 | name: !eval "'01/%s' % (datetime.now().year + 1)" |
792 | 265 | - code: 02/2012 | 265 | - code: !eval "'02/%s' % (datetime.now().year + 1)" |
793 | 266 | company_id: account_consolidation.subsidiary_a | 266 | company_id: account_consolidation.subsidiary_a |
794 | 267 | date_start: '2012-02-01' | 267 | date_start: !eval "'%s-02-01' % (datetime.now().year + 1)" |
795 | 268 | date_stop: '2012-02-29' | 268 | date_stop: !eval "'%s-02-%s' % ((datetime.now().year + 1), (datetime((datetime.now().year + 1), 3, 1) - timedelta(days=1)).day)" |
796 | 269 | name: 02/2012 | 269 | name: !eval "'02/%s' % (datetime.now().year + 1)" |
797 | 270 | - code: 03/2012 | 270 | - code: !eval "'03/%s' % (datetime.now().year + 1)" |
798 | 271 | company_id: account_consolidation.subsidiary_a | 271 | company_id: account_consolidation.subsidiary_a |
799 | 272 | date_start: '2012-03-01' | 272 | date_start: !eval "'%s-03-01' % (datetime.now().year + 1)" |
800 | 273 | date_stop: '2012-03-31' | 273 | date_stop: !eval "'%s-03-31' % (datetime.now().year + 1)" |
801 | 274 | name: 03/2012 | 274 | name: !eval "'03/%s' % (datetime.now().year + 1)" |
802 | 275 | - code: 04/2012 | 275 | - code: !eval "'04/%s' % (datetime.now().year + 1)" |
803 | 276 | company_id: account_consolidation.subsidiary_a | 276 | company_id: account_consolidation.subsidiary_a |
804 | 277 | date_start: '2012-04-01' | 277 | date_start: !eval "'%s-04-01' % (datetime.now().year + 1)" |
805 | 278 | date_stop: '2012-04-30' | 278 | date_stop: !eval "'%s-04-30' % (datetime.now().year + 1)" |
806 | 279 | name: 04/2012 | 279 | name: !eval "'04/%s' % (datetime.now().year + 1)" |
807 | 280 | - code: 05/2012 | 280 | - code: !eval "'05/%s' % (datetime.now().year + 1)" |
808 | 281 | company_id: account_consolidation.subsidiary_a | 281 | company_id: account_consolidation.subsidiary_a |
809 | 282 | date_start: '2012-05-01' | 282 | date_start: !eval "'%s-05-01' % (datetime.now().year + 1)" |
810 | 283 | date_stop: '2012-05-31' | 283 | date_stop: !eval "'%s-05-31' % (datetime.now().year + 1)" |
811 | 284 | name: 05/2012 | 284 | name: !eval "'05/%s' % (datetime.now().year + 1)" |
812 | 285 | - code: 06/2012 | 285 | - code: !eval "'06/%s' % (datetime.now().year + 1)" |
813 | 286 | company_id: account_consolidation.subsidiary_a | 286 | company_id: account_consolidation.subsidiary_a |
814 | 287 | date_start: '2012-06-01' | 287 | date_start: !eval "'%s-06-01' % (datetime.now().year + 1)" |
815 | 288 | date_stop: '2012-06-30' | 288 | date_stop: !eval "'%s-06-30' % (datetime.now().year + 1)" |
816 | 289 | name: 06/2012 | 289 | name: !eval "'06/%s' % (datetime.now().year + 1)" |
817 | 290 | - code: 08/2012 | 290 | - code: !eval "'08/%s' % (datetime.now().year + 1)" |
818 | 291 | company_id: account_consolidation.subsidiary_a | 291 | company_id: account_consolidation.subsidiary_a |
819 | 292 | date_start: '2012-08-01' | 292 | date_start: !eval "'%s-08-01' % (datetime.now().year + 1)" |
820 | 293 | date_stop: '2012-08-31' | 293 | date_stop: !eval "'%s-08-31' % (datetime.now().year + 1)" |
821 | 294 | name: 08/2012 | 294 | name: !eval "'08/%s' % (datetime.now().year + 1)" |
822 | 295 | - code: 09/2012 | 295 | - code: !eval "'09/%s' % (datetime.now().year + 1)" |
823 | 296 | company_id: account_consolidation.subsidiary_a | 296 | company_id: account_consolidation.subsidiary_a |
824 | 297 | date_start: '2012-09-01' | 297 | date_start: !eval "'%s-09-01' % (datetime.now().year + 1)" |
825 | 298 | date_stop: '2012-09-30' | 298 | date_stop: !eval "'%s-09-30' % (datetime.now().year + 1)" |
826 | 299 | name: 09/2012 | 299 | name: !eval "'09/%s' % (datetime.now().year + 1)" |
827 | 300 | - code: 10/2012 | 300 | - code: !eval "'10/%s' % (datetime.now().year + 1)" |
828 | 301 | company_id: account_consolidation.subsidiary_a | 301 | company_id: account_consolidation.subsidiary_a |
829 | 302 | date_start: '2012-10-01' | 302 | date_start: !eval "'%s-10-01' % (datetime.now().year + 1)" |
830 | 303 | date_stop: '2012-10-31' | 303 | date_stop: !eval "'%s-10-31' % (datetime.now().year + 1)" |
831 | 304 | name: 10/2012 | 304 | name: !eval "'10/%s' % (datetime.now().year + 1)" |
832 | 305 | - code: 11/2012 | 305 | - code: !eval "'11/%s' % (datetime.now().year + 1)" |
833 | 306 | company_id: account_consolidation.subsidiary_a | 306 | company_id: account_consolidation.subsidiary_a |
834 | 307 | date_start: '2012-11-01' | 307 | date_start: !eval "'%s-11-01' % (datetime.now().year + 1)" |
835 | 308 | date_stop: '2012-11-30' | 308 | date_stop: !eval "'%s-11-30' % (datetime.now().year + 1)" |
836 | 309 | name: 11/2012 | 309 | name: !eval "'11/%s' % (datetime.now().year + 1)" |
837 | 310 | - code: 12/2012 | 310 | - code: !eval "'12/%s' % (datetime.now().year + 1)" |
838 | 311 | company_id: account_consolidation.subsidiary_a | 311 | company_id: account_consolidation.subsidiary_a |
839 | 312 | date_start: '2012-12-01' | 312 | date_start: !eval "'%s-12-01' % (datetime.now().year + 1)" |
840 | 313 | date_stop: '2012-12-31' | 313 | date_stop: !eval "'%s-12-31' % (datetime.now().year + 1)" |
841 | 314 | name: 12/2012 | 314 | name: !eval "'12/%s' % (datetime.now().year + 1)" |
842 | 315 | 315 | ||
843 | === modified file 'account_consolidation/wizard/consolidation_base.py' | |||
844 | --- account_consolidation/wizard/consolidation_base.py 2012-04-18 14:35:42 +0000 | |||
845 | +++ account_consolidation/wizard/consolidation_base.py 2013-01-09 09:53:22 +0000 | |||
846 | @@ -1,38 +1,29 @@ | |||
847 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
848 | 2 | ############################################################################## | 2 | ############################################################################## |
849 | 3 | # | 3 | # |
874 | 4 | # Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com) | 4 | # Author: Guewen Baconnier |
875 | 5 | # | 5 | # Copyright 2011-2013 Camptocamp SA |
876 | 6 | # Author : Guewen Baconnier (Camptocamp) | 6 | # |
877 | 7 | # | 7 | # This program is free software: you can redistribute it and/or modify |
878 | 8 | # WARNING: This program as such is intended to be used by professional | 8 | # it under the terms of the GNU Affero General Public License as |
879 | 9 | # programmers who take the whole responsability of assessing all potential | 9 | # published by the Free Software Foundation, either version 3 of the |
880 | 10 | # consequences resulting from its eventual inadequacies and bugs | 10 | # License, or (at your option) any later version. |
881 | 11 | # End users who are looking for a ready-to-use solution with commercial | 11 | # |
882 | 12 | # garantees and support are strongly adviced to contract a Free Software | 12 | # This program is distributed in the hope that it will be useful, |
883 | 13 | # Service Company | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
884 | 14 | # | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
885 | 15 | # This program is Free Software; you can redistribute it and/or | 15 | # GNU Affero General Public License for more details. |
886 | 16 | # modify it under the terms of the GNU General Public License | 16 | # |
887 | 17 | # as published by the Free Software Foundation; either version 2 | 17 | # You should have received a copy of the GNU Affero General Public License |
888 | 18 | # of the License, or (at your option) any later version. | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
865 | 19 | # | ||
866 | 20 | # This program is distributed in the hope that it will be useful, | ||
867 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
868 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
869 | 23 | # GNU General Public License for more details. | ||
870 | 24 | # | ||
871 | 25 | # You should have received a copy of the GNU General Public License | ||
872 | 26 | # along with this program; if not, write to the Free Software | ||
873 | 27 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
889 | 28 | # | 19 | # |
890 | 29 | ############################################################################## | 20 | ############################################################################## |
891 | 30 | 21 | ||
897 | 31 | from osv import osv, fields | 22 | from openerp.osv import osv, orm, fields |
898 | 32 | from tools.translate import _ | 23 | from openerp.tools.translate import _ |
899 | 33 | 24 | ||
900 | 34 | 25 | ||
901 | 35 | class account_consolidation_base(osv.osv_memory): | 26 | class account_consolidation_base(orm.AbstractModel): |
902 | 36 | _name = 'account.consolidation.base' | 27 | _name = 'account.consolidation.base' |
903 | 37 | _description = 'Common consolidation wizard. Intended to be inherited' | 28 | _description = 'Common consolidation wizard. Intended to be inherited' |
904 | 38 | 29 | ||
905 | @@ -40,18 +31,30 @@ | |||
906 | 40 | user = self.pool.get('res.users').browse(cr, uid, uid, context=context) | 31 | user = self.pool.get('res.users').browse(cr, uid, uid, context=context) |
907 | 41 | if user.company_id: | 32 | if user.company_id: |
908 | 42 | return user.company_id.id | 33 | return user.company_id.id |
910 | 43 | return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] | 34 | return self.pool.get('res.company').search( |
911 | 35 | cr, uid, [('parent_id', '=', False)])[0] | ||
912 | 44 | 36 | ||
913 | 45 | _columns = { | 37 | _columns = { |
923 | 46 | 'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True, | 38 | 'fiscalyear_id': fields.many2one( |
924 | 47 | help="The checks will be done on the periods of the selected fiscal year."), | 39 | 'account.fiscalyear', |
925 | 48 | 'company_id': fields.many2one('res.company', 'Company', required=True), | 40 | 'Fiscal Year', |
926 | 49 | 'holding_chart_account_id': fields.many2one('account.account', | 41 | required=True, |
927 | 50 | 'Chart of Accounts', | 42 | help="The checks will be done on the periods of " |
928 | 51 | required=True, | 43 | "the selected fiscal year."), |
929 | 52 | domain=[('parent_id', '=', False)]), | 44 | 'company_id': fields.many2one( |
930 | 53 | 'subsidiary_ids': fields.many2many('res.company', 'account_conso_comp_rel', 'conso_id', 'company_id', | 45 | 'res.company', 'Company', required=True), |
931 | 54 | 'Subsidiaries', required=True) | 46 | 'holding_chart_account_id': fields.many2one( |
932 | 47 | 'account.account', | ||
933 | 48 | 'Chart of Accounts', | ||
934 | 49 | required=True, | ||
935 | 50 | domain=[('parent_id', '=', False)]), | ||
936 | 51 | 'subsidiary_ids': fields.many2many( | ||
937 | 52 | 'res.company', | ||
938 | 53 | 'account_conso_comp_rel', | ||
939 | 54 | 'conso_id', | ||
940 | 55 | 'company_id', | ||
941 | 56 | 'Subsidiaries', | ||
942 | 57 | required=True) | ||
943 | 55 | } | 58 | } |
944 | 56 | 59 | ||
945 | 57 | _defaults = { | 60 | _defaults = { |
946 | @@ -62,14 +65,9 @@ | |||
947 | 62 | """ | 65 | """ |
948 | 63 | On change of the company, set the chart of account and the subsidiaries | 66 | On change of the company, set the chart of account and the subsidiaries |
949 | 64 | 67 | ||
956 | 65 | @param self: The object pointer | 68 | :param company_id: ID of the selected company |
951 | 66 | @param cr: the current row, from the database cursor, | ||
952 | 67 | @param uid: the current user’s ID for security checks, | ||
953 | 68 | @param ids: List of the wizard IDs (commonly the first element is the current ID) | ||
954 | 69 | @param company_id: ID of the selected company | ||
955 | 70 | @param context: A standard dictionary for contextual values | ||
957 | 71 | 69 | ||
959 | 72 | @return: dict of values to change | 70 | :return: dict of values to change |
960 | 73 | """ | 71 | """ |
961 | 74 | company_obj = self.pool.get('res.company') | 72 | company_obj = self.pool.get('res.company') |
962 | 75 | 73 | ||
963 | @@ -82,21 +80,27 @@ | |||
964 | 82 | 80 | ||
965 | 83 | return {'value': result} | 81 | return {'value': result} |
966 | 84 | 82 | ||
982 | 85 | def check_subsidiary_periods(self, cr, uid, ids, holding_company_id, subs_company_id, fyear_id, context=None): | 83 | def check_subsidiary_periods(self, cr, uid, ids, holding_company_id, |
983 | 86 | """ | 84 | subs_company_id, fyear_id, context=None): |
984 | 87 | Check Subsidiary company periods vs Holding company periods and returns a list of errors | 85 | """ Check Subsidiary company periods vs Holding company periods and |
985 | 88 | All the periods defined within the group must be the same (same beginning and ending dates) | 86 | returns a list of errors |
986 | 89 | 87 | ||
987 | 90 | @param self: The object pointer | 88 | The periods checked are the periods within the fiscal year of the |
988 | 91 | @param cr: the current row, from the database cursor, | 89 | holding, and the periods of the subsidiary company in the same range of |
989 | 92 | @param uid: the current user’s ID for security checks, | 90 | time. |
990 | 93 | @param ids: List of the wizard IDs (commonly the first element is the current ID) | 91 | |
991 | 94 | @param holding_company_id: ID of the holding company | 92 | The fiscal year of the subsidiary is deduced from the start/stop date |
992 | 95 | @param subs_company_id: ID of the subsidiary company to check | 93 | of the holding's fiscal year. |
993 | 96 | @param fyear_id: ID of the fiscal years to compare | 94 | |
994 | 97 | @param context: A standard dictionary for contextual values | 95 | All the periods defined within the group must have the same beginning |
995 | 98 | 96 | and ending dates to be valid. | |
996 | 99 | @return: dict of list with errors for each company {company_id: ['error 1', 'error2']} | 97 | |
997 | 98 | :param holding_company_id: ID of the holding company | ||
998 | 99 | :param subs_company_id: ID of the subsidiary company to check | ||
999 | 100 | :param fyear_id: ID of the fiscal year of the holding. | ||
1000 | 101 | |||
1001 | 102 | :return: dict of list with errors for each company | ||
1002 | 103 | {company_id: ['error 1', 'error2']} | ||
1003 | 100 | """ | 104 | """ |
1004 | 101 | company_obj = self.pool.get('res.company') | 105 | company_obj = self.pool.get('res.company') |
1005 | 102 | period_obj = self.pool.get('account.period') | 106 | period_obj = self.pool.get('account.period') |
1006 | @@ -108,48 +112,69 @@ | |||
1007 | 108 | errors = [] | 112 | errors = [] |
1008 | 109 | 113 | ||
1009 | 110 | # get holding fiscal year and periods | 114 | # get holding fiscal year and periods |
1012 | 111 | holding = company_obj.browse(cr, uid, holding_company_id, context=context) | 115 | holding = company_obj.browse( |
1013 | 112 | subsidiary = company_obj.browse(cr, uid, subs_company_id, context=context) | 116 | cr, uid, holding_company_id, context=context) |
1014 | 117 | subsidiary = company_obj.browse( | ||
1015 | 118 | cr, uid, subs_company_id, context=context) | ||
1016 | 113 | 119 | ||
1018 | 114 | holding_periods_ids = period_obj.search(cr, uid, | 120 | holding_periods_ids = period_obj.search( |
1019 | 121 | cr, uid, | ||
1020 | 115 | [('company_id', '=', holding.id), | 122 | [('company_id', '=', holding.id), |
1021 | 116 | ('fiscalyear_id', '=', holding_fiscal_year.id)], | 123 | ('fiscalyear_id', '=', holding_fiscal_year.id)], |
1022 | 117 | context=context) | 124 | context=context) |
1024 | 118 | holding_periods = period_obj.browse(cr, uid, holding_periods_ids, context=context) | 125 | holding_periods = period_obj.browse( |
1025 | 126 | cr, uid, holding_periods_ids, context=context) | ||
1026 | 119 | 127 | ||
1027 | 120 | # get subsidiary fiscal year and periods | 128 | # get subsidiary fiscal year and periods |
1029 | 121 | subsidiary_fiscal_year = fy_obj.search(cr, uid, | 129 | subsidiary_fiscal_year = fy_obj.search( |
1030 | 130 | cr, uid, | ||
1031 | 122 | [('company_id', '=', subsidiary.id), | 131 | [('company_id', '=', subsidiary.id), |
1032 | 123 | ('date_start', '=', holding_fiscal_year.date_start), | 132 | ('date_start', '=', holding_fiscal_year.date_start), |
1033 | 124 | ('date_stop', '=', holding_fiscal_year.date_stop), | 133 | ('date_stop', '=', holding_fiscal_year.date_stop), |
1035 | 125 | ]) | 134 | ], |
1036 | 135 | context=context) | ||
1037 | 126 | if not subsidiary_fiscal_year: | 136 | if not subsidiary_fiscal_year: |
1040 | 127 | errors.append(_('The fiscal year of the subsidiary company %s does not exists from %s to %s') | 137 | errors.append( |
1041 | 128 | % (subsidiary.name, holding_fiscal_year.date_start, holding_fiscal_year.date_stop)) | 138 | _('The fiscal year of the subsidiary company %s ' |
1042 | 139 | 'does not exists from %s to %s') % | ||
1043 | 140 | (subsidiary.name, | ||
1044 | 141 | holding_fiscal_year.date_start, | ||
1045 | 142 | holding_fiscal_year.date_stop)) | ||
1046 | 129 | else: | 143 | else: |
1048 | 130 | subsidiary_period_ids = period_obj.search(cr, uid, | 144 | subsidiary_period_ids = period_obj.search( |
1049 | 145 | cr, uid, | ||
1050 | 131 | [('company_id', '=', subsidiary.id), | 146 | [('company_id', '=', subsidiary.id), |
1052 | 132 | ('fiscalyear_id', '=', subsidiary_fiscal_year[0])], # 0 because there can be only 1 fiscal year on the same dates as the holding | 147 | # 0 because there can be only 1 fiscal year |
1053 | 148 | # on the same dates than the holding | ||
1054 | 149 | ('fiscalyear_id', '=', subsidiary_fiscal_year[0])], | ||
1055 | 133 | context=context) | 150 | context=context) |
1057 | 134 | subsidiary_periods = period_obj.browse(cr, uid, subsidiary_period_ids, context=context) | 151 | subsidiary_periods = period_obj.browse( |
1058 | 152 | cr, uid, subsidiary_period_ids, context=context) | ||
1059 | 135 | 153 | ||
1061 | 136 | # a holding fiscal year may have more periods than a subsidiary (a subsidiary created at the middle of the year for example) | 154 | # a holding fiscal year may have more periods than a subsidiary |
1062 | 155 | # (a subsidiary created at the middle of the year for example) | ||
1063 | 137 | # but the reverse situation is not allowed | 156 | # but the reverse situation is not allowed |
1064 | 138 | if len(holding_periods) < len(subsidiary_periods): | 157 | if len(holding_periods) < len(subsidiary_periods): |
1066 | 139 | errors.append(_('Holding company has less periods than the subsidiary company %s!') % (subsidiary.name,)) | 158 | errors.append( |
1067 | 159 | _('Holding company has less periods than the ' | ||
1068 | 160 | 'subsidiary company %s!') % subsidiary.name) | ||
1069 | 140 | 161 | ||
1071 | 141 | # check subsidiary periods dates vs holding periods for each period of the subsidiary | 162 | # check subsidiary periods dates vs holding periods |
1072 | 163 | # for each period of the subsidiary | ||
1073 | 142 | for subsidiary_period in subsidiary_periods: | 164 | for subsidiary_period in subsidiary_periods: |
1074 | 143 | period_exists = False | 165 | period_exists = False |
1075 | 144 | for holding_period in holding_periods: | 166 | for holding_period in holding_periods: |
1080 | 145 | if subsidiary_period.date_start == holding_period.date_start \ | 167 | if (subsidiary_period.date_start == holding_period.date_start and |
1081 | 146 | and subsidiary_period.date_stop == holding_period.date_stop: | 168 | subsidiary_period.date_stop == holding_period.date_stop): |
1082 | 147 | period_exists = True | 169 | period_exists = True |
1083 | 148 | break | 170 | break |
1084 | 149 | if not period_exists: | 171 | if not period_exists: |
1088 | 150 | errors.append(_('Period from %s to %s not found in holding company %s') | 172 | errors.append( |
1089 | 151 | % (subsidiary_period.date_start, subsidiary_period.date_stop, holding.name)) | 173 | _('Period from %s to %s not found ' |
1090 | 152 | 174 | 'in holding company %s') % | |
1091 | 175 | (subsidiary_period.date_start, | ||
1092 | 176 | subsidiary_period.date_stop, | ||
1093 | 177 | holding.name)) | ||
1094 | 153 | return errors | 178 | return errors |
1095 | 154 | 179 | ||
1096 | 155 | def check_all_periods(self, cr, uid, ids, context=None): | 180 | def check_all_periods(self, cr, uid, ids, context=None): |
1097 | @@ -157,24 +182,24 @@ | |||
1098 | 157 | Call the period check on each period of all subsidiaries | 182 | Call the period check on each period of all subsidiaries |
1099 | 158 | Returns the errors by subsidiary | 183 | Returns the errors by subsidiary |
1100 | 159 | 184 | ||
1108 | 160 | @param self: The object pointer | 185 | :return: dict of list with errors for each company |
1109 | 161 | @param cr: the current row, from the database cursor, | 186 | {company_id: ['error 1', 'error2']} |
1103 | 162 | @param uid: the current user’s ID for security checks, | ||
1104 | 163 | @param ids: List of the wizard IDs (commonly the first element is the current ID) | ||
1105 | 164 | @param context: A standard dictionary for contextual values | ||
1106 | 165 | |||
1107 | 166 | @return: dict of list with errors for each company {company_id: ['error 1', 'error2']} | ||
1110 | 167 | """ | 187 | """ |
1111 | 188 | if isinstance(ids, (int, long)): | ||
1112 | 189 | ids = [ids] | ||
1113 | 190 | assert len(ids) == 1, "only 1 id expected" | ||
1114 | 191 | |||
1115 | 168 | form = self.browse(cr, uid, ids[0], context=context) | 192 | form = self.browse(cr, uid, ids[0], context=context) |
1116 | 169 | 193 | ||
1117 | 170 | errors_by_company = {} | 194 | errors_by_company = {} |
1118 | 171 | for subsidiary in form.subsidiary_ids: | 195 | for subsidiary in form.subsidiary_ids: |
1125 | 172 | errors = \ | 196 | errors = self.check_subsidiary_periods( |
1126 | 173 | self.check_subsidiary_periods(cr, uid, ids, | 197 | cr, uid, |
1127 | 174 | form.company_id.id, | 198 | ids, |
1128 | 175 | subsidiary.id, | 199 | form.company_id.id, |
1129 | 176 | form.fiscalyear_id.id, | 200 | subsidiary.id, |
1130 | 177 | context=context) | 201 | form.fiscalyear_id.id, |
1131 | 202 | context=context) | ||
1132 | 178 | if errors: | 203 | if errors: |
1133 | 179 | errors_by_company[subsidiary.id] = errors | 204 | errors_by_company[subsidiary.id] = errors |
1134 | 180 | 205 | ||
1135 | @@ -182,24 +207,23 @@ | |||
1136 | 182 | 207 | ||
1137 | 183 | def _chart_accounts_data(self, cr, uid, ids, chart_account_id, context=None): | 208 | def _chart_accounts_data(self, cr, uid, ids, chart_account_id, context=None): |
1138 | 184 | """ | 209 | """ |
1151 | 185 | Returns the list of accounts to use for the consolidation for the holding | 210 | Returns the list of accounts to use for the consolidation |
1152 | 186 | or the subsidiaries. Keys of the returned dict are the account codes and | 211 | for the holding or the subsidiaries. |
1153 | 187 | if the context is holding_coa, dict values are the browse instances of the accounts | 212 | Keys of the returned dict are the account codes and |
1154 | 188 | 213 | if the context is holding_coa, | |
1155 | 189 | @param self: The object pointer | 214 | dict values are the browse instances of the accounts |
1156 | 190 | @param cr: the current row, from the database cursor, | 215 | |
1157 | 191 | @param uid: the current user’s ID for security checks, | 216 | :chart_account_id: ID of the Chart of Account for which |
1158 | 192 | @param ids: List of the wizard IDs (commonly the first element is the current ID) | 217 | we want the account codes |
1159 | 193 | @chart_account_id: ID of the "Chart" Account for which we want the account codes | 218 | |
1160 | 194 | @param context: A standard dictionary for contextual values | 219 | :return: dict with {account codes: browse instances} |
1149 | 195 | |||
1150 | 196 | @return: dict with {account codes: browse instances} | ||
1161 | 197 | """ | 220 | """ |
1163 | 198 | context = context or {} | 221 | if context is None: |
1164 | 222 | context = {} | ||
1165 | 199 | account_obj = self.pool.get('account.account') | 223 | account_obj = self.pool.get('account.account') |
1166 | 200 | res = {} | 224 | res = {} |
1169 | 201 | account_ids = account_obj.\ | 225 | account_ids = account_obj._get_children_and_consol( |
1170 | 202 | _get_children_and_consol(cr, uid, chart_account_id, context=context) | 226 | cr, uid, chart_account_id, context=context) |
1171 | 203 | 227 | ||
1172 | 204 | # do not consolidate chart root | 228 | # do not consolidate chart root |
1173 | 205 | account_ids.remove(chart_account_id) | 229 | account_ids.remove(chart_account_id) |
1174 | @@ -216,33 +240,37 @@ | |||
1175 | 216 | continue | 240 | continue |
1176 | 217 | 241 | ||
1177 | 218 | res[account.code] = {} | 242 | res[account.code] = {} |
1180 | 219 | # we'll need the browse object during the "consolidate wizard" for the holding | 243 | # we'll need the browse object during the |
1181 | 220 | res[account.code] = holding and account or True | 244 | # "consolidate wizard" for the holding |
1182 | 245 | res[account.code] = account if holding else True | ||
1183 | 221 | 246 | ||
1184 | 222 | return res | 247 | return res |
1185 | 223 | 248 | ||
1187 | 224 | def check_subsidiary_chart(self, cr, uid, ids, holding_chart_account_id, subsidiary_chart_account_id, context=None): | 249 | def check_subsidiary_chart(self, cr, uid, ids, holding_chart_account_id, |
1188 | 250 | subsidiary_chart_account_id, context=None): | ||
1189 | 225 | """ | 251 | """ |
1191 | 226 | Check a Holding Chart of Accounts vs a Subsidiary Virtual Chart of Accounts | 252 | Check a Holding Chart of Accounts vs a Subsidiary Virtual |
1192 | 253 | Chart of Accounts | ||
1193 | 227 | All the accounts of the Virtual CoA must exist in the Holding CoA. | 254 | All the accounts of the Virtual CoA must exist in the Holding CoA. |
1205 | 228 | The Holding's CoA may hold accounts which do not exist in the Subsidiary's Virtual CoA. | 255 | The Holding's CoA may hold accounts which do not exist |
1206 | 229 | 256 | in the Subsidiary's Virtual CoA. | |
1207 | 230 | @param self: The object pointer | 257 | |
1208 | 231 | @param cr: the current row, from the database cursor, | 258 | :param holding_chart_account_id: ID of the Chart of Account |
1209 | 232 | @param uid: the current user’s ID for security checks, | 259 | of the holding company |
1210 | 233 | @param ids: List of the wizard IDs (commonly the first element is the current ID) | 260 | :param subsidiary_chart_account_id: ID of the Chart of Account |
1211 | 234 | @param holding_chart_account_id: ID of the "Chart" Account of the holding company | 261 | of the subsidiary company to check |
1212 | 235 | @param subsidiary_chart_account_id: ID of the "Chart" Account of the subsidiary company to check | 262 | |
1213 | 236 | @param context: A standard dictionary for contextual values | 263 | :return: List of accounts existing on subsidiary but no on holding COA |
1203 | 237 | |||
1204 | 238 | @return: List of accounts existing on subsidiary but no on holding COA | ||
1214 | 239 | """ | 264 | """ |
1221 | 240 | context = context or {} | 265 | if context is None: |
1222 | 241 | holding_ctx = context.copy() | 266 | context = {} |
1223 | 242 | holding_ctx.update({'holding_coa': True}) | 267 | holding_ctx = dict(context, holding_coa=True) |
1224 | 243 | holding_accounts = self._chart_accounts_data(cr, uid, ids, holding_chart_account_id, context=holding_ctx) | 268 | holding_accounts = self._chart_accounts_data( |
1225 | 244 | subsidiary_accounts = self._chart_accounts_data(cr, uid, ids, subsidiary_chart_account_id, context=context) | 269 | cr, uid, ids, holding_chart_account_id, context=holding_ctx) |
1226 | 245 | # accounts which are configured on the subsidiary VCoA but not on the holding CoA | 270 | subsidiary_accounts = self._chart_accounts_data( |
1227 | 271 | cr, uid, ids, subsidiary_chart_account_id, context=context) | ||
1228 | 272 | # accounts which are configured on the subsidiary | ||
1229 | 273 | # Virtual CoA but not on the holding CoA | ||
1230 | 246 | spare_accounts = [code for code | 274 | spare_accounts = [code for code |
1231 | 247 | in subsidiary_accounts | 275 | in subsidiary_accounts |
1232 | 248 | if code not in holding_accounts] | 276 | if code not in holding_accounts] |
1233 | @@ -250,26 +278,27 @@ | |||
1234 | 250 | 278 | ||
1235 | 251 | def check_account_charts(self, cr, uid, ids, context=None): | 279 | def check_account_charts(self, cr, uid, ids, context=None): |
1236 | 252 | """ | 280 | """ |
1244 | 253 | Check the chart of accounts of the holding vs each virtual chart of accounts of the subsidiaries | 281 | Check the chart of accounts of the holding vs |
1245 | 254 | 282 | each virtual chart of accounts of the subsidiaries | |
1239 | 255 | @param self: The object pointer | ||
1240 | 256 | @param cr: the current row, from the database cursor, | ||
1241 | 257 | @param uid: the current user’s ID for security checks, | ||
1242 | 258 | @param ids: List of the wizard IDs (commonly the first element is the current ID) | ||
1243 | 259 | @param context: A standard dictionary for contextual values | ||
1246 | 260 | """ | 283 | """ |
1247 | 284 | if isinstance(ids, (int, long)): | ||
1248 | 285 | ids = [ids] | ||
1249 | 286 | assert len(ids) == 1, "only 1 id expected" | ||
1250 | 261 | form = self.browse(cr, uid, ids[0], context=context) | 287 | form = self.browse(cr, uid, ids[0], context=context) |
1251 | 262 | 288 | ||
1252 | 263 | invalid_items_per_company = {} | 289 | invalid_items_per_company = {} |
1253 | 264 | for subsidiary in form.subsidiary_ids: | 290 | for subsidiary in form.subsidiary_ids: |
1254 | 265 | if not subsidiary.consolidation_chart_account_id: | 291 | if not subsidiary.consolidation_chart_account_id: |
1256 | 266 | raise osv.except_osv(_('Error'), _('No chart of accounts for company %s') % (subsidiary,)) | 292 | raise osv.except_osv( |
1257 | 293 | _('Error'), | ||
1258 | 294 | _('No chart of accounts for company %s') % subsidiary) | ||
1259 | 267 | 295 | ||
1265 | 268 | invalid_items = \ | 296 | invalid_items = self.check_subsidiary_chart( |
1266 | 269 | self.check_subsidiary_chart(cr, uid, ids, | 297 | cr, uid, |
1267 | 270 | form.holding_chart_account_id.id, | 298 | ids, |
1268 | 271 | subsidiary.consolidation_chart_account_id.id, | 299 | form.holding_chart_account_id.id, |
1269 | 272 | context=context) | 300 | subsidiary.consolidation_chart_account_id.id, |
1270 | 301 | context=context) | ||
1271 | 273 | if any(invalid_items): | 302 | if any(invalid_items): |
1272 | 274 | invalid_items_per_company[subsidiary.id] = invalid_items | 303 | invalid_items_per_company[subsidiary.id] = invalid_items |
1273 | 275 | 304 | ||
1274 | @@ -278,25 +307,24 @@ | |||
1275 | 278 | def run_consolidation(self, cr, uid, ids, context=None): | 307 | def run_consolidation(self, cr, uid, ids, context=None): |
1276 | 279 | """ | 308 | """ |
1277 | 280 | Proceed with all checks before launch any consolidation step | 309 | Proceed with all checks before launch any consolidation step |
1285 | 281 | This is a base method intended to be inherited with the next consolidation steps | 310 | This is a base method intended to be inherited with the next |
1286 | 282 | 311 | consolidation steps | |
1280 | 283 | @param self: The object pointer | ||
1281 | 284 | @param cr: the current row, from the database cursor, | ||
1282 | 285 | @param uid: the current user’s ID for security checks, | ||
1283 | 286 | @param ids: List of the wizard IDs (commonly the first element is the current ID) | ||
1284 | 287 | @param context: A standard dictionary for contextual values | ||
1287 | 288 | """ | 312 | """ |
1288 | 313 | if isinstance(ids, (int, long)): | ||
1289 | 314 | ids = [ids] | ||
1290 | 315 | assert len(ids) == 1, "only 1 id expected" | ||
1291 | 289 | 316 | ||
1292 | 290 | if self.check_all_periods(cr, uid, ids, context=context): | 317 | if self.check_all_periods(cr, uid, ids, context=context): |
1295 | 291 | raise osv.except_osv(_('Error'), | 318 | raise osv.except_osv( |
1296 | 292 | _('Invalid periods, please launch the "Consolidation: Checks" wizard')) | 319 | _('Error'), |
1297 | 320 | _('Invalid periods, please launch the ' | ||
1298 | 321 | '"Consolidation: Checks" wizard')) | ||
1299 | 293 | if self.check_account_charts(cr, uid, ids, context=context): | 322 | if self.check_account_charts(cr, uid, ids, context=context): |
1302 | 294 | raise osv.except_osv(_('Error'), | 323 | raise osv.except_osv( |
1303 | 295 | _('Invalid charts, please launch the "Consolidation: Checks" wizard')) | 324 | _('Error'), |
1304 | 325 | _('Invalid charts, please launch the ' | ||
1305 | 326 | '"Consolidation: Checks" wizard')) | ||
1306 | 296 | 327 | ||
1307 | 297 | # inherit to add the next steps of the reconciliation | 328 | # inherit to add the next steps of the reconciliation |
1308 | 298 | 329 | ||
1309 | 299 | return {'type': 'ir.actions.act_window_close'} | 330 | return {'type': 'ir.actions.act_window_close'} |
1310 | 300 | |||
1311 | 301 | |||
1312 | 302 | account_consolidation_base() | ||
1313 | 303 | 331 | ||
1314 | === modified file 'account_consolidation/wizard/consolidation_check.py' | |||
1315 | --- account_consolidation/wizard/consolidation_check.py 2012-04-18 14:35:42 +0000 | |||
1316 | +++ account_consolidation/wizard/consolidation_check.py 2013-01-09 09:53:22 +0000 | |||
1317 | @@ -1,109 +1,91 @@ | |||
1318 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
1319 | 2 | ############################################################################## | 2 | ############################################################################## |
1320 | 3 | # | 3 | # |
1345 | 4 | # Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com) | 4 | # Author: Guewen Baconnier |
1346 | 5 | # | 5 | # Copyright 2011-2013 Camptocamp SA |
1347 | 6 | # Author : Guewen Baconnier (Camptocamp) | 6 | # |
1348 | 7 | # | 7 | # This program is free software: you can redistribute it and/or modify |
1349 | 8 | # WARNING: This program as such is intended to be used by professional | 8 | # it under the terms of the GNU Affero General Public License as |
1350 | 9 | # programmers who take the whole responsability of assessing all potential | 9 | # published by the Free Software Foundation, either version 3 of the |
1351 | 10 | # consequences resulting from its eventual inadequacies and bugs | 10 | # License, or (at your option) any later version. |
1352 | 11 | # End users who are looking for a ready-to-use solution with commercial | 11 | # |
1353 | 12 | # garantees and support are strongly adviced to contract a Free Software | 12 | # This program is distributed in the hope that it will be useful, |
1354 | 13 | # Service Company | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
1355 | 14 | # | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1356 | 15 | # This program is Free Software; you can redistribute it and/or | 15 | # GNU Affero General Public License for more details. |
1357 | 16 | # modify it under the terms of the GNU General Public License | 16 | # |
1358 | 17 | # as published by the Free Software Foundation; either version 2 | 17 | # You should have received a copy of the GNU Affero General Public License |
1359 | 18 | # of the License, or (at your option) any later version. | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1336 | 19 | # | ||
1337 | 20 | # This program is distributed in the hope that it will be useful, | ||
1338 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1339 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1340 | 23 | # GNU General Public License for more details. | ||
1341 | 24 | # | ||
1342 | 25 | # You should have received a copy of the GNU General Public License | ||
1343 | 26 | # along with this program; if not, write to the Free Software | ||
1344 | 27 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
1360 | 28 | # | 19 | # |
1361 | 29 | ############################################################################## | 20 | ############################################################################## |
1362 | 30 | 21 | ||
1369 | 31 | from osv import osv, fields | 22 | from openerp.osv import osv, orm, fields |
1370 | 32 | 23 | from openerp.tools.translate import _ | |
1371 | 33 | from tools.translate import _ | 24 | |
1372 | 34 | 25 | ||
1373 | 35 | 26 | class account_consolidation_check(orm.TransientModel): | |
1368 | 36 | class account_consolidation_check(osv.osv_memory): | ||
1374 | 37 | _name = 'account.consolidation.check' | 27 | _name = 'account.consolidation.check' |
1375 | 38 | _inherit = 'account.consolidation.base' | 28 | _inherit = 'account.consolidation.base' |
1376 | 39 | _description = 'Consolidation Checks. Model used for views' | 29 | _description = 'Consolidation Checks. Model used for views' |
1377 | 40 | 30 | ||
1378 | 41 | _columns = { | 31 | _columns = { |
1381 | 42 | 'subsidiary_ids': fields.many2many('res.company', 'account_conso_check_comp_rel', 'conso_id', 'company_id', | 32 | 'subsidiary_ids': fields.many2many( |
1382 | 43 | 'Subsidiaries', required=True), | 33 | 'res.company', |
1383 | 34 | 'account_conso_check_comp_rel', | ||
1384 | 35 | 'conso_id', | ||
1385 | 36 | 'company_id', | ||
1386 | 37 | 'Subsidiaries', | ||
1387 | 38 | required=True), | ||
1388 | 44 | } | 39 | } |
1389 | 45 | 40 | ||
1390 | 46 | def check_account_charts(self, cr, uid, ids, context=None): | 41 | def check_account_charts(self, cr, uid, ids, context=None): |
1391 | 47 | """ | 42 | """ |
1392 | 48 | Action launched with the button on the view. | 43 | Action launched with the button on the view. |
1393 | 49 | Check the account charts and display a report of the errors | 44 | Check the account charts and display a report of the errors |
1394 | 50 | |||
1395 | 51 | @param self: The object pointer | ||
1396 | 52 | @param cr: the current row, from the database cursor, | ||
1397 | 53 | @param uid: the current user’s ID for security checks, | ||
1398 | 54 | @param ids: List of the wizard IDs (commonly the first element is the current ID) | ||
1399 | 55 | @param context: A standard dictionary for contextual values | ||
1400 | 56 | """ | 45 | """ |
1421 | 57 | invalid_items_per_company = \ | 46 | company_obj = self.pool.get('res.company') |
1422 | 58 | super(account_consolidation_check, self).check_account_charts(cr, uid, ids, context=context) | 47 | invalid_items_per_company = super(account_consolidation_check, self).\ |
1423 | 59 | if invalid_items_per_company: | 48 | check_account_charts(cr, uid, ids, context=context) |
1424 | 60 | err_lines = [] | 49 | |
1425 | 61 | for company_id, account_codes in invalid_items_per_company.iteritems(): | 50 | if not invalid_items_per_company: |
1426 | 62 | company_obj = self.pool.get('res.company') | 51 | raise osv.except_osv( |
1427 | 63 | company = company_obj.browse(cr, uid, company_id, context=context) | 52 | _('Validation'), |
1428 | 64 | err_lines.append(_("%s :") % (company.name,)) | 53 | _('Chart of Accounts are OK.')) |
1429 | 65 | [err_lines.append(_("Account with code %s does not exist on the Holding company.") % (account_code,)) | 54 | |
1430 | 66 | for account_code | 55 | err_lines = [] |
1431 | 67 | in account_codes] | 56 | for company_id, account_codes in invalid_items_per_company.iteritems(): |
1432 | 68 | err_lines.append('') | 57 | company = company_obj.browse( |
1433 | 69 | 58 | cr, uid, company_id, context=context) | |
1434 | 70 | raise osv.except_osv(_('Invalid charts'), | 59 | err_lines.append(_("%s :") % company.name) |
1435 | 71 | '\n'.join(err_lines)) | 60 | for account_code in account_codes: |
1436 | 72 | 61 | err_lines.append( | |
1437 | 73 | else: | 62 | _("Account with code %s does not exist on the " |
1438 | 74 | raise osv.except_osv(_('Validation'), _('Chart of Accounts are OK.')) | 63 | "Holding company.") % account_code) |
1439 | 75 | # open a confirmation view ? | 64 | err_lines.append('') |
1440 | 76 | return True | 65 | |
1441 | 66 | raise osv.except_osv( | ||
1442 | 67 | _('Invalid charts'), '\n'.join(err_lines)) | ||
1443 | 77 | 68 | ||
1444 | 78 | def check_all_periods(self, cr, uid, ids, context=None): | 69 | def check_all_periods(self, cr, uid, ids, context=None): |
1445 | 79 | """ | 70 | """ |
1446 | 80 | Action launched with the button on the view. | 71 | Action launched with the button on the view. |
1447 | 81 | Check the periods and display a report of the errors | 72 | Check the periods and display a report of the errors |
1448 | 82 | |||
1449 | 83 | @param self: The object pointer | ||
1450 | 84 | @param cr: the current row, from the database cursor, | ||
1451 | 85 | @param uid: the current user’s ID for security checks, | ||
1452 | 86 | @param ids: List of the wizard IDs (commonly the first element is the current ID) | ||
1453 | 87 | @param context: A standard dictionary for contextual values | ||
1454 | 88 | """ | 73 | """ |
1471 | 89 | errors_by_company = \ | 74 | errors_by_company = super(account_consolidation_check, self).\ |
1472 | 90 | super(account_consolidation_check, self).check_all_periods(cr, uid, ids, context=context) | 75 | check_all_periods(cr, uid, ids, context=context) |
1473 | 91 | 76 | ||
1474 | 92 | if errors_by_company: | 77 | if not errors_by_company: |
1459 | 93 | company_obj = self.pool.get('res.company') | ||
1460 | 94 | |||
1461 | 95 | err_lines = [] | ||
1462 | 96 | for company_id, errors in errors_by_company.iteritems(): | ||
1463 | 97 | company = company_obj.browse(cr, uid, company_id, context=context) | ||
1464 | 98 | err_lines.append(_("%s :") % (company.name,)) | ||
1465 | 99 | [err_lines.append(error) for error in errors] | ||
1466 | 100 | err_lines.append('') | ||
1467 | 101 | |||
1468 | 102 | raise osv.except_osv(_('Invalid periods'), | ||
1469 | 103 | '\n'.join(err_lines)) | ||
1470 | 104 | else: | ||
1475 | 105 | raise osv.except_osv(_('Validation'), _('Periods are OK.')) | 78 | raise osv.except_osv(_('Validation'), _('Periods are OK.')) |
1480 | 106 | # open a confirmation view ? | 79 | |
1481 | 107 | return True | 80 | company_obj = self.pool.get('res.company') |
1482 | 108 | 81 | ||
1483 | 109 | account_consolidation_check() | 82 | err_lines = [] |
1484 | 83 | for company_id, errors in errors_by_company.iteritems(): | ||
1485 | 84 | company = company_obj.browse(cr, uid, company_id, context=context) | ||
1486 | 85 | err_lines.append(_("%s :") % company.name) | ||
1487 | 86 | for error in errors: | ||
1488 | 87 | err_lines.append(error) | ||
1489 | 88 | err_lines.append('') | ||
1490 | 89 | |||
1491 | 90 | raise osv.except_osv(_('Invalid periods'), | ||
1492 | 91 | '\n'.join(err_lines)) | ||
1493 | 110 | 92 | ||
1494 | === modified file 'account_consolidation/wizard/consolidation_check_view.xml' | |||
1495 | --- account_consolidation/wizard/consolidation_check_view.xml 2011-08-19 13:08:01 +0000 | |||
1496 | +++ account_consolidation/wizard/consolidation_check_view.xml 2013-01-09 09:53:22 +0000 | |||
1497 | @@ -2,32 +2,44 @@ | |||
1498 | 2 | <openerp> | 2 | <openerp> |
1499 | 3 | <data> | 3 | <data> |
1500 | 4 | 4 | ||
1502 | 5 | <record id="view_consolidation_check_form" model="ir.ui.view"> | 5 | <record id="view_consolidation_check_form" model="ir.ui.view"> |
1503 | 6 | <field name="name">account.consolidation.check.form</field> | 6 | <field name="name">account.consolidation.check.form</field> |
1504 | 7 | <field name="model">account.consolidation.check</field> | 7 | <field name="model">account.consolidation.check</field> |
1505 | 8 | <field name="type">form</field> | 8 | <field name="type">form</field> |
1506 | 9 | <field name="arch" type="xml"> | 9 | <field name="arch" type="xml"> |
1528 | 10 | <form string="Consolidation: Checks"> | 10 | <form string="Consolidation: Checks" version="7.0"> |
1529 | 11 | <group col="4" colspan="6"> | 11 | <label string="Prepare your consolidation and make sure that your consolidation will be correct by proceeding with the checks. The 'Check Periods' verify if fiscal year exists for each subsidiary, and if the periods have the same beginning and ending dates. The 'Check Charts' verify if subsidiary accounts are missing in the Holding's Chart of Accounts."/> |
1530 | 12 | <field name="company_id" on_change="on_change_company_id(company_id)" invisible="True"/> | 12 | <group> |
1531 | 13 | <field name="fiscalyear_id" domain="[('company_id', '=', company_id)]"/> | 13 | <field name="company_id" |
1532 | 14 | <newline/> | 14 | on_change="on_change_company_id(company_id)" |
1533 | 15 | <field name="holding_chart_account_id" domain="[('company_id', '=', company_id), ('parent_id', '=', False)]"/> | 15 | invisible="True"/> |
1534 | 16 | <separator string="Subsidiaries to Consolidate" colspan="4"/> | 16 | <field name="fiscalyear_id" |
1535 | 17 | <field name="subsidiary_ids" colspan="4" nolabel="1" required="True" domain="[('parent_id', '=', company_id)]"> | 17 | domain="[('company_id', '=', company_id)]"/> |
1536 | 18 | <tree> | 18 | <newline/> |
1537 | 19 | <field name="name"/> | 19 | <field name="holding_chart_account_id" |
1538 | 20 | <field name="consolidation_chart_account_id"/> | 20 | domain="[('company_id', '=', company_id), ('parent_id', '=', False)]"/> |
1539 | 21 | </tree> | 21 | <separator string="Subsidiaries to Consolidate" colspan="4"/> |
1540 | 22 | </field> | 22 | <field name="subsidiary_ids" colspan="4" nolabel="1" |
1541 | 23 | </group> | 23 | required="True" |
1542 | 24 | <separator colspan="4"/> | 24 | domain="[('parent_id', '=', company_id)]"> |
1543 | 25 | <group col="3" colspan="4"> | 25 | <tree> |
1544 | 26 | <button special="cancel" string="Cancel" icon='gtk-cancel'/> | 26 | <field name="name"/> |
1545 | 27 | <button name="check_all_periods" string="Check Periods" colspan="1" type="object" icon="gtk-execute"/> | 27 | <field name="consolidation_chart_account_id"/> |
1546 | 28 | <button name="check_account_charts" string="Check Charts" colspan="1" type="object" icon="gtk-execute"/> | 28 | </tree> |
1547 | 29 | </group> | 29 | </field> |
1548 | 30 | </form> | 30 | </group> |
1549 | 31 | <footer> | ||
1550 | 32 | <button name="check_all_periods" | ||
1551 | 33 | string="Check Periods" type="object" | ||
1552 | 34 | class="oe_highlight"/> | ||
1553 | 35 | or | ||
1554 | 36 | <button name="check_account_charts" | ||
1555 | 37 | string="Check Charts" type="object" | ||
1556 | 38 | class="oe_highlight"/> | ||
1557 | 39 | or | ||
1558 | 40 | <button string="Cancel" class="oe_link" special="cancel"/> | ||
1559 | 41 | </footer> | ||
1560 | 42 | </form> | ||
1561 | 31 | </field> | 43 | </field> |
1562 | 32 | </record> | 44 | </record> |
1563 | 33 | 45 | ||
1564 | @@ -37,9 +49,8 @@ | |||
1565 | 37 | <field name="res_model">account.consolidation.check</field> | 49 | <field name="res_model">account.consolidation.check</field> |
1566 | 38 | <field name="view_type">form</field> | 50 | <field name="view_type">form</field> |
1567 | 39 | <field name="view_mode">form</field> | 51 | <field name="view_mode">form</field> |
1568 | 40 | <field name="help">Prepare your consolidation and make sure that your consolidation will be correct by proceeding with the checks. The "Check Periods" verify if fiscal year exists for each subsidiary, and if the periods have the same beginning and ending dates. The "Check Charts" verify if subsidiary accounts are missing in the Holding's Chart of Accounts.</field> | ||
1569 | 41 | <field name="target">new</field> | 52 | <field name="target">new</field> |
1570 | 42 | </record> | 53 | </record> |
1571 | 43 | 54 | ||
1573 | 44 | </data> | 55 | </data> |
1574 | 45 | </openerp> | 56 | </openerp> |
1575 | 46 | 57 | ||
1576 | === modified file 'account_consolidation/wizard/consolidation_consolidate.py' | |||
1577 | --- account_consolidation/wizard/consolidation_consolidate.py 2012-04-11 07:57:56 +0000 | |||
1578 | +++ account_consolidation/wizard/consolidation_consolidate.py 2013-01-09 09:53:22 +0000 | |||
1579 | @@ -1,55 +1,60 @@ | |||
1580 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
1581 | 2 | ############################################################################## | 2 | ############################################################################## |
1582 | 3 | # | 3 | # |
1607 | 4 | # Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com) | 4 | # Author: Guewen Baconnier |
1608 | 5 | # | 5 | # Copyright 2011-2013 Camptocamp SA |
1609 | 6 | # Author : Guewen Baconnier (Camptocamp) | 6 | # |
1610 | 7 | # | 7 | # This program is free software: you can redistribute it and/or modify |
1611 | 8 | # WARNING: This program as such is intended to be used by professional | 8 | # it under the terms of the GNU Affero General Public License as |
1612 | 9 | # programmers who take the whole responsability of assessing all potential | 9 | # published by the Free Software Foundation, either version 3 of the |
1613 | 10 | # consequences resulting from its eventual inadequacies and bugs | 10 | # License, or (at your option) any later version. |
1614 | 11 | # End users who are looking for a ready-to-use solution with commercial | 11 | # |
1615 | 12 | # garantees and support are strongly adviced to contract a Free Software | 12 | # This program is distributed in the hope that it will be useful, |
1616 | 13 | # Service Company | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
1617 | 14 | # | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1618 | 15 | # This program is Free Software; you can redistribute it and/or | 15 | # GNU Affero General Public License for more details. |
1619 | 16 | # modify it under the terms of the GNU General Public License | 16 | # |
1620 | 17 | # as published by the Free Software Foundation; either version 2 | 17 | # You should have received a copy of the GNU Affero General Public License |
1621 | 18 | # of the License, or (at your option) any later version. | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1598 | 19 | # | ||
1599 | 20 | # This program is distributed in the hope that it will be useful, | ||
1600 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1601 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1602 | 23 | # GNU General Public License for more details. | ||
1603 | 24 | # | ||
1604 | 25 | # You should have received a copy of the GNU General Public License | ||
1605 | 26 | # along with this program; if not, write to the Free Software | ||
1606 | 27 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
1622 | 28 | # | 19 | # |
1623 | 29 | ############################################################################## | 20 | ############################################################################## |
1624 | 30 | 21 | ||
1630 | 31 | from osv import osv, fields | 22 | from openerp.osv import orm, fields |
1631 | 32 | from tools.translate import _ | 23 | from openerp.tools.translate import _ |
1632 | 33 | from tools import safe_eval as eval | 24 | |
1633 | 34 | 25 | ||
1634 | 35 | class account_consolidation_consolidate(osv.osv_memory): | 26 | class account_consolidation_consolidate(orm.TransientModel): |
1635 | 36 | _name = 'account.consolidation.consolidate' | 27 | _name = 'account.consolidation.consolidate' |
1636 | 37 | _inherit = 'account.consolidation.base' | 28 | _inherit = 'account.consolidation.base' |
1637 | 38 | 29 | ||
1638 | 39 | _columns = { | 30 | _columns = { |
1652 | 40 | 'from_period_id': fields.many2one('account.period', 'Start Period', required=True, | 31 | 'from_period_id': fields.many2one( |
1653 | 41 | help="Select the same period in 'from' and 'to' if you want to proceed with a single period. Start Period is ignored for Year To Date accounts."), | 32 | 'account.period', |
1654 | 42 | 'to_period_id': fields.many2one('account.period', 'End Period', required=True, | 33 | 'Start Period', |
1655 | 43 | help="The consolidation will be done at the very last date of the selected period."), | 34 | required=True, |
1656 | 44 | 'journal_id': fields.many2one('account.journal', 'Journal', required=True), | 35 | help="Select the same period in 'from' and 'to' " |
1657 | 45 | # not sure that we'll use them, actually using centralised counterpart journal | 36 | "if you want to proceed with a single period. " |
1658 | 46 | # 'gain_account_id': fields.many2one('account.account', 'Gain Account', required=True,), | 37 | "Start Period is ignored for Year To Date accounts."), |
1659 | 47 | # 'loss_account_id': fields.many2one('account.account', 'Loss Account', required=True,), | 38 | 'to_period_id': fields.many2one( |
1660 | 48 | 'target_move': fields.selection([('posted', 'All Posted Entries'), | 39 | 'account.period', |
1661 | 49 | ('all', 'All Entries'), | 40 | 'End Period', |
1662 | 50 | ], 'Target Moves', required=True), | 41 | required=True, |
1663 | 51 | 'subsidiary_ids': fields.many2many('res.company', 'account_conso_conso_comp_rel', 'conso_id', 'company_id', | 42 | help="The consolidation will be done at the very " |
1664 | 52 | 'Subsidiaries', required=True), | 43 | "last date of the selected period."), |
1665 | 44 | 'journal_id': fields.many2one( | ||
1666 | 45 | 'account.journal', 'Journal', required=True), | ||
1667 | 46 | 'target_move': fields.selection( | ||
1668 | 47 | [('posted', 'All Posted Entries'), | ||
1669 | 48 | ('all', 'All Entries')], | ||
1670 | 49 | 'Target Moves', | ||
1671 | 50 | required=True), | ||
1672 | 51 | 'subsidiary_ids': fields.many2many( | ||
1673 | 52 | 'res.company', | ||
1674 | 53 | 'account_conso_conso_comp_rel', | ||
1675 | 54 | 'conso_id', | ||
1676 | 55 | 'company_id', | ||
1677 | 56 | string='Subsidiaries', | ||
1678 | 57 | required=True), | ||
1679 | 53 | } | 58 | } |
1680 | 54 | 59 | ||
1681 | 55 | _defaults = { | 60 | _defaults = { |
1682 | @@ -57,38 +62,39 @@ | |||
1683 | 57 | } | 62 | } |
1684 | 58 | 63 | ||
1685 | 59 | def _check_periods_fy(self, cr, uid, ids, context=None): | 64 | def _check_periods_fy(self, cr, uid, ids, context=None): |
1688 | 60 | if context is None: | 65 | if isinstance(ids, (int, long)): |
1689 | 61 | context = {} | 66 | ids = [ids] |
1690 | 67 | assert len(ids) == 1, "only 1 id expected" | ||
1691 | 68 | |||
1692 | 62 | form = self.browse(cr, uid, ids[0], context=context) | 69 | form = self.browse(cr, uid, ids[0], context=context) |
1696 | 63 | if form.from_period_id.fiscalyear_id.id != form.to_period_id.fiscalyear_id.id: | 70 | return (form.from_period_id.fiscalyear_id.id == |
1697 | 64 | return False | 71 | form.to_period_id.fiscalyear_id.id) |
1695 | 65 | return True | ||
1698 | 66 | 72 | ||
1699 | 67 | _constraints = [ | 73 | _constraints = [ |
1701 | 68 | (_check_periods_fy, 'Start Period and End Period must be of the same Fiscal Year !', ['from_period_id', 'to_period_id']), | 74 | (_check_periods_fy, |
1702 | 75 | 'Start Period and End Period must be of the same Fiscal Year !', | ||
1703 | 76 | ['from_period_id', 'to_period_id']), | ||
1704 | 69 | ] | 77 | ] |
1705 | 70 | 78 | ||
1719 | 71 | def on_change_from_period_id(self, cr, uid, ids, from_period_id, to_period_id, context=None): | 79 | def on_change_from_period_id(self, cr, uid, ids, from_period_id, |
1720 | 72 | """ | 80 | to_period_id, context=None): |
1721 | 73 | On change of the From period, set the To period to the same period if it is empty | 81 | """ On change of the From period, set the To period |
1722 | 74 | 82 | to the same period if it is empty | |
1723 | 75 | @param self: The object pointer | 83 | |
1724 | 76 | @param cr: the current row, from the database cursor, | 84 | :param from_period_id: ID of the selected from period id |
1725 | 77 | @param uid: the current user’s ID for security checks, | 85 | :param to_period_id: ID of the current from period id |
1726 | 78 | @param ids: List of the wizard IDs (commonly the first element is the current ID) | 86 | |
1727 | 79 | @param from_period_id: ID of the selected from period id | 87 | :return: dict of values to change |
1715 | 80 | @param to_period_id: ID of the current from period id | ||
1716 | 81 | @param context: A standard dictionary for contextual values | ||
1717 | 82 | |||
1718 | 83 | @return: dict of values to change | ||
1728 | 84 | """ | 88 | """ |
1729 | 85 | result = {} | 89 | result = {} |
1730 | 86 | period_obj = self.pool.get('account.period') | 90 | period_obj = self.pool.get('account.period') |
1732 | 87 | from_period = period_obj.browse(cr, uid, from_period_id, context=context) | 91 | from_period = period_obj.browse( |
1733 | 92 | cr, uid, from_period_id, context=context) | ||
1734 | 88 | if not to_period_id: | 93 | if not to_period_id: |
1735 | 89 | result['to_period_id'] = from_period_id | 94 | result['to_period_id'] = from_period_id |
1736 | 90 | else: | 95 | else: |
1738 | 91 | to_period = period_obj.browse(cr, uid, to_period_id, context=context) | 96 | to_period = period_obj.browse( |
1739 | 97 | cr, uid, to_period_id, context=context) | ||
1740 | 92 | if to_period.date_start < from_period.date_start: | 98 | if to_period.date_start < from_period.date_start: |
1741 | 93 | result['to_period_id'] = from_period_id | 99 | result['to_period_id'] = from_period_id |
1742 | 94 | 100 | ||
1743 | @@ -99,97 +105,87 @@ | |||
1744 | 99 | """ | 105 | """ |
1745 | 100 | Returns the currency rate type to use | 106 | Returns the currency rate type to use |
1746 | 101 | 107 | ||
1753 | 102 | @param self: The object pointer | 108 | :param account: browse_record instance of account.account |
1748 | 103 | @param cr: the current row, from the database cursor, | ||
1749 | 104 | @param uid: the current user’s ID for security checks, | ||
1750 | 105 | @param ids: List of the wizard IDs (commonly the first element is the current ID) | ||
1751 | 106 | @param account: browse instance of account.account | ||
1752 | 107 | @param context: A standard dictionary for contextual values | ||
1754 | 108 | 109 | ||
1756 | 109 | @return: 'spot' or 'average' | 110 | :return: id of the currency rate type to use |
1757 | 110 | """ | 111 | """ |
1761 | 111 | return account.consolidation_rate_type_id and account.consolidation_rate_type_id \ | 112 | if account.consolidation_rate_type_id: |
1762 | 112 | or account.user_type.consolidation_rate_type_id and account.user_type.consolidation_rate_type_id.id \ | 113 | return account.consolidation_rate_type_id.id |
1763 | 113 | or False | 114 | |
1764 | 115 | elif account.user_type.consolidation_rate_type_id: | ||
1765 | 116 | return account.user_type.consolidation_rate_type_id.id | ||
1766 | 117 | |||
1767 | 118 | else: | ||
1768 | 119 | return False | ||
1769 | 114 | 120 | ||
1770 | 115 | def _consolidation_mode(self, cr, uid, ids, account, context=None): | 121 | def _consolidation_mode(self, cr, uid, ids, account, context=None): |
1771 | 116 | """ | 122 | """ |
1772 | 117 | Returns the consolidation mode to use | 123 | Returns the consolidation mode to use |
1773 | 118 | 124 | ||
1799 | 119 | @param self: The object pointer | 125 | :param account: browse instance of account.account |
1800 | 120 | @param cr: the current row, from the database cursor, | 126 | |
1801 | 121 | @param uid: the current user’s ID for security checks, | 127 | :return: 'ytd' or 'period' |
1802 | 122 | @param ids: List of the wizard IDs (commonly the first element is the current ID) | 128 | """ |
1803 | 123 | @param account: browse instance of account.account | 129 | return (account.consolidation_mode or |
1804 | 124 | @param context: A standard dictionary for contextual values | 130 | account.user_type.consolidation_mode) |
1805 | 125 | 131 | ||
1806 | 126 | @return: 'ytd' or 'period' | 132 | def _periods_holding_to_subsidiary(self, cr, uid, ids, period_ids, |
1807 | 127 | """ | 133 | subsidiary_id, context=None): |
1808 | 128 | return account.consolidation_mode or account.user_type.consolidation_mode | 134 | """ |
1809 | 129 | 135 | Returns the periods of a subsidiary company which | |
1810 | 130 | def _periods_holding_to_subsidiary(self, cr, uid, ids, period_ids, subsidiary_id, context=None): | 136 | correspond to the holding periods (same beginning and ending dates) |
1811 | 131 | """ | 137 | |
1812 | 132 | Returns the periods of a subsidiary company which correspond to the holding periods | 138 | :param period_ids: list of periods of the holding |
1813 | 133 | (same beginning and ending dates) | 139 | :param subsidiary_id: ID of the subsidiary for which |
1814 | 134 | 140 | we want the period IDs | |
1815 | 135 | @param self: The object pointer | 141 | |
1816 | 136 | @param cr: the current row, from the database cursor, | 142 | :return: list of periods of the subsidiaries |
1792 | 137 | @param uid: the current user’s ID for security checks, | ||
1793 | 138 | @param ids: List of the wizard IDs (commonly the first element is the current ID) | ||
1794 | 139 | @param period_ids: list of periods of the holding | ||
1795 | 140 | @param subsidiary_id: ID of the subsidiary for which we want the period IDs | ||
1796 | 141 | @param context: A standard dictionary for contextual values | ||
1797 | 142 | |||
1798 | 143 | @return: list of periods of the subsidiaries | ||
1817 | 144 | """ | 143 | """ |
1818 | 145 | period_obj = self.pool.get('account.period') | 144 | period_obj = self.pool.get('account.period') |
1819 | 146 | if isinstance(period_ids, (int, long)): | 145 | if isinstance(period_ids, (int, long)): |
1820 | 147 | period_ids = [period_ids] | 146 | period_ids = [period_ids] |
1821 | 147 | |||
1822 | 148 | subs_period_ids = [] | 148 | subs_period_ids = [] |
1823 | 149 | for period in period_obj.browse(cr, uid, period_ids, context=context): | 149 | for period in period_obj.browse(cr, uid, period_ids, context=context): |
1825 | 150 | subs_period_ids.extend(period_obj.search(cr, uid, | 150 | subs_period_ids += period_obj.search( |
1826 | 151 | cr, uid, | ||
1827 | 151 | [('date_start', '=', period.date_start), | 152 | [('date_start', '=', period.date_start), |
1828 | 152 | ('date_stop', '=', period.date_stop), | 153 | ('date_stop', '=', period.date_stop), |
1831 | 153 | ('company_id', '=', subsidiary_id)]) | 154 | ('company_id', '=', subsidiary_id)], |
1832 | 154 | ) | 155 | context=context) |
1833 | 155 | return subs_period_ids | 156 | return subs_period_ids |
1834 | 156 | 157 | ||
1835 | 157 | def create_rate_difference_line(self, cr, uid, ids, move_id, context): | 158 | def create_rate_difference_line(self, cr, uid, ids, move_id, context): |
1836 | 158 | """ | 159 | """ |
1847 | 159 | Create a move line for the gain/loss currency difference | 160 | Placeholder for creation of a move line |
1848 | 160 | 161 | for the gain/loss currency difference | |
1849 | 161 | @param self: The object pointer | 162 | |
1850 | 162 | @param cr: the current row, from the database cursor, | 163 | :param move_id: ID of the move |
1841 | 163 | @param uid: the current user’s ID for security checks, | ||
1842 | 164 | @param ids: List of the wizard IDs (commonly the first element is the current ID) | ||
1843 | 165 | @param move_id: ID of the move | ||
1844 | 166 | @param context: A standard dictionary for contextual values | ||
1845 | 167 | |||
1846 | 168 | @return: | ||
1851 | 169 | """ | 164 | """ |
1852 | 170 | 165 | ||
1856 | 171 | pass | 166 | def consolidate_account(self, cr, uid, ids, consolidation_mode, |
1857 | 172 | 167 | subsidiary_period_ids, state, move_id, | |
1855 | 173 | def consolidate_account(self, cr, uid, ids, consolidation_mode, subsidiary_period_ids, state, move_id, | ||
1858 | 174 | holding_account_id, subsidiary_id, context=None): | 168 | holding_account_id, subsidiary_id, context=None): |
1859 | 175 | """ | 169 | """ |
1860 | 176 | Consolidates the subsidiary account on the holding account | 170 | Consolidates the subsidiary account on the holding account |
1861 | 177 | Creates move lines on the move with id "move_id" | 171 | Creates move lines on the move with id "move_id" |
1862 | 178 | 172 | ||
1874 | 179 | @param self: The object pointer | 173 | :param consolidation_mode: consolidate by Periods or |
1875 | 180 | @param cr: the current row, from the database cursor, | 174 | Year To Date ('period' or 'ytd') |
1876 | 181 | @param uid: the current user’s ID for security checks, | 175 | :param subsidiary_period_ids: IDs of periods for which we |
1877 | 182 | @param ids: List of the wizard IDs (commonly the first element is the current ID) | 176 | want to sum the debit/credit |
1878 | 183 | @param consolidation_mode: consolidate by Periods or Year To Date ('period' or 'ytd') | 177 | :param state: state of the moves to consolidate ('all' or 'posted') |
1879 | 184 | @param subsidiary_period_ids: IDs of periods for which we want to sum the debit/credit | 178 | :param move_id: ID of the move on which all the |
1880 | 185 | @param state: state of the moves to consolidate ('all' or 'posted') | 179 | created move lines will be linked |
1881 | 186 | @param move_id: ID of the move on which all the created move lines will be linked | 180 | :param holding_account_id: ID of the account to consolidate |
1882 | 187 | @param holding_account_id: ID of the account to consolidate (on the holding), the method will find the subsidiary's corresponding account | 181 | (on the holding), the method will |
1883 | 188 | @param subsidiary_id: ID of the subsidiary to consolidate | 182 | find the subsidiary's corresponding account |
1884 | 189 | @param context: A standard dictionary for contextual values | 183 | :param subsidiary_id: ID of the subsidiary to consolidate |
1885 | 190 | 184 | ||
1887 | 191 | @return: list of IDs of the created move lines | 185 | :return: list of IDs of the created move lines |
1888 | 192 | """ | 186 | """ |
1889 | 187 | if context is None: | ||
1890 | 188 | context = {} | ||
1891 | 193 | 189 | ||
1892 | 194 | account_obj = self.pool.get('account.account') | 190 | account_obj = self.pool.get('account.account') |
1893 | 195 | move_obj = self.pool.get('account.move') | 191 | move_obj = self.pool.get('account.move') |
1894 | @@ -197,26 +193,27 @@ | |||
1895 | 197 | currency_obj = self.pool.get('res.currency') | 193 | currency_obj = self.pool.get('res.currency') |
1896 | 198 | 194 | ||
1897 | 199 | move = move_obj.browse(cr, uid, move_id, context=context) | 195 | move = move_obj.browse(cr, uid, move_id, context=context) |
1899 | 200 | holding_account = account_obj.browse(cr, uid, holding_account_id, context=context) | 196 | holding_account = account_obj.browse( |
1900 | 197 | cr, uid, holding_account_id, context=context) | ||
1901 | 201 | 198 | ||
1906 | 202 | subsidiary_account_id = account_obj.search(cr, uid, | 199 | subsidiary_account_id = account_obj.search( |
1907 | 203 | [('code', '=', holding_account.code), | 200 | cr, uid, |
1908 | 204 | ('company_id', '=', subsidiary_id)], | 201 | [('code', '=', holding_account.code), |
1909 | 205 | context=context) | 202 | ('company_id', '=', subsidiary_id)], |
1910 | 203 | context=context) | ||
1911 | 206 | 204 | ||
1912 | 207 | if not subsidiary_account_id: | 205 | if not subsidiary_account_id: |
1914 | 208 | return [] # an account may exist on the holding and not in the subsidiaries, nothing to do | 206 | # an account may exist on the holding and not in the subsidiaries, |
1915 | 207 | # nothing to do | ||
1916 | 208 | return [] | ||
1917 | 209 | 209 | ||
1925 | 210 | browse_ctx = context.copy() | 210 | browse_ctx = dict(context, state=state, periods=subsidiary_period_ids) |
1926 | 211 | browse_ctx.update({ | 211 | # 1st item because the account's code is unique per company |
1927 | 212 | 'state': state, | 212 | subs_account = account_obj.browse( |
1928 | 213 | 'periods': subsidiary_period_ids, | 213 | cr, uid, subsidiary_account_id[0], context=browse_ctx) |
1922 | 214 | }) | ||
1923 | 215 | # subsidiary_account_id[0] because only one account per company for one code is permitted | ||
1924 | 216 | subs_account = account_obj.browse(cr, uid, subsidiary_account_id[0], context=browse_ctx) | ||
1929 | 217 | 214 | ||
1930 | 218 | vals = { | 215 | vals = { |
1932 | 219 | 'name': _("Consolidation line in %s mode") % (consolidation_mode,), | 216 | 'name': _("Consolidation line in %s mode") % consolidation_mode, |
1933 | 220 | 'account_id': holding_account.id, | 217 | 'account_id': holding_account.id, |
1934 | 221 | 'move_id': move.id, | 218 | 'move_id': move.id, |
1935 | 222 | 'journal_id': move.journal_id.id, | 219 | 'journal_id': move.journal_id.id, |
1936 | @@ -225,16 +222,24 @@ | |||
1937 | 225 | 'date': move.date | 222 | 'date': move.date |
1938 | 226 | } | 223 | } |
1939 | 227 | 224 | ||
1942 | 228 | if holding_account.company_currency_id.id != subs_account.company_currency_id.id: | 225 | if (holding_account.company_currency_id.id == |
1943 | 229 | currency_rate_type = self._currency_rate_type(cr, uid, ids, holding_account, context=context) | 226 | subs_account.company_currency_id.id): |
1944 | 227 | vals.update({ | ||
1945 | 228 | 'debit': subs_account.debit, | ||
1946 | 229 | 'credit': subs_account.credit, | ||
1947 | 230 | }) | ||
1948 | 231 | else: | ||
1949 | 232 | currency_rate_type = self._currency_rate_type( | ||
1950 | 233 | cr, uid, ids, holding_account, context=context) | ||
1951 | 230 | 234 | ||
1959 | 231 | currency_value = currency_obj.compute(cr, uid, | 235 | currency_value = currency_obj.compute( |
1960 | 232 | holding_account.company_currency_id.id, | 236 | cr, uid, |
1961 | 233 | subs_account.company_currency_id.id, | 237 | holding_account.company_currency_id.id, |
1962 | 234 | subs_account.balance, | 238 | subs_account.company_currency_id.id, |
1963 | 235 | currency_rate_type_from=False, # means spot | 239 | subs_account.balance, |
1964 | 236 | currency_rate_type_to=currency_rate_type, | 240 | currency_rate_type_from=False, # means spot |
1965 | 237 | context=context) | 241 | currency_rate_type_to=currency_rate_type, |
1966 | 242 | context=context) | ||
1967 | 238 | vals.update({ | 243 | vals.update({ |
1968 | 239 | 'currency_id': subs_account.company_currency_id.id, | 244 | 'currency_id': subs_account.company_currency_id.id, |
1969 | 240 | 'amount_currency': subs_account.balance, | 245 | 'amount_currency': subs_account.balance, |
1970 | @@ -242,72 +247,73 @@ | |||
1971 | 242 | 'credit': currency_value < 0 and -currency_value or 0.0 | 247 | 'credit': currency_value < 0 and -currency_value or 0.0 |
1972 | 243 | }) | 248 | }) |
1973 | 244 | 249 | ||
1974 | 245 | else: | ||
1975 | 246 | vals.update({ | ||
1976 | 247 | 'debit': subs_account.debit, | ||
1977 | 248 | 'credit': subs_account.credit, | ||
1978 | 249 | }) | ||
1979 | 250 | |||
1980 | 251 | move_line_id = move_line_obj.create(cr, uid, vals, context=context) | 250 | move_line_id = move_line_obj.create(cr, uid, vals, context=context) |
1981 | 252 | 251 | ||
1982 | 253 | return move_line_id | 252 | return move_line_id |
1983 | 254 | 253 | ||
1985 | 255 | def reverse_moves(self, cr, uid, ids, subsidiary_id, journal_id, reversal_date, context): | 254 | def reverse_moves(self, cr, uid, ids, subsidiary_id, journal_id, |
1986 | 255 | reversal_date, context=None): | ||
1987 | 256 | """ | 256 | """ |
2000 | 257 | Reverse all account moves of a journal which have the "To be reversed" flag | 257 | Reverse all account moves of a journal which have |
2001 | 258 | 258 | the "To be reversed" flag | |
2002 | 259 | @param self: The object pointer | 259 | |
2003 | 260 | @param cr: the current row, from the database cursor, | 260 | :param subsidiary_id: ID of the subsidiary moves to reverse |
2004 | 261 | @param uid: the current user’s ID for security checks, | 261 | :param journal_id: ID of the journal with moves to reverse |
2005 | 262 | @param ids: List of the wizard IDs (commonly the first element is the current ID) | 262 | :param reversal_date: date when to create the reversal |
2006 | 263 | @param subsidiary_id: ID of the subsidiary moves to reverse | 263 | |
2007 | 264 | @param journal_id: ID of the journal with moves to reverse | 264 | :return: tuple with : list of IDs of the reversed moves, |
2008 | 265 | @param reversal_date: date when to create the reversal | 265 | list of IDs of the reversal moves |
1997 | 266 | @param context: A standard dictionary for contextual values | ||
1998 | 267 | |||
1999 | 268 | @return: tuple with : list of IDs of the reversed moves, list of IDs of the reversal moves | ||
2009 | 269 | """ | 266 | """ |
2010 | 270 | move_obj = self.pool.get('account.move') | 267 | move_obj = self.pool.get('account.move') |
2017 | 271 | reversed_ids = move_obj.search(cr, uid, | 268 | reversed_ids = move_obj.search( |
2018 | 272 | [('journal_id', '=', journal_id), | 269 | cr, uid, |
2019 | 273 | ('to_be_reversed', '=', True), | 270 | [('journal_id', '=', journal_id), |
2020 | 274 | ('consol_company_id', '=', subsidiary_id)], | 271 | ('to_be_reversed', '=', True), |
2021 | 275 | context=context) | 272 | ('consol_company_id', '=', subsidiary_id)], |
2022 | 276 | reversal_ids = move_obj.create_reversals(cr, uid, reversed_ids, reversal_date, context=context) | 273 | context=context) |
2023 | 274 | reversal_ids = move_obj.create_reversals( | ||
2024 | 275 | cr, uid, reversed_ids, reversal_date, context=context) | ||
2025 | 277 | return reversed_ids, reversal_ids | 276 | return reversed_ids, reversal_ids |
2026 | 278 | 277 | ||
2028 | 279 | def consolidate_subsidiary(self, cr, uid, ids, subsidiary_id, context=None): | 278 | def consolidate_subsidiary(self, cr, uid, ids, |
2029 | 279 | subsidiary_id, context=None): | ||
2030 | 280 | """ | 280 | """ |
2031 | 281 | Consolidate one subsidiary on the Holding. | 281 | Consolidate one subsidiary on the Holding. |
2032 | 282 | Create a move per subsidiary and consolidation type (YTD/Period) | 282 | Create a move per subsidiary and consolidation type (YTD/Period) |
2033 | 283 | and an move line per account of the subsidiary | 283 | and an move line per account of the subsidiary |
2044 | 284 | Plus a move line for the currency gain / loss # FIXME to check! | 284 | |
2045 | 285 | 285 | :param subsidiary_id: ID of the subsidiary to consolidate | |
2046 | 286 | @param self: The object pointer | 286 | on the holding |
2047 | 287 | @param cr: the current row, from the database cursor, | 287 | |
2048 | 288 | @param uid: the current user’s ID for security checks, | 288 | :return: Tuple of form: |
2049 | 289 | @param ids: List of the wizard IDs (commonly the first element is the current ID) | 289 | (list of IDs of the YTD moves, |
2050 | 290 | @param subsidiary_id: ID of the subsidiary to consolidate on the holding | 290 | list of IDs of the Period Moves) |
2041 | 291 | @param context: A standard dictionary for contextual values | ||
2042 | 292 | |||
2043 | 293 | @return: Tuple of (list of IDs of the YTD moves, list of IDs of the Period Moves) | ||
2051 | 294 | """ | 291 | """ |
2054 | 295 | 292 | if context is None: | |
2055 | 296 | context = context or {} | 293 | context = {} |
2056 | 294 | |||
2057 | 295 | if isinstance(ids, (int, long)): | ||
2058 | 296 | ids = [ids] | ||
2059 | 297 | assert len(ids) == 1, "only 1 id expected" | ||
2060 | 298 | |||
2061 | 297 | company_obj = self.pool.get('res.company') | 299 | company_obj = self.pool.get('res.company') |
2062 | 298 | move_obj = self.pool.get('account.move') | 300 | move_obj = self.pool.get('account.move') |
2063 | 299 | period_obj = self.pool.get('account.period') | 301 | period_obj = self.pool.get('account.period') |
2064 | 302 | |||
2065 | 300 | form = self.browse(cr, uid, ids[0], context=context) | 303 | form = self.browse(cr, uid, ids[0], context=context) |
2066 | 301 | subsidiary = company_obj.browse(cr, uid, subsidiary_id, context=None) | 304 | subsidiary = company_obj.browse(cr, uid, subsidiary_id, context=None) |
2067 | 302 | 305 | ||
2076 | 303 | data_ctx = context.copy() | 306 | data_ctx = dict(context, holding_coa=True) |
2077 | 304 | data_ctx.update({'holding_coa': True}) | 307 | holding_accounts_data = self._chart_accounts_data( |
2078 | 305 | holding_accounts_data = self._chart_accounts_data(cr, uid, ids, | 308 | cr, uid, |
2079 | 306 | form.holding_chart_account_id.id, | 309 | ids, |
2080 | 307 | context=data_ctx) | 310 | form.holding_chart_account_id.id, |
2081 | 308 | subs_accounts_codes = self._chart_accounts_data(cr, uid, ids, | 311 | context=data_ctx) |
2082 | 309 | subsidiary.consolidation_chart_account_id.id, | 312 | subs_accounts_codes = self._chart_accounts_data( |
2083 | 310 | context=context) | 313 | cr, uid, |
2084 | 314 | ids, | ||
2085 | 315 | subsidiary.consolidation_chart_account_id.id, | ||
2086 | 316 | context=context) | ||
2087 | 311 | holding_accounts = [values for key, values | 317 | holding_accounts = [values for key, values |
2088 | 312 | in holding_accounts_data.iteritems() | 318 | in holding_accounts_data.iteritems() |
2089 | 313 | if key in subs_accounts_codes] | 319 | if key in subs_accounts_codes] |
2090 | @@ -316,12 +322,14 @@ | |||
2091 | 316 | # a move per type will be created | 322 | # a move per type will be created |
2092 | 317 | consolidation_modes = {'ytd': [], 'period': []} | 323 | consolidation_modes = {'ytd': [], 'period': []} |
2093 | 318 | for account in holding_accounts: | 324 | for account in holding_accounts: |
2095 | 319 | cm = self._consolidation_mode(cr, uid, ids, account, context=context) | 325 | cm = self._consolidation_mode( |
2096 | 326 | cr, uid, ids, account, context=context) | ||
2097 | 320 | consolidation_modes[cm].append(account) | 327 | consolidation_modes[cm].append(account) |
2098 | 321 | 328 | ||
2102 | 322 | period_ids = period_obj.build_ctx_periods(cr, uid, | 329 | period_ids = period_obj.build_ctx_periods( |
2103 | 323 | form.from_period_id.id, | 330 | cr, uid, |
2104 | 324 | form.to_period_id.id) | 331 | form.from_period_id.id, |
2105 | 332 | form.to_period_id.id) | ||
2106 | 325 | 333 | ||
2107 | 326 | generic_move_vals = { | 334 | generic_move_vals = { |
2108 | 327 | 'journal_id': form.journal_id.id, | 335 | 'journal_id': form.journal_id.id, |
2109 | @@ -337,15 +345,18 @@ | |||
2110 | 337 | 345 | ||
2111 | 338 | # get list of periods for which we have to create a move | 346 | # get list of periods for which we have to create a move |
2112 | 339 | # in period mode : a move per period | 347 | # in period mode : a move per period |
2117 | 340 | # in ytd mode : a move at the last period (which will contains lines from 1st january to last period) | 348 | # in ytd mode : a move at the last period |
2118 | 341 | move_period_ids = consolidation_mode == 'period' \ | 349 | # (which will contains lines from 1st january to last period) |
2119 | 342 | and period_ids \ | 350 | move_period_ids = (period_ids |
2120 | 343 | or [form.to_period_id.id] | 351 | if consolidation_mode == 'period' |
2121 | 352 | else [form.to_period_id.id]) | ||
2122 | 344 | 353 | ||
2123 | 345 | for move_period_id in move_period_ids: | 354 | for move_period_id in move_period_ids: |
2125 | 346 | period = period_obj.browse(cr, uid, move_period_id, context=context) | 355 | period = period_obj.browse( |
2126 | 356 | cr, uid, move_period_id, context=context) | ||
2127 | 347 | 357 | ||
2129 | 348 | # in ytd we compute the amount from the first day of the fiscal year | 358 | # in ytd we compute the amount from the first |
2130 | 359 | # day of the fiscal year | ||
2131 | 349 | # in period, only for the period | 360 | # in period, only for the period |
2132 | 350 | if consolidation_mode == 'ytd': | 361 | if consolidation_mode == 'ytd': |
2133 | 351 | date_from = period.fiscalyear_id.date_start | 362 | date_from = period.fiscalyear_id.date_start |
2134 | @@ -353,50 +364,51 @@ | |||
2135 | 353 | date_from = period.date_start | 364 | date_from = period.date_start |
2136 | 354 | date_to = period.date_stop | 365 | date_to = period.date_stop |
2137 | 355 | 366 | ||
2147 | 356 | period_ctx = context.copy() | 367 | period_ctx = dict(context, company_id=subsidiary.id) |
2148 | 357 | period_ctx.update({ | 368 | compute_from_period_id = period_obj.find( |
2149 | 358 | 'company_id': subsidiary.id, | 369 | cr, uid, date_from, context=period_ctx)[0] |
2150 | 359 | }) | 370 | compute_to_period_id = period_obj.find( |
2151 | 360 | compute_from_period_id = period_obj.find(cr, uid, date_from, context=period_ctx)[0] | 371 | cr, uid, date_to, context=period_ctx)[0] |
2152 | 361 | compute_to_period_id = period_obj.find(cr, uid, date_to, context=period_ctx)[0] | 372 | compute_period_ids = period_obj.build_ctx_periods( |
2153 | 362 | compute_period_ids = period_obj.build_ctx_periods(cr, uid, | 373 | cr, uid, |
2154 | 363 | compute_from_period_id, | 374 | compute_from_period_id, |
2155 | 364 | compute_to_period_id) | 375 | compute_to_period_id) |
2156 | 365 | 376 | ||
2157 | 366 | # reverse previous entries with flag 'to_be_reversed' (YTD) | 377 | # reverse previous entries with flag 'to_be_reversed' (YTD) |
2161 | 367 | self.reverse_moves(cr, uid, ids, subsidiary.id, form.journal_id.id, date_to, context=context) | 378 | self.reverse_moves( |
2162 | 368 | 379 | cr, uid, | |
2163 | 369 | # TODO if moves found for the same period : skip ? | 380 | ids, |
2164 | 381 | subsidiary.id, | ||
2165 | 382 | form.journal_id.id, | ||
2166 | 383 | date_to, | ||
2167 | 384 | context=context) | ||
2168 | 370 | 385 | ||
2169 | 371 | # create the account move | 386 | # create the account move |
2170 | 372 | # at the very last date of the end period | 387 | # at the very last date of the end period |
2177 | 373 | move_vals = generic_move_vals.copy() | 388 | move_vals = dict( |
2178 | 374 | move_vals.update({ | 389 | generic_move_vals, |
2179 | 375 | 'ref': _("Consolidation %s") % (consolidation_mode,), | 390 | ref=_("Consolidation %s") % consolidation_mode, |
2180 | 376 | 'period_id': period.id, | 391 | period_id=period.id, |
2181 | 377 | 'date': period.date_stop, | 392 | date=period.date_stop) |
2176 | 378 | }) | ||
2182 | 379 | move_id = move_obj.create(cr, uid, move_vals, context=context) | 393 | move_id = move_obj.create(cr, uid, move_vals, context=context) |
2183 | 380 | 394 | ||
2184 | 381 | move_line_ids = [] | 395 | move_line_ids = [] |
2185 | 382 | # create a move line per account | 396 | # create a move line per account |
2186 | 383 | for account in accounts: | 397 | for account in accounts: |
2187 | 384 | move_line_ids.append( | 398 | move_line_ids.append( |
2196 | 385 | self.consolidate_account(cr, uid, ids, | 399 | self.consolidate_account( |
2197 | 386 | consolidation_mode, | 400 | cr, uid, ids, |
2198 | 387 | compute_period_ids, | 401 | consolidation_mode, |
2199 | 388 | form.target_move, | 402 | compute_period_ids, |
2200 | 389 | move_id, | 403 | form.target_move, |
2201 | 390 | account.id, | 404 | move_id, |
2202 | 391 | subsidiary.id, | 405 | account.id, |
2203 | 392 | context=context) | 406 | subsidiary.id, |
2204 | 407 | context=context) | ||
2205 | 393 | ) | 408 | ) |
2206 | 394 | 409 | ||
2212 | 395 | # TODO calculate currency rate difference (all move lines debit - all move lines credit) and post a move line | 410 | self.create_rate_difference_line( |
2213 | 396 | # on the gain / loss account | 411 | cr, uid, ids, move_id, context=context) |
2209 | 397 | # will works IF : counterparts are always configured with the same mode (YTD/Periods) | ||
2210 | 398 | self.create_rate_difference_line(cr, uid, ids, | ||
2211 | 399 | move_id, context=context) | ||
2214 | 400 | 412 | ||
2215 | 401 | locals()[consolidation_mode + '_move_ids'].append(move_id) | 413 | locals()[consolidation_mode + '_move_ids'].append(move_id) |
2216 | 402 | 414 | ||
2217 | @@ -407,15 +419,10 @@ | |||
2218 | 407 | Consolidate all selected subsidiaries Virtual Chart of Accounts | 419 | Consolidate all selected subsidiaries Virtual Chart of Accounts |
2219 | 408 | on the Holding Chart of Account | 420 | on the Holding Chart of Account |
2220 | 409 | 421 | ||
2228 | 410 | @param self: The object pointer | 422 | :return: dict to open an Entries view filtered on the created moves |
2222 | 411 | @param cr: the current row, from the database cursor, | ||
2223 | 412 | @param uid: the current user’s ID for security checks, | ||
2224 | 413 | @param ids: List of the wizard IDs (commonly the first element is the current ID) | ||
2225 | 414 | @param context: A standard dictionary for contextual values | ||
2226 | 415 | |||
2227 | 416 | @return: dict to open an Entries view filtered on the created moves | ||
2229 | 417 | """ | 423 | """ |
2231 | 418 | super(account_consolidation_consolidate, self).run_consolidation(cr, uid, ids, context=context) | 424 | super(account_consolidation_consolidate, self).run_consolidation( |
2232 | 425 | cr, uid, ids, context=context) | ||
2233 | 419 | 426 | ||
2234 | 420 | mod_obj = self.pool.get('ir.model.data') | 427 | mod_obj = self.pool.get('ir.model.data') |
2235 | 421 | act_obj = self.pool.get('ir.actions.act_window') | 428 | act_obj = self.pool.get('ir.actions.act_window') |
2236 | @@ -425,20 +432,23 @@ | |||
2237 | 425 | move_ids = [] | 432 | move_ids = [] |
2238 | 426 | ytd_move_ids = [] | 433 | ytd_move_ids = [] |
2239 | 427 | for subsidiary in form.subsidiary_ids: | 434 | for subsidiary in form.subsidiary_ids: |
2243 | 428 | new_move_ids = self.consolidate_subsidiary(cr, uid, ids, subsidiary.id, context=context) | 435 | new_move_ids = self.consolidate_subsidiary( |
2244 | 429 | ytd_move_ids.extend(new_move_ids[0]) | 436 | cr, uid, ids, subsidiary.id, context=context) |
2245 | 430 | move_ids.extend(sum(new_move_ids, [])) | 437 | ytd_move_ids += new_move_ids[0] |
2246 | 438 | move_ids += sum(new_move_ids, []) | ||
2247 | 431 | 439 | ||
2248 | 432 | # YTD moves have to be reversed on the next consolidation | 440 | # YTD moves have to be reversed on the next consolidation |
2250 | 433 | move_obj.write(cr, uid, ytd_move_ids, {'to_be_reversed': True}, context=context) | 441 | move_obj.write( |
2251 | 442 | cr, uid, | ||
2252 | 443 | ytd_move_ids, | ||
2253 | 444 | {'to_be_reversed': True}, | ||
2254 | 445 | context=context) | ||
2255 | 434 | 446 | ||
2256 | 435 | context.update({'move_ids': move_ids}) | 447 | context.update({'move_ids': move_ids}) |
2259 | 436 | action_ref = mod_obj.get_object_reference(cr, uid, 'account', 'action_move_journal_line') | 448 | __, action_id = mod_obj.get_object_reference( |
2260 | 437 | action_id = action_ref and action_ref[1] or False | 449 | cr, uid, 'account', 'action_move_journal_line') |
2261 | 438 | action = act_obj.read(cr, uid, [action_id], context=context)[0] | 450 | action = act_obj.read(cr, uid, [action_id], context=context)[0] |
2262 | 439 | action['domain'] = unicode([('id', 'in', move_ids)]) | 451 | action['domain'] = unicode([('id', 'in', move_ids)]) |
2263 | 440 | action['name'] = _('Consolidated Entries') | 452 | action['name'] = _('Consolidated Entries') |
2264 | 441 | action['context'] = unicode({'search_default_to_be_reversed': 0}) | 453 | action['context'] = unicode({'search_default_to_be_reversed': 0}) |
2265 | 442 | return action | 454 | return action |
2266 | 443 | |||
2267 | 444 | account_consolidation_consolidate() | ||
2268 | 445 | 455 | ||
2269 | === modified file 'account_consolidation/wizard/consolidation_consolidate_view.xml' | |||
2270 | --- account_consolidation/wizard/consolidation_consolidate_view.xml 2011-08-29 05:45:40 +0000 | |||
2271 | +++ account_consolidation/wizard/consolidation_consolidate_view.xml 2013-01-09 09:53:22 +0000 | |||
2272 | @@ -2,39 +2,49 @@ | |||
2273 | 2 | <openerp> | 2 | <openerp> |
2274 | 3 | <data> | 3 | <data> |
2275 | 4 | 4 | ||
2277 | 5 | <record id="view_consolidation_consolidate_form" model="ir.ui.view"> | 5 | <record id="view_consolidation_consolidate_form" model="ir.ui.view"> |
2278 | 6 | <field name="name">account.consolidation.consolidate.form</field> | 6 | <field name="name">account.consolidation.consolidate.form</field> |
2279 | 7 | <field name="model">account.consolidation.consolidate</field> | 7 | <field name="model">account.consolidation.consolidate</field> |
2280 | 8 | <field name="type">form</field> | 8 | <field name="type">form</field> |
2281 | 9 | <field name="arch" type="xml"> | 9 | <field name="arch" type="xml"> |
2292 | 10 | <form string="Consolidation: Consolidate"> | 10 | <form string="Consolidation: Consolidate" version="7.0"> |
2293 | 11 | <group col="4" colspan="6"> | 11 | <label string="Run the consolidation for the selected periods and subsidiaries."/> |
2294 | 12 | <field name="company_id" on_change="on_change_company_id(company_id)" invisible="True"/> | 12 | <group> |
2295 | 13 | <field name="fiscalyear_id" invisible="True"/> | 13 | <field name="company_id" |
2296 | 14 | <field name="from_period_id" on_change="on_change_from_period_id(from_period_id, to_period_id)" domain="[('company_id', '=', company_id)]"/> | 14 | on_change="on_change_company_id(company_id)" |
2297 | 15 | <field name="to_period_id" domain="[('company_id', '=', company_id)]"/> | 15 | invisible="True"/> |
2298 | 16 | <field name="journal_id" domain="[('company_id', '=', company_id)]"/> | 16 | <field name="fiscalyear_id" invisible="True"/> |
2299 | 17 | <field name="target_move"/> | 17 | <field name="from_period_id" |
2300 | 18 | <separator string="Holding Chart of Accounts" colspan="4"/> | 18 | on_change="on_change_from_period_id(from_period_id, to_period_id)" |
2301 | 19 | <field name="holding_chart_account_id" domain="[('company_id', '=', company_id), ('parent_id', '=', False)]"/> | 19 | domain="[('company_id', '=', company_id)]"/> |
2302 | 20 | <field name="to_period_id" | ||
2303 | 21 | domain="[('company_id', '=', company_id)]"/> | ||
2304 | 22 | <field name="journal_id" | ||
2305 | 23 | domain="[('company_id', '=', company_id)]"/> | ||
2306 | 24 | <field name="target_move"/> | ||
2307 | 25 | <separator string="Holding Chart of Accounts" colspan="4"/> | ||
2308 | 26 | <field name="holding_chart_account_id" | ||
2309 | 27 | domain="[('company_id', '=', company_id), ('parent_id', '=', False)]"/> | ||
2310 | 20 | 28 | ||
2328 | 21 | <!--<separator string="Consolidation Difference Accounts" colspan="4"/>--> | 29 | <separator string="Subsidiaries to Consolidate" colspan="4"/> |
2329 | 22 | <!--<field name="gain_account_id" domain="[('type','<>','view'), ('id', 'child_of', [holding_chart_account_id])]"/>--> | 30 | <field name="subsidiary_ids" colspan="4" |
2330 | 23 | <!--<field name="loss_account_id" domain="[('type','<>','view'), ('id', 'child_of', [holding_chart_account_id])]"/>--> | 31 | nolabel="1" required="True"> |
2331 | 24 | <separator string="Subsidiaries to Consolidate" colspan="4"/> | 32 | <tree> |
2332 | 25 | <field name="subsidiary_ids" colspan="4" nolabel="1" required="True"> | 33 | <field name="name"/> |
2333 | 26 | <tree> | 34 | <field name="consolidation_chart_account_id"/> |
2334 | 27 | <field name="name"/> | 35 | </tree> |
2335 | 28 | <field name="consolidation_chart_account_id"/> | 36 | </field> |
2336 | 29 | </tree> | 37 | </group> |
2337 | 30 | </field> | 38 | <separator colspan="4"/> |
2338 | 31 | </group> | 39 | <footer> |
2339 | 32 | <separator colspan="4"/> | 40 | <button name="run_consolidation" |
2340 | 33 | <group col="2" colspan="4"> | 41 | string="Consolidate" |
2341 | 34 | <button special="cancel" string="Cancel" icon='gtk-cancel'/> | 42 | type="object" |
2342 | 35 | <button name="run_consolidation" string="Consolidate" colspan="1" type="object" icon="gtk-execute"/> | 43 | class="oe_highlight"/> |
2343 | 36 | </group> | 44 | or |
2344 | 37 | </form> | 45 | <button string="Cancel" class="oe_link" special="cancel"/> |
2345 | 46 | </footer> | ||
2346 | 47 | </form> | ||
2347 | 38 | </field> | 48 | </field> |
2348 | 39 | </record> | 49 | </record> |
2349 | 40 | 50 | ||
2350 | @@ -44,9 +54,8 @@ | |||
2351 | 44 | <field name="res_model">account.consolidation.consolidate</field> | 54 | <field name="res_model">account.consolidation.consolidate</field> |
2352 | 45 | <field name="view_type">form</field> | 55 | <field name="view_type">form</field> |
2353 | 46 | <field name="view_mode">form</field> | 56 | <field name="view_mode">form</field> |
2354 | 47 | <field name="help">Run the consolidation for the selected periods and subsidiaries.</field> | ||
2355 | 48 | <field name="target">new</field> | 57 | <field name="target">new</field> |
2356 | 49 | </record> | 58 | </record> |
2357 | 50 | 59 | ||
2359 | 51 | </data> | 60 | </data> |
2360 | 52 | </openerp> | 61 | </openerp> |
992 + :param fyear_id: ID of the fiscal years to compare
-> if it is a single fiscal year, then s/years/year/. Otherwise, the arg should be renamed fyear_ids.
1758 + return account. user_type. consolidation_ rate_type_ id
-> I think you want to return account. user_type. consolidation_ rate_type_ id.id (according to the original code)