Merge lp:~camptocamp/account-consolidation/7.0-account_consolidation-migr into lp:~account-core-editors/account-consolidation/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
Reviewer Review Type Date Requested Status
Alexandre Fayolle - camptocamp Approve
Review via email: mp+142453@code.launchpad.net

Commit message

[MIGR] Migration of account_consolidation to OpenERP version 7.0

Description of the change

Migration of the 'account_consolidation' module.

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 :

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)

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 # -*- coding: utf-8 -*-
6 ##############################################################################
7 #
8-# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)
9-# All Right Reserved
10-#
11-# Author : Guewen Baconnier (Camptocamp)
12-#
13-# WARNING: This program as such is intended to be used by professional
14-# programmers who take the whole responsability of assessing all potential
15-# consequences resulting from its eventual inadequacies and bugs
16-# End users who are looking for a ready-to-use solution with commercial
17-# garantees and support are strongly adviced to contract a Free Software
18-# Service Company
19-#
20-# This program is Free Software; you can redistribute it and/or
21-# modify it under the terms of the GNU General Public License
22-# as published by the Free Software Foundation; either version 2
23-# of the License, or (at your option) any later version.
24-#
25-# This program is distributed in the hope that it will be useful,
26-# but WITHOUT ANY WARRANTY; without even the implied warranty of
27-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28-# GNU General Public License for more details.
29-#
30-# You should have received a copy of the GNU General Public License
31-# along with this program; if not, write to the Free Software
32-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33+# Author: Guewen Baconnier
34+# Copyright 2011-2013 Camptocamp SA
35+#
36+# This program is free software: you can redistribute it and/or modify
37+# it under the terms of the GNU Affero General Public License as
38+# published by the Free Software Foundation, either version 3 of the
39+# License, or (at your option) any later version.
40+#
41+# This program is distributed in the hope that it will be useful,
42+# but WITHOUT ANY WARRANTY; without even the implied warranty of
43+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44+# GNU Affero General Public License for more details.
45+#
46+# You should have received a copy of the GNU Affero General Public License
47+# along with this program. If not, see <http://www.gnu.org/licenses/>.
48 #
49 ##############################################################################
50
51-
52 {
53 "name" : "Account Consolidation",
54- "version" : "0.0",
55+ "version" : "1.0",
56 "author" : "Camptocamp",
57+ 'license': 'AGPL-3',
58 "category" : "Generic Modules/Accounting",
59 "description":
60 """
61-Account consolidation module. Coding in progress...
62-
63-Some explanations to do...
64-
65- - Difference between debit/credit is balanced on the debit/credit default account of the journal?
66+Account consolidation
67+=====================
68+
69+Introduction
70+------------
71+
72+Consolidate chart of accounts on subsidiaries
73+in a virtual chart of accounts of the holding.
74+
75+Installation
76+------------
77+The `account_reversal` module is required,
78+it can be found on the account-financial-tools_
79+project
80+
81+.. _account-financial-tools: https://launchpad.net/account-financial-tools
82+
83 """,
84 "website": "http://www.camptocamp.com",
85 "depends" : [
86@@ -49,13 +51,12 @@
87 'account',
88 'account_reversal',
89 ],
90- "init_xml" : [],
91 "demo_xml" : [
92 'demo/consolidation_demo.xml',
93 'demo/chart_a_demo.xml',
94 'demo/chart_b_demo.xml',
95 ],
96- "update_xml" : [
97+ "data" : [
98 'company_view.xml',
99 'account_view.xml',
100 'wizard/consolidation_check_view.xml',
101@@ -68,5 +69,5 @@
102 'test/consolidation_consolidate.yml',
103 ],
104 "active": False,
105- "installable": False,
106+ "installable": True,
107 }
108
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 # -*- coding: utf-8 -*-
114 ##############################################################################
115 #
116-# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)
117-#
118-# Author : Guewen Baconnier (Camptocamp)
119-#
120-# WARNING: This program as such is intended to be used by professional
121-# programmers who take the whole responsability of assessing all potential
122-# consequences resulting from its eventual inadequacies and bugs
123-# End users who are looking for a ready-to-use solution with commercial
124-# garantees and support are strongly adviced to contract a Free Software
125-# Service Company
126-#
127-# This program is Free Software; you can redistribute it and/or
128-# modify it under the terms of the GNU General Public License
129-# as published by the Free Software Foundation; either version 2
130-# of the License, or (at your option) any later version.
131-#
132-# This program is distributed in the hope that it will be useful,
133-# but WITHOUT ANY WARRANTY; without even the implied warranty of
134-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
135-# GNU General Public License for more details.
136-#
137-# You should have received a copy of the GNU General Public License
138-# along with this program; if not, write to the Free Software
139-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
140+# Author: Guewen Baconnier
141+# Copyright 2011-2013 Camptocamp SA
142+#
143+# This program is free software: you can redistribute it and/or modify
144+# it under the terms of the GNU Affero General Public License as
145+# published by the Free Software Foundation, either version 3 of the
146+# License, or (at your option) any later version.
147+#
148+# This program is distributed in the hope that it will be useful,
149+# but WITHOUT ANY WARRANTY; without even the implied warranty of
150+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
151+# GNU Affero General Public License for more details.
152+#
153+# You should have received a copy of the GNU Affero General Public License
154+# along with this program. If not, see <http://www.gnu.org/licenses/>.
155 #
156 ##############################################################################
157
158-from osv import osv, fields
159-
160-
161-class account_account(osv.osv):
162+from openerp.osv import orm, fields
163+
164+
165+class account_account(orm.Model):
166 _inherit = 'account.account'
167
168 _columns = {
169- 'consolidation_rate_type_id': fields.many2one('res.currency.rate.type',
170- 'Consolidation Currency Rate Type',
171- help="Currency rate type used on this account for the consolidation, Leave empty to use the rate type of the account type."),
172- 'consolidation_mode': fields.selection([('', ''),
173- ('ytd', 'YTD'),
174- ('period', 'Period Movements'),
175- ],
176- 'Consolidation Mode'),
177+ 'consolidation_rate_type_id': fields.many2one(
178+ 'res.currency.rate.type',
179+ 'Consolidation Currency Rate Type',
180+ help="Currency rate type used on this account "
181+ "for the consolidation. "
182+ "Leave empty to use the rate type of the account type."),
183+ 'consolidation_mode': fields.selection(
184+ [('ytd', 'YTD'),
185+ ('period', 'Period Movements')],
186+ 'Consolidation Mode'),
187 }
188
189-account_account()
190-
191-
192-class account_account_type(osv.osv):
193+
194+class account_account_type(orm.Model):
195 _inherit = 'account.account.type'
196
197 _columns = {
198- 'consolidation_rate_type_id': fields.many2one('res.currency.rate.type',
199- 'Consolidation Currency Rate Type',
200- help="Currency rate type used on this account type for the consolidation, Leave empty to use the 'spot' rate type."),
201- 'consolidation_mode': fields.selection([('ytd', 'YTD'),
202- ('period', 'Period Movements'),],
203- 'Consolidation Mode'),
204+ 'consolidation_rate_type_id': fields.many2one(
205+ 'res.currency.rate.type',
206+ 'Consolidation Currency Rate Type',
207+ help="Currency rate type used on this account type "
208+ "for the consolidation. "
209+ "Leave empty to use the 'spot' rate type."),
210+ 'consolidation_mode': fields.selection(
211+ [('ytd', 'YTD'),
212+ ('period', 'Period Movements')],
213+ 'Consolidation Mode'),
214 }
215
216 _defaults = {
217 'consolidation_mode': 'ytd',
218 }
219
220-account_account_type()
221-
222-
223-class account_move(osv.osv):
224+
225+class account_move(orm.Model):
226 _inherit = 'account.move'
227
228 _columns = {
229- 'consol_company_id': fields.many2one('res.company', 'Consolidated from Company', readonly=True),
230+ 'consol_company_id': fields.many2one(
231+ 'res.company',
232+ 'Consolidated from Company',
233+ readonly=True),
234 }
235-
236-account_move()
237
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 <field name="type">form</field>
243 <field name="arch" type="xml">
244 <data>
245- <xpath expr="/form/notebook/page[@string='General Information']/group[2]" position="after">
246- <group col="2" colspan="2">
247+ <xpath expr="//field[@name='note']" position="after">
248+ <group>
249 <separator string="Consolidation" colspan="2"/>
250 <field name="consolidation_rate_type_id" widget="selection"/>
251 <field name="consolidation_mode"/>
252@@ -20,7 +20,7 @@
253 </data>
254 </field>
255 </record>
256-
257+
258 <record id="view_account_type_consolidation_form" model="ir.ui.view">
259 <field name="name">account.account.type.consolidation.form</field>
260 <field name="model">account.account.type</field>
261@@ -44,11 +44,11 @@
262 <field name="type">form</field>
263 <field name="arch" type="xml">
264 <field name="company_id" position="after">
265- <field name="consol_company_id" attrs="{'invisible': [('consol_company_id', '=', False)]}"/>
266+ <field name="consol_company_id"
267+ attrs="{'invisible': [('consol_company_id', '=', False)]}"/>
268 </field>
269 </field>
270 </record>
271
272 </data>
273 </openerp>
274-
275
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 @@
280-# -*- coding: utf-8 -*-
281-##############################################################################
282-#
283-# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)
284-# All Right Reserved
285-#
286-# Author : Guewen Baconnier (Camptocamp)
287-#
288-# WARNING: This program as such is intended to be used by professional
289-# programmers who take the whole responsability of assessing all potential
290-# consequences resulting from its eventual inadequacies and bugs
291-# End users who are looking for a ready-to-use solution with commercial
292-# garantees and support are strongly adviced to contract a Free Software
293-# Service Company
294-#
295-# This program is Free Software; you can redistribute it and/or
296-# modify it under the terms of the GNU General Public License
297-# as published by the Free Software Foundation; either version 2
298-# of the License, or (at your option) any later version.
299-#
300-# This program is distributed in the hope that it will be useful,
301-# but WITHOUT ANY WARRANTY; without even the implied warranty of
302-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
303-# GNU General Public License for more details.
304-#
305-# You should have received a copy of the GNU General Public License
306-# along with this program; if not, write to the Free Software
307-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
308-#
309-##############################################################################
310-
311-from osv import osv, fields
312-
313-
314-class res_company(osv.osv):
315+# -* coding: utf-8 -*-
316+##############################################################################
317+#
318+# Author: Guewen Baconnier
319+# Copyright 2011-2013 Camptocamp SA
320+#
321+# This program is free software: you can redistribute it and/or modify
322+# it under the terms of the GNU Affero General Public License as
323+# published by the Free Software Foundation, either version 3 of the
324+# License, or (at your option) any later version.
325+#
326+# This program is distributed in the hope that it will be useful,
327+# but WITHOUT ANY WARRANTY; without even the implied warranty of
328+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
329+# GNU Affero General Public License for more details.
330+#
331+# You should have received a copy of the GNU Affero General Public License
332+# along with this program. If not, see <http://www.gnu.org/licenses/>.
333+#
334+##############################################################################
335+
336+from openerp.osv import orm, fields
337+
338+
339+class res_company(orm.Model):
340 _inherit = 'res.company'
341
342 _columns = {
343- 'consolidation_chart_account_id': fields.many2one('account.account',
344- 'Chart of Accounts for Consolidation',
345- domain=[('parent_id', '=', False)]),
346+ 'consolidation_chart_account_id': fields.many2one(
347+ 'account.account',
348+ 'Chart of Accounts for Consolidation',
349+ domain=[('parent_id', '=', False)]),
350 }
351-
352-res_company()
353
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 <field name="company_id" ref="subsidiary_a"/>
359 </record>
360
361- <record id="period_b_1" model="account.period">
362+ <record id="period_b_1" model="account.period">
363 <field eval="'01/'+time.strftime('%Y')" name="code"/>
364 <field eval="'01/'+time.strftime('%Y')" name="name"/>
365 <field eval="True" name="special"/>
366@@ -292,25 +292,23 @@
367 <field name="company_id" ref="subsidiary_b"/>
368 </record>
369
370- <record id="account_journal_sale0" model="account.journal">
371- <field name="code">SALE</field>
372- <field name="name">SALE</field>
373- <field name="view_id" ref="account.account_sp_journal_view"/>
374- <field name="company_id" ref="account_consolidation.subsidiary_a"/>
375- <field name="sequence_id" ref="account.sequence_sale_journal"/>
376- <field eval="1" name="allow_date"/>
377- <field name="type">sale</field>
378- </record>
379+ <record id="account_journal_sale0" model="account.journal">
380+ <field name="code">SALE</field>
381+ <field name="name">SALE</field>
382+ <field name="company_id" ref="account_consolidation.subsidiary_a"/>
383+ <field name="sequence_id" ref="account.sequence_sale_journal"/>
384+ <field eval="1" name="allow_date"/>
385+ <field name="type">sale</field>
386+ </record>
387
388- <record id="account_journal_sale1" model="account.journal">
389- <field name="code">SALE</field>
390- <field name="name">SALE</field>
391- <field name="view_id" ref="account.account_sp_journal_view"/>
392- <field name="company_id" ref="account_consolidation.subsidiary_b"/>
393- <field name="sequence_id" ref="account.sequence_sale_journal"/>
394- <field eval="1" name="allow_date"/>
395- <field name="type">sale</field>
396- </record>
397+ <record id="account_journal_sale1" model="account.journal">
398+ <field name="code">SALE</field>
399+ <field name="name">SALE</field>
400+ <field name="company_id" ref="account_consolidation.subsidiary_b"/>
401+ <field name="sequence_id" ref="account.sequence_sale_journal"/>
402+ <field eval="1" name="allow_date"/>
403+ <field name="type">sale</field>
404+ </record>
405
406 </data>
407 </openerp>
408
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 raise
414
415 -
416- In order to test the consolidation checks on misconfigured periods, I use the wizard on FY2012
417+ In order to test the consolidation checks on misconfigured periods, I use the wizard on the next year
418+ which is misconfigured
419 -
420 !record {model: account.consolidation.check, id: conso_check_period_1}:
421 fiscalyear_id: account_fiscalyear_fy0
422@@ -79,8 +80,8 @@
423 name: Virtual Account Spare
424 parent_id: account_consolidation.virtual_chart_subsidiary_a
425 type: consolidation
426- user_type: account.account_type_expense
427-
428+ user_type: account.data_account_type_expense
429+
430 -
431 In order to test the consolidation checks on misconfigured charts, I use the wizard
432 -
433
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 -
439 !record {model: account.move, id: account_move_0}:
440 company_id: subsidiary_b
441- date: '2011-01-02'
442+ date: !eval "'%s-01-02' % datetime.now().year"
443 journal_id: account_journal_sale1
444 line_id:
445 - company_id: subsidiary_b
446 account_id: a_sale_b
447 amount_currency: 0.0
448 credit: 0.0
449- date: '2011-01-01'
450+ date: !eval "'%s-01-02' % datetime.now().year"
451 debit: 1240.0
452 journal_id: account_journal_sale1
453 name: Entry 0
454@@ -22,7 +22,7 @@
455 account_id: cog_b
456 amount_currency: 0.0
457 credit: 1240.0
458- date: '2011-01-01'
459+ date: !eval "'%s-01-02' % datetime.now().year"
460 debit: 0.0
461 journal_id: account_journal_sale1
462 name: Entry 0
463@@ -40,14 +40,14 @@
464 -
465 !record {model: account.move, id: account_move_1}:
466 company_id: account_consolidation.subsidiary_a
467- date: '2011-01-20'
468+ date: !eval "'%s-01-20' % datetime.now().year"
469 journal_id: account_journal_sale0
470 line_id:
471 - account_id: account_consolidation.a_sale_a
472 amount_currency: 0.0
473 company_id: account_consolidation.subsidiary_a
474 credit: 0.0
475- date: '2011-01-20'
476+ date: !eval "'%s-01-20' % datetime.now().year"
477 debit: 40.0
478 journal_id: account_journal_sale0
479 name: Entry 1
480@@ -59,7 +59,7 @@
481 amount_currency: 0.0
482 company_id: account_consolidation.subsidiary_a
483 credit: 40.0
484- date: '2011-01-20'
485+ date: !eval "'%s-01-20' % datetime.now().year"
486 debit: 0.0
487 journal_id: account_journal_sale0
488 name: Entry 1
489@@ -77,14 +77,14 @@
490 -
491 !record {model: account.move, id: account_move_2}:
492 company_id: account_consolidation.subsidiary_a
493- date: '2011-02-23'
494+ date: !eval "'%s-02-23' % datetime.now().year"
495 journal_id: account_journal_sale0
496 line_id:
497 - account_id: account_consolidation.a_sale_a
498 amount_currency: 0.0
499 company_id: account_consolidation.subsidiary_a
500 credit: 0.0
501- date: '2011-02-01'
502+ date: !eval "'%s-02-23' % datetime.now().year"
503 debit: 200.0
504 journal_id: account_journal_sale0
505 name: Entry 2
506@@ -96,7 +96,7 @@
507 amount_currency: 0.0
508 company_id: account_consolidation.subsidiary_a
509 credit: 200.0
510- date: '2011-02-01'
511+ date: !eval "'%s-02-23' % datetime.now().year"
512 debit: 0.0
513 journal_id: account_journal_sale0
514 name: Entry 2
515@@ -114,14 +114,14 @@
516 -
517 !record {model: account.move, id: account_move_3}:
518 company_id: account_consolidation.subsidiary_a
519- date: '2011-01-15'
520+ date: !eval "'%s-01-15' % datetime.now().year"
521 journal_id: account_journal_sale0
522 line_id:
523 - account_id: account_consolidation.cog_a
524 amount_currency: 0.0
525 company_id: account_consolidation.subsidiary_a
526 credit: 300.0
527- date: '2011-01-01'
528+ date: !eval "'%s-01-15' % datetime.now().year"
529 debit: 0.0
530 journal_id: account_journal_sale0
531 name: Entry 3
532@@ -133,7 +133,7 @@
533 amount_currency: 0.0
534 company_id: account_consolidation.subsidiary_a
535 credit: 0.0
536- date: '2011-01-01'
537+ date: !eval "'%s-01-15' % datetime.now().year"
538 debit: 300.0
539 journal_id: account_journal_sale0
540 name: Entry 3
541@@ -150,94 +150,94 @@
542 Creating a account.fiscalyear record with a missing period for january
543 -
544 !record {model: account.fiscalyear, id: account_fiscalyear_fy0}:
545- code: FY2012
546+ code: !eval "'FY%s' % (datetime.now().year + 1)"
547 company_id: base.main_company
548- date_start: '2012-01-01'
549- date_stop: '2012-12-31'
550- name: FY2012
551+ date_start: !eval "'%s-01-01' % (datetime.now().year + 1)"
552+ date_stop: !eval "'%s-12-31' % (datetime.now().year + 1)"
553+ name: !eval "'FY%s' % (datetime.now().year + 1)"
554 period_ids:
555- - code: 00/2012
556+ - code: !eval "'00/%s' % (datetime.now().year + 1)"
557 company_id: base.main_company
558- date_start: '2012-01-01'
559- date_stop: '2012-01-01'
560+ date_start: !eval "'%s-01-01' % (datetime.now().year + 1)"
561+ date_stop: !eval "'%s-01-01' % (datetime.now().year + 1)"
562 name: Opening Period
563 special: true
564- - code: 01/2012
565- company_id: base.main_company
566- date_start: '2012-01-01'
567- date_stop: '2012-01-31'
568- name: 01/2012
569- - code: 02/2012
570- company_id: base.main_company
571- date_start: '2012-02-01'
572- date_stop: '2012-02-29'
573- name: 02/2012
574- - code: 03/2012
575- company_id: base.main_company
576- date_start: '2012-03-01'
577- date_stop: '2012-03-31'
578- name: 03/2012
579- - code: 04/2012
580- company_id: base.main_company
581- date_start: '2012-04-01'
582- date_stop: '2012-04-30'
583- name: 04/2012
584- - code: 05/2012
585- company_id: base.main_company
586- date_start: '2012-05-01'
587- date_stop: '2012-05-31'
588- name: 05/2012
589- - code: 06/2012
590- company_id: base.main_company
591- date_start: '2012-06-01'
592- date_stop: '2012-06-30'
593- name: 06/2012
594- - code: 07/2012
595- company_id: base.main_company
596- date_start: '2012-07-01'
597- date_stop: '2012-07-31'
598- name: 07/2012
599- - code: 08/2012
600- company_id: base.main_company
601- date_start: '2012-08-01'
602- date_stop: '2012-08-31'
603- name: 08/2012
604- - code: 09/2012
605- company_id: base.main_company
606- date_start: '2012-09-01'
607- date_stop: '2012-09-30'
608- name: 09/2012
609- - code: 10/2012
610- company_id: base.main_company
611- date_start: '2012-10-01'
612- date_stop: '2012-10-31'
613- name: 10/2012
614- - code: 11/2012
615- company_id: base.main_company
616- date_start: '2012-11-01'
617- date_stop: '2012-11-30'
618- name: 11/2012
619- - code: 12/2012
620- company_id: base.main_company
621- date_start: '2012-12-01'
622- date_stop: '2012-12-31'
623- name: 12/2012
624+ - code: !eval "'01/%s' % (datetime.now().year + 1)"
625+ company_id: base.main_company
626+ date_start: !eval "'%s-01-01' % (datetime.now().year + 1)"
627+ date_stop: !eval "'%s-01-31' % (datetime.now().year + 1)"
628+ name: !eval "'01/%s' % (datetime.now().year + 1)"
629+ - code: !eval "'02/%s' % (datetime.now().year + 1)"
630+ company_id: base.main_company
631+ date_start: !eval "'%s-02-01' % (datetime.now().year + 1)"
632+ date_stop: !eval "'%s-02-%s' % ((datetime.now().year + 1), (datetime((datetime.now().year + 1), 3, 1) - timedelta(days=1)).day)"
633+ name: !eval "'02/%s' % (datetime.now().year + 1)"
634+ - code: !eval "'03/%s' % (datetime.now().year + 1)"
635+ company_id: base.main_company
636+ date_start: !eval "'%s-03-01' % (datetime.now().year + 1)"
637+ date_stop: !eval "'%s-03-31' % (datetime.now().year + 1)"
638+ name: !eval "'03/%s' % (datetime.now().year + 1)"
639+ - code: !eval "'04/%s' % (datetime.now().year + 1)"
640+ company_id: base.main_company
641+ date_start: !eval "'%s-04-01' % (datetime.now().year + 1)"
642+ date_stop: !eval "'%s-04-30' % (datetime.now().year + 1)"
643+ name: !eval "'04/%s' % (datetime.now().year + 1)"
644+ - code: !eval "'05/%s' % (datetime.now().year + 1)"
645+ company_id: base.main_company
646+ date_start: !eval "'%s-05-01' % (datetime.now().year + 1)"
647+ date_stop: !eval "'%s-05-31' % (datetime.now().year + 1)"
648+ name: !eval "'05/%s' % (datetime.now().year + 1)"
649+ - code: !eval "'06/%s' % (datetime.now().year + 1)"
650+ company_id: base.main_company
651+ date_start: !eval "'%s-06-01' % (datetime.now().year + 1)"
652+ date_stop: !eval "'%s-06-30' % (datetime.now().year + 1)"
653+ name: !eval "'06/%s' % (datetime.now().year + 1)"
654+ - code: !eval "'07/%s' % (datetime.now().year + 1)"
655+ company_id: base.main_company
656+ date_start: !eval "'%s-07-01' % (datetime.now().year + 1)"
657+ date_stop: !eval "'%s-07-31' % (datetime.now().year + 1)"
658+ name: !eval "'07/%s' % (datetime.now().year + 1)"
659+ - code: !eval "'08/%s' % (datetime.now().year + 1)"
660+ company_id: base.main_company
661+ date_start: !eval "'%s-08-01' % (datetime.now().year + 1)"
662+ date_stop: !eval "'%s-08-31' % (datetime.now().year + 1)"
663+ name: !eval "'08/%s' % (datetime.now().year + 1)"
664+ - code: !eval "'09/%s' % (datetime.now().year + 1)"
665+ company_id: base.main_company
666+ date_start: !eval "'%s-09-01' % (datetime.now().year + 1)"
667+ date_stop: !eval "'%s-09-30' % (datetime.now().year + 1)"
668+ name: !eval "'09/%s' % (datetime.now().year + 1)"
669+ - code: !eval "'10/%s' % (datetime.now().year + 1)"
670+ company_id: base.main_company
671+ date_start: !eval "'%s-10-01' % (datetime.now().year + 1)"
672+ date_stop: !eval "'%s-10-31' % (datetime.now().year + 1)"
673+ name: !eval "'10/%s' % (datetime.now().year + 1)"
674+ - code: !eval "'11/%s' % (datetime.now().year + 1)"
675+ company_id: base.main_company
676+ date_start: !eval "'%s-11-01' % (datetime.now().year + 1)"
677+ date_stop: !eval "'%s-11-30' % (datetime.now().year + 1)"
678+ name: !eval "'11/%s' % (datetime.now().year + 1)"
679+ - code: !eval "'12/%s' % (datetime.now().year + 1)"
680+ company_id: base.main_company
681+ date_start: !eval "'%s-12-01' % (datetime.now().year + 1)"
682+ date_stop: !eval "'%s-12-31' % (datetime.now().year + 1)"
683+ name: !eval "'12/%s' % (datetime.now().year + 1)"
684
685
686 -
687 Creating a account.fiscalyear record with a period in december but with different dates than the holding
688 -
689 !record {model: account.fiscalyear, id: account_fiscalyear_fy1}:
690- code: FY2012
691+ code: !eval "'FY%s' % (datetime.now().year + 1)"
692 company_id: account_consolidation.subsidiary_b
693- date_start: '2012-01-01'
694- date_stop: '2012-12-31'
695- name: FY2012
696+ date_start: !eval "'%s-01-01' % (datetime.now().year + 1)"
697+ date_stop: !eval "'%s-12-31' % (datetime.now().year + 1)"
698+ name: !eval "'FY%s' % (datetime.now().year + 1)"
699 period_ids:
700 - code: diff_dates
701 company_id: account_consolidation.subsidiary_b
702- date_start: '2012-12-15'
703- date_stop: '2012-12-31'
704+ date_start: !eval "'%s-12-15' % (datetime.now().year + 1)"
705+ date_stop: !eval "'%s-12-31' % (datetime.now().year + 1)"
706 name: diff_dates
707
708
709@@ -245,70 +245,70 @@
710 Creating a account.fiscalyear record on subsidiary with a period for january (missing on holding)
711 -
712 !record {model: account.fiscalyear, id: account_fiscalyear_fy2}:
713- code: FY2012
714+ code: !eval "'FY%s' % (datetime.now().year + 1)"
715 company_id: account_consolidation.subsidiary_a
716- date_start: '2012-01-01'
717- date_stop: '2012-12-31'
718- name: FY2012
719+ date_start: !eval "'%s-01-01' % (datetime.now().year + 1)"
720+ date_stop: !eval "'%s-12-31' % (datetime.now().year + 1)"
721+ name: !eval "'FY%s' % (datetime.now().year + 1)"
722 period_ids:
723- - code: 00/2012
724+ - code: !eval "'00/%s' % (datetime.now().year + 1)"
725 company_id: account_consolidation.subsidiary_a
726- date_start: '2012-01-01'
727- date_stop: '2012-01-01'
728+ date_start: !eval "'%s-01-01' % (datetime.now().year + 1)"
729+ date_stop: !eval "'%s-01-01' % (datetime.now().year + 1)"
730 name: Opening Period
731 special: true
732- - code: 01/2012
733- company_id: account_consolidation.subsidiary_a
734- date_start: '2012-01-01'
735- date_stop: '2012-01-31'
736- name: 01/2012
737- - code: 02/2012
738- company_id: account_consolidation.subsidiary_a
739- date_start: '2012-02-01'
740- date_stop: '2012-02-29'
741- name: 02/2012
742- - code: 03/2012
743- company_id: account_consolidation.subsidiary_a
744- date_start: '2012-03-01'
745- date_stop: '2012-03-31'
746- name: 03/2012
747- - code: 04/2012
748- company_id: account_consolidation.subsidiary_a
749- date_start: '2012-04-01'
750- date_stop: '2012-04-30'
751- name: 04/2012
752- - code: 05/2012
753- company_id: account_consolidation.subsidiary_a
754- date_start: '2012-05-01'
755- date_stop: '2012-05-31'
756- name: 05/2012
757- - code: 06/2012
758- company_id: account_consolidation.subsidiary_a
759- date_start: '2012-06-01'
760- date_stop: '2012-06-30'
761- name: 06/2012
762- - code: 08/2012
763- company_id: account_consolidation.subsidiary_a
764- date_start: '2012-08-01'
765- date_stop: '2012-08-31'
766- name: 08/2012
767- - code: 09/2012
768- company_id: account_consolidation.subsidiary_a
769- date_start: '2012-09-01'
770- date_stop: '2012-09-30'
771- name: 09/2012
772- - code: 10/2012
773- company_id: account_consolidation.subsidiary_a
774- date_start: '2012-10-01'
775- date_stop: '2012-10-31'
776- name: 10/2012
777- - code: 11/2012
778- company_id: account_consolidation.subsidiary_a
779- date_start: '2012-11-01'
780- date_stop: '2012-11-30'
781- name: 11/2012
782- - code: 12/2012
783- company_id: account_consolidation.subsidiary_a
784- date_start: '2012-12-01'
785- date_stop: '2012-12-31'
786- name: 12/2012
787+ - code: !eval "'01/%s' % (datetime.now().year + 1)"
788+ company_id: account_consolidation.subsidiary_a
789+ date_start: !eval "'%s-01-01' % (datetime.now().year + 1)"
790+ date_stop: !eval "'%s-01-31' % (datetime.now().year + 1)"
791+ name: !eval "'01/%s' % (datetime.now().year + 1)"
792+ - code: !eval "'02/%s' % (datetime.now().year + 1)"
793+ company_id: account_consolidation.subsidiary_a
794+ date_start: !eval "'%s-02-01' % (datetime.now().year + 1)"
795+ date_stop: !eval "'%s-02-%s' % ((datetime.now().year + 1), (datetime((datetime.now().year + 1), 3, 1) - timedelta(days=1)).day)"
796+ name: !eval "'02/%s' % (datetime.now().year + 1)"
797+ - code: !eval "'03/%s' % (datetime.now().year + 1)"
798+ company_id: account_consolidation.subsidiary_a
799+ date_start: !eval "'%s-03-01' % (datetime.now().year + 1)"
800+ date_stop: !eval "'%s-03-31' % (datetime.now().year + 1)"
801+ name: !eval "'03/%s' % (datetime.now().year + 1)"
802+ - code: !eval "'04/%s' % (datetime.now().year + 1)"
803+ company_id: account_consolidation.subsidiary_a
804+ date_start: !eval "'%s-04-01' % (datetime.now().year + 1)"
805+ date_stop: !eval "'%s-04-30' % (datetime.now().year + 1)"
806+ name: !eval "'04/%s' % (datetime.now().year + 1)"
807+ - code: !eval "'05/%s' % (datetime.now().year + 1)"
808+ company_id: account_consolidation.subsidiary_a
809+ date_start: !eval "'%s-05-01' % (datetime.now().year + 1)"
810+ date_stop: !eval "'%s-05-31' % (datetime.now().year + 1)"
811+ name: !eval "'05/%s' % (datetime.now().year + 1)"
812+ - code: !eval "'06/%s' % (datetime.now().year + 1)"
813+ company_id: account_consolidation.subsidiary_a
814+ date_start: !eval "'%s-06-01' % (datetime.now().year + 1)"
815+ date_stop: !eval "'%s-06-30' % (datetime.now().year + 1)"
816+ name: !eval "'06/%s' % (datetime.now().year + 1)"
817+ - code: !eval "'08/%s' % (datetime.now().year + 1)"
818+ company_id: account_consolidation.subsidiary_a
819+ date_start: !eval "'%s-08-01' % (datetime.now().year + 1)"
820+ date_stop: !eval "'%s-08-31' % (datetime.now().year + 1)"
821+ name: !eval "'08/%s' % (datetime.now().year + 1)"
822+ - code: !eval "'09/%s' % (datetime.now().year + 1)"
823+ company_id: account_consolidation.subsidiary_a
824+ date_start: !eval "'%s-09-01' % (datetime.now().year + 1)"
825+ date_stop: !eval "'%s-09-30' % (datetime.now().year + 1)"
826+ name: !eval "'09/%s' % (datetime.now().year + 1)"
827+ - code: !eval "'10/%s' % (datetime.now().year + 1)"
828+ company_id: account_consolidation.subsidiary_a
829+ date_start: !eval "'%s-10-01' % (datetime.now().year + 1)"
830+ date_stop: !eval "'%s-10-31' % (datetime.now().year + 1)"
831+ name: !eval "'10/%s' % (datetime.now().year + 1)"
832+ - code: !eval "'11/%s' % (datetime.now().year + 1)"
833+ company_id: account_consolidation.subsidiary_a
834+ date_start: !eval "'%s-11-01' % (datetime.now().year + 1)"
835+ date_stop: !eval "'%s-11-30' % (datetime.now().year + 1)"
836+ name: !eval "'11/%s' % (datetime.now().year + 1)"
837+ - code: !eval "'12/%s' % (datetime.now().year + 1)"
838+ company_id: account_consolidation.subsidiary_a
839+ date_start: !eval "'%s-12-01' % (datetime.now().year + 1)"
840+ date_stop: !eval "'%s-12-31' % (datetime.now().year + 1)"
841+ name: !eval "'12/%s' % (datetime.now().year + 1)"
842
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 # -*- coding: utf-8 -*-
848 ##############################################################################
849 #
850-# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)
851-#
852-# Author : Guewen Baconnier (Camptocamp)
853-#
854-# WARNING: This program as such is intended to be used by professional
855-# programmers who take the whole responsability of assessing all potential
856-# consequences resulting from its eventual inadequacies and bugs
857-# End users who are looking for a ready-to-use solution with commercial
858-# garantees and support are strongly adviced to contract a Free Software
859-# Service Company
860-#
861-# This program is Free Software; you can redistribute it and/or
862-# modify it under the terms of the GNU General Public License
863-# as published by the Free Software Foundation; either version 2
864-# of the License, or (at your option) any later version.
865-#
866-# This program is distributed in the hope that it will be useful,
867-# but WITHOUT ANY WARRANTY; without even the implied warranty of
868-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
869-# GNU General Public License for more details.
870-#
871-# You should have received a copy of the GNU General Public License
872-# along with this program; if not, write to the Free Software
873-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
874+# Author: Guewen Baconnier
875+# Copyright 2011-2013 Camptocamp SA
876+#
877+# This program is free software: you can redistribute it and/or modify
878+# it under the terms of the GNU Affero General Public License as
879+# published by the Free Software Foundation, either version 3 of the
880+# License, or (at your option) any later version.
881+#
882+# This program is distributed in the hope that it will be useful,
883+# but WITHOUT ANY WARRANTY; without even the implied warranty of
884+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
885+# GNU Affero General Public License for more details.
886+#
887+# You should have received a copy of the GNU Affero General Public License
888+# along with this program. If not, see <http://www.gnu.org/licenses/>.
889 #
890 ##############################################################################
891
892-from osv import osv, fields
893-from tools.translate import _
894-
895-
896-class account_consolidation_base(osv.osv_memory):
897+from openerp.osv import osv, orm, fields
898+from openerp.tools.translate import _
899+
900+
901+class account_consolidation_base(orm.AbstractModel):
902 _name = 'account.consolidation.base'
903 _description = 'Common consolidation wizard. Intended to be inherited'
904
905@@ -40,18 +31,30 @@
906 user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
907 if user.company_id:
908 return user.company_id.id
909- return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
910+ return self.pool.get('res.company').search(
911+ cr, uid, [('parent_id', '=', False)])[0]
912
913 _columns = {
914- 'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True,
915- help="The checks will be done on the periods of the selected fiscal year."),
916- 'company_id': fields.many2one('res.company', 'Company', required=True),
917- 'holding_chart_account_id': fields.many2one('account.account',
918- 'Chart of Accounts',
919- required=True,
920- domain=[('parent_id', '=', False)]),
921- 'subsidiary_ids': fields.many2many('res.company', 'account_conso_comp_rel', 'conso_id', 'company_id',
922- 'Subsidiaries', required=True)
923+ 'fiscalyear_id': fields.many2one(
924+ 'account.fiscalyear',
925+ 'Fiscal Year',
926+ required=True,
927+ help="The checks will be done on the periods of "
928+ "the selected fiscal year."),
929+ 'company_id': fields.many2one(
930+ 'res.company', 'Company', required=True),
931+ 'holding_chart_account_id': fields.many2one(
932+ 'account.account',
933+ 'Chart of Accounts',
934+ required=True,
935+ domain=[('parent_id', '=', False)]),
936+ 'subsidiary_ids': fields.many2many(
937+ 'res.company',
938+ 'account_conso_comp_rel',
939+ 'conso_id',
940+ 'company_id',
941+ 'Subsidiaries',
942+ required=True)
943 }
944
945 _defaults = {
946@@ -62,14 +65,9 @@
947 """
948 On change of the company, set the chart of account and the subsidiaries
949
950- @param self: The object pointer
951- @param cr: the current row, from the database cursor,
952- @param uid: the current user’s ID for security checks,
953- @param ids: List of the wizard IDs (commonly the first element is the current ID)
954- @param company_id: ID of the selected company
955- @param context: A standard dictionary for contextual values
956+ :param company_id: ID of the selected company
957
958- @return: dict of values to change
959+ :return: dict of values to change
960 """
961 company_obj = self.pool.get('res.company')
962
963@@ -82,21 +80,27 @@
964
965 return {'value': result}
966
967- def check_subsidiary_periods(self, cr, uid, ids, holding_company_id, subs_company_id, fyear_id, context=None):
968- """
969- Check Subsidiary company periods vs Holding company periods and returns a list of errors
970- All the periods defined within the group must be the same (same beginning and ending dates)
971-
972- @param self: The object pointer
973- @param cr: the current row, from the database cursor,
974- @param uid: the current user’s ID for security checks,
975- @param ids: List of the wizard IDs (commonly the first element is the current ID)
976- @param holding_company_id: ID of the holding company
977- @param subs_company_id: ID of the subsidiary company to check
978- @param fyear_id: ID of the fiscal years to compare
979- @param context: A standard dictionary for contextual values
980-
981- @return: dict of list with errors for each company {company_id: ['error 1', 'error2']}
982+ def check_subsidiary_periods(self, cr, uid, ids, holding_company_id,
983+ subs_company_id, fyear_id, context=None):
984+ """ Check Subsidiary company periods vs Holding company periods and
985+ returns a list of errors
986+
987+ The periods checked are the periods within the fiscal year of the
988+ holding, and the periods of the subsidiary company in the same range of
989+ time.
990+
991+ The fiscal year of the subsidiary is deduced from the start/stop date
992+ of the holding's fiscal year.
993+
994+ All the periods defined within the group must have the same beginning
995+ and ending dates to be valid.
996+
997+ :param holding_company_id: ID of the holding company
998+ :param subs_company_id: ID of the subsidiary company to check
999+ :param fyear_id: ID of the fiscal year of the holding.
1000+
1001+ :return: dict of list with errors for each company
1002+ {company_id: ['error 1', 'error2']}
1003 """
1004 company_obj = self.pool.get('res.company')
1005 period_obj = self.pool.get('account.period')
1006@@ -108,48 +112,69 @@
1007 errors = []
1008
1009 # get holding fiscal year and periods
1010- holding = company_obj.browse(cr, uid, holding_company_id, context=context)
1011- subsidiary = company_obj.browse(cr, uid, subs_company_id, context=context)
1012+ holding = company_obj.browse(
1013+ cr, uid, holding_company_id, context=context)
1014+ subsidiary = company_obj.browse(
1015+ cr, uid, subs_company_id, context=context)
1016
1017- holding_periods_ids = period_obj.search(cr, uid,
1018+ holding_periods_ids = period_obj.search(
1019+ cr, uid,
1020 [('company_id', '=', holding.id),
1021 ('fiscalyear_id', '=', holding_fiscal_year.id)],
1022 context=context)
1023- holding_periods = period_obj.browse(cr, uid, holding_periods_ids, context=context)
1024+ holding_periods = period_obj.browse(
1025+ cr, uid, holding_periods_ids, context=context)
1026
1027 # get subsidiary fiscal year and periods
1028- subsidiary_fiscal_year = fy_obj.search(cr, uid,
1029+ subsidiary_fiscal_year = fy_obj.search(
1030+ cr, uid,
1031 [('company_id', '=', subsidiary.id),
1032 ('date_start', '=', holding_fiscal_year.date_start),
1033 ('date_stop', '=', holding_fiscal_year.date_stop),
1034- ])
1035+ ],
1036+ context=context)
1037 if not subsidiary_fiscal_year:
1038- errors.append(_('The fiscal year of the subsidiary company %s does not exists from %s to %s')
1039- % (subsidiary.name, holding_fiscal_year.date_start, holding_fiscal_year.date_stop))
1040+ errors.append(
1041+ _('The fiscal year of the subsidiary company %s '
1042+ 'does not exists from %s to %s') %
1043+ (subsidiary.name,
1044+ holding_fiscal_year.date_start,
1045+ holding_fiscal_year.date_stop))
1046 else:
1047- subsidiary_period_ids = period_obj.search(cr, uid,
1048+ subsidiary_period_ids = period_obj.search(
1049+ cr, uid,
1050 [('company_id', '=', subsidiary.id),
1051- ('fiscalyear_id', '=', subsidiary_fiscal_year[0])], # 0 because there can be only 1 fiscal year on the same dates as the holding
1052+ # 0 because there can be only 1 fiscal year
1053+ # on the same dates than the holding
1054+ ('fiscalyear_id', '=', subsidiary_fiscal_year[0])],
1055 context=context)
1056- subsidiary_periods = period_obj.browse(cr, uid, subsidiary_period_ids, context=context)
1057+ subsidiary_periods = period_obj.browse(
1058+ cr, uid, subsidiary_period_ids, context=context)
1059
1060- # a holding fiscal year may have more periods than a subsidiary (a subsidiary created at the middle of the year for example)
1061+ # a holding fiscal year may have more periods than a subsidiary
1062+ # (a subsidiary created at the middle of the year for example)
1063 # but the reverse situation is not allowed
1064 if len(holding_periods) < len(subsidiary_periods):
1065- errors.append(_('Holding company has less periods than the subsidiary company %s!') % (subsidiary.name,))
1066+ errors.append(
1067+ _('Holding company has less periods than the '
1068+ 'subsidiary company %s!') % subsidiary.name)
1069
1070- # check subsidiary periods dates vs holding periods for each period of the subsidiary
1071+ # check subsidiary periods dates vs holding periods
1072+ # for each period of the subsidiary
1073 for subsidiary_period in subsidiary_periods:
1074 period_exists = False
1075 for holding_period in holding_periods:
1076- if subsidiary_period.date_start == holding_period.date_start \
1077- and subsidiary_period.date_stop == holding_period.date_stop:
1078- period_exists = True
1079- break
1080+ if (subsidiary_period.date_start == holding_period.date_start and
1081+ subsidiary_period.date_stop == holding_period.date_stop):
1082+ period_exists = True
1083+ break
1084 if not period_exists:
1085- errors.append(_('Period from %s to %s not found in holding company %s')
1086- % (subsidiary_period.date_start, subsidiary_period.date_stop, holding.name))
1087-
1088+ errors.append(
1089+ _('Period from %s to %s not found '
1090+ 'in holding company %s') %
1091+ (subsidiary_period.date_start,
1092+ subsidiary_period.date_stop,
1093+ holding.name))
1094 return errors
1095
1096 def check_all_periods(self, cr, uid, ids, context=None):
1097@@ -157,24 +182,24 @@
1098 Call the period check on each period of all subsidiaries
1099 Returns the errors by subsidiary
1100
1101- @param self: The object pointer
1102- @param cr: the current row, from the database cursor,
1103- @param uid: the current user’s ID for security checks,
1104- @param ids: List of the wizard IDs (commonly the first element is the current ID)
1105- @param context: A standard dictionary for contextual values
1106-
1107- @return: dict of list with errors for each company {company_id: ['error 1', 'error2']}
1108+ :return: dict of list with errors for each company
1109+ {company_id: ['error 1', 'error2']}
1110 """
1111+ if isinstance(ids, (int, long)):
1112+ ids = [ids]
1113+ assert len(ids) == 1, "only 1 id expected"
1114+
1115 form = self.browse(cr, uid, ids[0], context=context)
1116
1117 errors_by_company = {}
1118 for subsidiary in form.subsidiary_ids:
1119- errors = \
1120- self.check_subsidiary_periods(cr, uid, ids,
1121- form.company_id.id,
1122- subsidiary.id,
1123- form.fiscalyear_id.id,
1124- context=context)
1125+ errors = self.check_subsidiary_periods(
1126+ cr, uid,
1127+ ids,
1128+ form.company_id.id,
1129+ subsidiary.id,
1130+ form.fiscalyear_id.id,
1131+ context=context)
1132 if errors:
1133 errors_by_company[subsidiary.id] = errors
1134
1135@@ -182,24 +207,23 @@
1136
1137 def _chart_accounts_data(self, cr, uid, ids, chart_account_id, context=None):
1138 """
1139- Returns the list of accounts to use for the consolidation for the holding
1140- or the subsidiaries. Keys of the returned dict are the account codes and
1141- if the context is holding_coa, dict values are the browse instances of the accounts
1142-
1143- @param self: The object pointer
1144- @param cr: the current row, from the database cursor,
1145- @param uid: the current user’s ID for security checks,
1146- @param ids: List of the wizard IDs (commonly the first element is the current ID)
1147- @chart_account_id: ID of the "Chart" Account for which we want the account codes
1148- @param context: A standard dictionary for contextual values
1149-
1150- @return: dict with {account codes: browse instances}
1151+ Returns the list of accounts to use for the consolidation
1152+ for the holding or the subsidiaries.
1153+ Keys of the returned dict are the account codes and
1154+ if the context is holding_coa,
1155+ dict values are the browse instances of the accounts
1156+
1157+ :chart_account_id: ID of the Chart of Account for which
1158+ we want the account codes
1159+
1160+ :return: dict with {account codes: browse instances}
1161 """
1162- context = context or {}
1163+ if context is None:
1164+ context = {}
1165 account_obj = self.pool.get('account.account')
1166 res = {}
1167- account_ids = account_obj.\
1168- _get_children_and_consol(cr, uid, chart_account_id, context=context)
1169+ account_ids = account_obj._get_children_and_consol(
1170+ cr, uid, chart_account_id, context=context)
1171
1172 # do not consolidate chart root
1173 account_ids.remove(chart_account_id)
1174@@ -216,33 +240,37 @@
1175 continue
1176
1177 res[account.code] = {}
1178- # we'll need the browse object during the "consolidate wizard" for the holding
1179- res[account.code] = holding and account or True
1180+ # we'll need the browse object during the
1181+ # "consolidate wizard" for the holding
1182+ res[account.code] = account if holding else True
1183
1184 return res
1185
1186- def check_subsidiary_chart(self, cr, uid, ids, holding_chart_account_id, subsidiary_chart_account_id, context=None):
1187+ def check_subsidiary_chart(self, cr, uid, ids, holding_chart_account_id,
1188+ subsidiary_chart_account_id, context=None):
1189 """
1190- Check a Holding Chart of Accounts vs a Subsidiary Virtual Chart of Accounts
1191+ Check a Holding Chart of Accounts vs a Subsidiary Virtual
1192+ Chart of Accounts
1193 All the accounts of the Virtual CoA must exist in the Holding CoA.
1194- The Holding's CoA may hold accounts which do not exist in the Subsidiary's Virtual CoA.
1195-
1196- @param self: The object pointer
1197- @param cr: the current row, from the database cursor,
1198- @param uid: the current user’s ID for security checks,
1199- @param ids: List of the wizard IDs (commonly the first element is the current ID)
1200- @param holding_chart_account_id: ID of the "Chart" Account of the holding company
1201- @param subsidiary_chart_account_id: ID of the "Chart" Account of the subsidiary company to check
1202- @param context: A standard dictionary for contextual values
1203-
1204- @return: List of accounts existing on subsidiary but no on holding COA
1205+ The Holding's CoA may hold accounts which do not exist
1206+ in the Subsidiary's Virtual CoA.
1207+
1208+ :param holding_chart_account_id: ID of the Chart of Account
1209+ of the holding company
1210+ :param subsidiary_chart_account_id: ID of the Chart of Account
1211+ of the subsidiary company to check
1212+
1213+ :return: List of accounts existing on subsidiary but no on holding COA
1214 """
1215- context = context or {}
1216- holding_ctx = context.copy()
1217- holding_ctx.update({'holding_coa': True})
1218- holding_accounts = self._chart_accounts_data(cr, uid, ids, holding_chart_account_id, context=holding_ctx)
1219- subsidiary_accounts = self._chart_accounts_data(cr, uid, ids, subsidiary_chart_account_id, context=context)
1220- # accounts which are configured on the subsidiary VCoA but not on the holding CoA
1221+ if context is None:
1222+ context = {}
1223+ holding_ctx = dict(context, holding_coa=True)
1224+ holding_accounts = self._chart_accounts_data(
1225+ cr, uid, ids, holding_chart_account_id, context=holding_ctx)
1226+ subsidiary_accounts = self._chart_accounts_data(
1227+ cr, uid, ids, subsidiary_chart_account_id, context=context)
1228+ # accounts which are configured on the subsidiary
1229+ # Virtual CoA but not on the holding CoA
1230 spare_accounts = [code for code
1231 in subsidiary_accounts
1232 if code not in holding_accounts]
1233@@ -250,26 +278,27 @@
1234
1235 def check_account_charts(self, cr, uid, ids, context=None):
1236 """
1237- Check the chart of accounts of the holding vs each virtual chart of accounts of the subsidiaries
1238-
1239- @param self: The object pointer
1240- @param cr: the current row, from the database cursor,
1241- @param uid: the current user’s ID for security checks,
1242- @param ids: List of the wizard IDs (commonly the first element is the current ID)
1243- @param context: A standard dictionary for contextual values
1244+ Check the chart of accounts of the holding vs
1245+ each virtual chart of accounts of the subsidiaries
1246 """
1247+ if isinstance(ids, (int, long)):
1248+ ids = [ids]
1249+ assert len(ids) == 1, "only 1 id expected"
1250 form = self.browse(cr, uid, ids[0], context=context)
1251
1252 invalid_items_per_company = {}
1253 for subsidiary in form.subsidiary_ids:
1254 if not subsidiary.consolidation_chart_account_id:
1255- raise osv.except_osv(_('Error'), _('No chart of accounts for company %s') % (subsidiary,))
1256+ raise osv.except_osv(
1257+ _('Error'),
1258+ _('No chart of accounts for company %s') % subsidiary)
1259
1260- invalid_items = \
1261- self.check_subsidiary_chart(cr, uid, ids,
1262- form.holding_chart_account_id.id,
1263- subsidiary.consolidation_chart_account_id.id,
1264- context=context)
1265+ invalid_items = self.check_subsidiary_chart(
1266+ cr, uid,
1267+ ids,
1268+ form.holding_chart_account_id.id,
1269+ subsidiary.consolidation_chart_account_id.id,
1270+ context=context)
1271 if any(invalid_items):
1272 invalid_items_per_company[subsidiary.id] = invalid_items
1273
1274@@ -278,25 +307,24 @@
1275 def run_consolidation(self, cr, uid, ids, context=None):
1276 """
1277 Proceed with all checks before launch any consolidation step
1278- This is a base method intended to be inherited with the next consolidation steps
1279-
1280- @param self: The object pointer
1281- @param cr: the current row, from the database cursor,
1282- @param uid: the current user’s ID for security checks,
1283- @param ids: List of the wizard IDs (commonly the first element is the current ID)
1284- @param context: A standard dictionary for contextual values
1285+ This is a base method intended to be inherited with the next
1286+ consolidation steps
1287 """
1288+ if isinstance(ids, (int, long)):
1289+ ids = [ids]
1290+ assert len(ids) == 1, "only 1 id expected"
1291
1292 if self.check_all_periods(cr, uid, ids, context=context):
1293- raise osv.except_osv(_('Error'),
1294- _('Invalid periods, please launch the "Consolidation: Checks" wizard'))
1295+ raise osv.except_osv(
1296+ _('Error'),
1297+ _('Invalid periods, please launch the '
1298+ '"Consolidation: Checks" wizard'))
1299 if self.check_account_charts(cr, uid, ids, context=context):
1300- raise osv.except_osv(_('Error'),
1301- _('Invalid charts, please launch the "Consolidation: Checks" wizard'))
1302+ raise osv.except_osv(
1303+ _('Error'),
1304+ _('Invalid charts, please launch the '
1305+ '"Consolidation: Checks" wizard'))
1306
1307 # inherit to add the next steps of the reconciliation
1308
1309 return {'type': 'ir.actions.act_window_close'}
1310-
1311-
1312-account_consolidation_base()
1313
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 # -*- coding: utf-8 -*-
1319 ##############################################################################
1320 #
1321-# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)
1322-#
1323-# Author : Guewen Baconnier (Camptocamp)
1324-#
1325-# WARNING: This program as such is intended to be used by professional
1326-# programmers who take the whole responsability of assessing all potential
1327-# consequences resulting from its eventual inadequacies and bugs
1328-# End users who are looking for a ready-to-use solution with commercial
1329-# garantees and support are strongly adviced to contract a Free Software
1330-# Service Company
1331-#
1332-# This program is Free Software; you can redistribute it and/or
1333-# modify it under the terms of the GNU General Public License
1334-# as published by the Free Software Foundation; either version 2
1335-# of the License, or (at your option) any later version.
1336-#
1337-# This program is distributed in the hope that it will be useful,
1338-# but WITHOUT ANY WARRANTY; without even the implied warranty of
1339-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1340-# GNU General Public License for more details.
1341-#
1342-# You should have received a copy of the GNU General Public License
1343-# along with this program; if not, write to the Free Software
1344-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1345+# Author: Guewen Baconnier
1346+# Copyright 2011-2013 Camptocamp SA
1347+#
1348+# This program is free software: you can redistribute it and/or modify
1349+# it under the terms of the GNU Affero General Public License as
1350+# published by the Free Software Foundation, either version 3 of the
1351+# License, or (at your option) any later version.
1352+#
1353+# This program is distributed in the hope that it will be useful,
1354+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1355+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1356+# GNU Affero General Public License for more details.
1357+#
1358+# You should have received a copy of the GNU Affero General Public License
1359+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1360 #
1361 ##############################################################################
1362
1363-from osv import osv, fields
1364-
1365-from tools.translate import _
1366-
1367-
1368-class account_consolidation_check(osv.osv_memory):
1369+from openerp.osv import osv, orm, fields
1370+from openerp.tools.translate import _
1371+
1372+
1373+class account_consolidation_check(orm.TransientModel):
1374 _name = 'account.consolidation.check'
1375 _inherit = 'account.consolidation.base'
1376 _description = 'Consolidation Checks. Model used for views'
1377
1378 _columns = {
1379- 'subsidiary_ids': fields.many2many('res.company', 'account_conso_check_comp_rel', 'conso_id', 'company_id',
1380- 'Subsidiaries', required=True),
1381+ 'subsidiary_ids': fields.many2many(
1382+ 'res.company',
1383+ 'account_conso_check_comp_rel',
1384+ 'conso_id',
1385+ 'company_id',
1386+ 'Subsidiaries',
1387+ required=True),
1388 }
1389
1390 def check_account_charts(self, cr, uid, ids, context=None):
1391 """
1392 Action launched with the button on the view.
1393 Check the account charts and display a report of the errors
1394-
1395- @param self: The object pointer
1396- @param cr: the current row, from the database cursor,
1397- @param uid: the current user’s ID for security checks,
1398- @param ids: List of the wizard IDs (commonly the first element is the current ID)
1399- @param context: A standard dictionary for contextual values
1400 """
1401- invalid_items_per_company = \
1402- super(account_consolidation_check, self).check_account_charts(cr, uid, ids, context=context)
1403- if invalid_items_per_company:
1404- err_lines = []
1405- for company_id, account_codes in invalid_items_per_company.iteritems():
1406- company_obj = self.pool.get('res.company')
1407- company = company_obj.browse(cr, uid, company_id, context=context)
1408- err_lines.append(_("%s :") % (company.name,))
1409- [err_lines.append(_("Account with code %s does not exist on the Holding company.") % (account_code,))
1410- for account_code
1411- in account_codes]
1412- err_lines.append('')
1413-
1414- raise osv.except_osv(_('Invalid charts'),
1415- '\n'.join(err_lines))
1416-
1417- else:
1418- raise osv.except_osv(_('Validation'), _('Chart of Accounts are OK.'))
1419- # open a confirmation view ?
1420- return True
1421+ company_obj = self.pool.get('res.company')
1422+ invalid_items_per_company = super(account_consolidation_check, self).\
1423+ check_account_charts(cr, uid, ids, context=context)
1424+
1425+ if not invalid_items_per_company:
1426+ raise osv.except_osv(
1427+ _('Validation'),
1428+ _('Chart of Accounts are OK.'))
1429+
1430+ err_lines = []
1431+ for company_id, account_codes in invalid_items_per_company.iteritems():
1432+ company = company_obj.browse(
1433+ cr, uid, company_id, context=context)
1434+ err_lines.append(_("%s :") % company.name)
1435+ for account_code in account_codes:
1436+ err_lines.append(
1437+ _("Account with code %s does not exist on the "
1438+ "Holding company.") % account_code)
1439+ err_lines.append('')
1440+
1441+ raise osv.except_osv(
1442+ _('Invalid charts'), '\n'.join(err_lines))
1443
1444 def check_all_periods(self, cr, uid, ids, context=None):
1445 """
1446 Action launched with the button on the view.
1447 Check the periods and display a report of the errors
1448-
1449- @param self: The object pointer
1450- @param cr: the current row, from the database cursor,
1451- @param uid: the current user’s ID for security checks,
1452- @param ids: List of the wizard IDs (commonly the first element is the current ID)
1453- @param context: A standard dictionary for contextual values
1454 """
1455- errors_by_company = \
1456- super(account_consolidation_check, self).check_all_periods(cr, uid, ids, context=context)
1457-
1458- if errors_by_company:
1459- company_obj = self.pool.get('res.company')
1460-
1461- err_lines = []
1462- for company_id, errors in errors_by_company.iteritems():
1463- company = company_obj.browse(cr, uid, company_id, context=context)
1464- err_lines.append(_("%s :") % (company.name,))
1465- [err_lines.append(error) for error in errors]
1466- err_lines.append('')
1467-
1468- raise osv.except_osv(_('Invalid periods'),
1469- '\n'.join(err_lines))
1470- else:
1471+ errors_by_company = super(account_consolidation_check, self).\
1472+ check_all_periods(cr, uid, ids, context=context)
1473+
1474+ if not errors_by_company:
1475 raise osv.except_osv(_('Validation'), _('Periods are OK.'))
1476- # open a confirmation view ?
1477- return True
1478-
1479-account_consolidation_check()
1480+
1481+ company_obj = self.pool.get('res.company')
1482+
1483+ err_lines = []
1484+ for company_id, errors in errors_by_company.iteritems():
1485+ company = company_obj.browse(cr, uid, company_id, context=context)
1486+ err_lines.append(_("%s :") % company.name)
1487+ for error in errors:
1488+ err_lines.append(error)
1489+ err_lines.append('')
1490+
1491+ raise osv.except_osv(_('Invalid periods'),
1492+ '\n'.join(err_lines))
1493
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 <openerp>
1499 <data>
1500
1501- <record id="view_consolidation_check_form" model="ir.ui.view">
1502+ <record id="view_consolidation_check_form" model="ir.ui.view">
1503 <field name="name">account.consolidation.check.form</field>
1504 <field name="model">account.consolidation.check</field>
1505 <field name="type">form</field>
1506 <field name="arch" type="xml">
1507- <form string="Consolidation: Checks">
1508- <group col="4" colspan="6">
1509- <field name="company_id" on_change="on_change_company_id(company_id)" invisible="True"/>
1510- <field name="fiscalyear_id" domain="[('company_id', '=', company_id)]"/>
1511- <newline/>
1512- <field name="holding_chart_account_id" domain="[('company_id', '=', company_id), ('parent_id', '=', False)]"/>
1513- <separator string="Subsidiaries to Consolidate" colspan="4"/>
1514- <field name="subsidiary_ids" colspan="4" nolabel="1" required="True" domain="[('parent_id', '=', company_id)]">
1515- <tree>
1516- <field name="name"/>
1517- <field name="consolidation_chart_account_id"/>
1518- </tree>
1519- </field>
1520- </group>
1521- <separator colspan="4"/>
1522- <group col="3" colspan="4">
1523- <button special="cancel" string="Cancel" icon='gtk-cancel'/>
1524- <button name="check_all_periods" string="Check Periods" colspan="1" type="object" icon="gtk-execute"/>
1525- <button name="check_account_charts" string="Check Charts" colspan="1" type="object" icon="gtk-execute"/>
1526- </group>
1527- </form>
1528+ <form string="Consolidation: Checks" version="7.0">
1529+ <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+ <group>
1531+ <field name="company_id"
1532+ on_change="on_change_company_id(company_id)"
1533+ invisible="True"/>
1534+ <field name="fiscalyear_id"
1535+ domain="[('company_id', '=', company_id)]"/>
1536+ <newline/>
1537+ <field name="holding_chart_account_id"
1538+ domain="[('company_id', '=', company_id), ('parent_id', '=', False)]"/>
1539+ <separator string="Subsidiaries to Consolidate" colspan="4"/>
1540+ <field name="subsidiary_ids" colspan="4" nolabel="1"
1541+ required="True"
1542+ domain="[('parent_id', '=', company_id)]">
1543+ <tree>
1544+ <field name="name"/>
1545+ <field name="consolidation_chart_account_id"/>
1546+ </tree>
1547+ </field>
1548+ </group>
1549+ <footer>
1550+ <button name="check_all_periods"
1551+ string="Check Periods" type="object"
1552+ class="oe_highlight"/>
1553+ or
1554+ <button name="check_account_charts"
1555+ string="Check Charts" type="object"
1556+ class="oe_highlight"/>
1557+ or
1558+ <button string="Cancel" class="oe_link" special="cancel"/>
1559+ </footer>
1560+ </form>
1561 </field>
1562 </record>
1563
1564@@ -37,9 +49,8 @@
1565 <field name="res_model">account.consolidation.check</field>
1566 <field name="view_type">form</field>
1567 <field name="view_mode">form</field>
1568- <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 <field name="target">new</field>
1570 </record>
1571
1572- </data>
1573+ </data>
1574 </openerp>
1575
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 # -*- coding: utf-8 -*-
1581 ##############################################################################
1582 #
1583-# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)
1584-#
1585-# Author : Guewen Baconnier (Camptocamp)
1586-#
1587-# WARNING: This program as such is intended to be used by professional
1588-# programmers who take the whole responsability of assessing all potential
1589-# consequences resulting from its eventual inadequacies and bugs
1590-# End users who are looking for a ready-to-use solution with commercial
1591-# garantees and support are strongly adviced to contract a Free Software
1592-# Service Company
1593-#
1594-# This program is Free Software; you can redistribute it and/or
1595-# modify it under the terms of the GNU General Public License
1596-# as published by the Free Software Foundation; either version 2
1597-# of the License, or (at your option) any later version.
1598-#
1599-# This program is distributed in the hope that it will be useful,
1600-# but WITHOUT ANY WARRANTY; without even the implied warranty of
1601-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1602-# GNU General Public License for more details.
1603-#
1604-# You should have received a copy of the GNU General Public License
1605-# along with this program; if not, write to the Free Software
1606-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1607+# Author: Guewen Baconnier
1608+# Copyright 2011-2013 Camptocamp SA
1609+#
1610+# This program is free software: you can redistribute it and/or modify
1611+# it under the terms of the GNU Affero General Public License as
1612+# published by the Free Software Foundation, either version 3 of the
1613+# License, or (at your option) any later version.
1614+#
1615+# This program is distributed in the hope that it will be useful,
1616+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1617+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1618+# GNU Affero General Public License for more details.
1619+#
1620+# You should have received a copy of the GNU Affero General Public License
1621+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1622 #
1623 ##############################################################################
1624
1625-from osv import osv, fields
1626-from tools.translate import _
1627-from tools import safe_eval as eval
1628-
1629-class account_consolidation_consolidate(osv.osv_memory):
1630+from openerp.osv import orm, fields
1631+from openerp.tools.translate import _
1632+
1633+
1634+class account_consolidation_consolidate(orm.TransientModel):
1635 _name = 'account.consolidation.consolidate'
1636 _inherit = 'account.consolidation.base'
1637
1638 _columns = {
1639- 'from_period_id': fields.many2one('account.period', 'Start Period', required=True,
1640- 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."),
1641- 'to_period_id': fields.many2one('account.period', 'End Period', required=True,
1642- help="The consolidation will be done at the very last date of the selected period."),
1643- 'journal_id': fields.many2one('account.journal', 'Journal', required=True),
1644- # not sure that we'll use them, actually using centralised counterpart journal
1645-# 'gain_account_id': fields.many2one('account.account', 'Gain Account', required=True,),
1646-# 'loss_account_id': fields.many2one('account.account', 'Loss Account', required=True,),
1647- 'target_move': fields.selection([('posted', 'All Posted Entries'),
1648- ('all', 'All Entries'),
1649- ], 'Target Moves', required=True),
1650- 'subsidiary_ids': fields.many2many('res.company', 'account_conso_conso_comp_rel', 'conso_id', 'company_id',
1651- 'Subsidiaries', required=True),
1652+ 'from_period_id': fields.many2one(
1653+ 'account.period',
1654+ 'Start Period',
1655+ required=True,
1656+ help="Select the same period in 'from' and 'to' "
1657+ "if you want to proceed with a single period. "
1658+ "Start Period is ignored for Year To Date accounts."),
1659+ 'to_period_id': fields.many2one(
1660+ 'account.period',
1661+ 'End Period',
1662+ required=True,
1663+ help="The consolidation will be done at the very "
1664+ "last date of the selected period."),
1665+ 'journal_id': fields.many2one(
1666+ 'account.journal', 'Journal', required=True),
1667+ 'target_move': fields.selection(
1668+ [('posted', 'All Posted Entries'),
1669+ ('all', 'All Entries')],
1670+ 'Target Moves',
1671+ required=True),
1672+ 'subsidiary_ids': fields.many2many(
1673+ 'res.company',
1674+ 'account_conso_conso_comp_rel',
1675+ 'conso_id',
1676+ 'company_id',
1677+ string='Subsidiaries',
1678+ required=True),
1679 }
1680
1681 _defaults = {
1682@@ -57,38 +62,39 @@
1683 }
1684
1685 def _check_periods_fy(self, cr, uid, ids, context=None):
1686- if context is None:
1687- context = {}
1688+ if isinstance(ids, (int, long)):
1689+ ids = [ids]
1690+ assert len(ids) == 1, "only 1 id expected"
1691+
1692 form = self.browse(cr, uid, ids[0], context=context)
1693- if form.from_period_id.fiscalyear_id.id != form.to_period_id.fiscalyear_id.id:
1694- return False
1695- return True
1696+ return (form.from_period_id.fiscalyear_id.id ==
1697+ form.to_period_id.fiscalyear_id.id)
1698
1699 _constraints = [
1700- (_check_periods_fy, 'Start Period and End Period must be of the same Fiscal Year !', ['from_period_id', 'to_period_id']),
1701+ (_check_periods_fy,
1702+ 'Start Period and End Period must be of the same Fiscal Year !',
1703+ ['from_period_id', 'to_period_id']),
1704 ]
1705
1706- def on_change_from_period_id(self, cr, uid, ids, from_period_id, to_period_id, context=None):
1707- """
1708- On change of the From period, set the To period to the same period if it is empty
1709-
1710- @param self: The object pointer
1711- @param cr: the current row, from the database cursor,
1712- @param uid: the current user’s ID for security checks,
1713- @param ids: List of the wizard IDs (commonly the first element is the current ID)
1714- @param from_period_id: ID of the selected from period id
1715- @param to_period_id: ID of the current from period id
1716- @param context: A standard dictionary for contextual values
1717-
1718- @return: dict of values to change
1719+ def on_change_from_period_id(self, cr, uid, ids, from_period_id,
1720+ to_period_id, context=None):
1721+ """ On change of the From period, set the To period
1722+ to the same period if it is empty
1723+
1724+ :param from_period_id: ID of the selected from period id
1725+ :param to_period_id: ID of the current from period id
1726+
1727+ :return: dict of values to change
1728 """
1729 result = {}
1730 period_obj = self.pool.get('account.period')
1731- from_period = period_obj.browse(cr, uid, from_period_id, context=context)
1732+ from_period = period_obj.browse(
1733+ cr, uid, from_period_id, context=context)
1734 if not to_period_id:
1735 result['to_period_id'] = from_period_id
1736 else:
1737- to_period = period_obj.browse(cr, uid, to_period_id, context=context)
1738+ to_period = period_obj.browse(
1739+ cr, uid, to_period_id, context=context)
1740 if to_period.date_start < from_period.date_start:
1741 result['to_period_id'] = from_period_id
1742
1743@@ -99,97 +105,87 @@
1744 """
1745 Returns the currency rate type to use
1746
1747- @param self: The object pointer
1748- @param cr: the current row, from the database cursor,
1749- @param uid: the current user’s ID for security checks,
1750- @param ids: List of the wizard IDs (commonly the first element is the current ID)
1751- @param account: browse instance of account.account
1752- @param context: A standard dictionary for contextual values
1753+ :param account: browse_record instance of account.account
1754
1755- @return: 'spot' or 'average'
1756+ :return: id of the currency rate type to use
1757 """
1758- return account.consolidation_rate_type_id and account.consolidation_rate_type_id \
1759- or account.user_type.consolidation_rate_type_id and account.user_type.consolidation_rate_type_id.id \
1760- or False
1761+ if account.consolidation_rate_type_id:
1762+ return account.consolidation_rate_type_id.id
1763+
1764+ elif account.user_type.consolidation_rate_type_id:
1765+ return account.user_type.consolidation_rate_type_id.id
1766+
1767+ else:
1768+ return False
1769
1770 def _consolidation_mode(self, cr, uid, ids, account, context=None):
1771 """
1772 Returns the consolidation mode to use
1773
1774- @param self: The object pointer
1775- @param cr: the current row, from the database cursor,
1776- @param uid: the current user’s ID for security checks,
1777- @param ids: List of the wizard IDs (commonly the first element is the current ID)
1778- @param account: browse instance of account.account
1779- @param context: A standard dictionary for contextual values
1780-
1781- @return: 'ytd' or 'period'
1782- """
1783- return account.consolidation_mode or account.user_type.consolidation_mode
1784-
1785- def _periods_holding_to_subsidiary(self, cr, uid, ids, period_ids, subsidiary_id, context=None):
1786- """
1787- Returns the periods of a subsidiary company which correspond to the holding periods
1788- (same beginning and ending dates)
1789-
1790- @param self: The object pointer
1791- @param cr: the current row, from the database cursor,
1792- @param uid: the current user’s ID for security checks,
1793- @param ids: List of the wizard IDs (commonly the first element is the current ID)
1794- @param period_ids: list of periods of the holding
1795- @param subsidiary_id: ID of the subsidiary for which we want the period IDs
1796- @param context: A standard dictionary for contextual values
1797-
1798- @return: list of periods of the subsidiaries
1799+ :param account: browse instance of account.account
1800+
1801+ :return: 'ytd' or 'period'
1802+ """
1803+ return (account.consolidation_mode or
1804+ account.user_type.consolidation_mode)
1805+
1806+ def _periods_holding_to_subsidiary(self, cr, uid, ids, period_ids,
1807+ subsidiary_id, context=None):
1808+ """
1809+ Returns the periods of a subsidiary company which
1810+ correspond to the holding periods (same beginning and ending dates)
1811+
1812+ :param period_ids: list of periods of the holding
1813+ :param subsidiary_id: ID of the subsidiary for which
1814+ we want the period IDs
1815+
1816+ :return: list of periods of the subsidiaries
1817 """
1818 period_obj = self.pool.get('account.period')
1819 if isinstance(period_ids, (int, long)):
1820 period_ids = [period_ids]
1821+
1822 subs_period_ids = []
1823 for period in period_obj.browse(cr, uid, period_ids, context=context):
1824- subs_period_ids.extend(period_obj.search(cr, uid,
1825+ subs_period_ids += period_obj.search(
1826+ cr, uid,
1827 [('date_start', '=', period.date_start),
1828 ('date_stop', '=', period.date_stop),
1829- ('company_id', '=', subsidiary_id)])
1830- )
1831+ ('company_id', '=', subsidiary_id)],
1832+ context=context)
1833 return subs_period_ids
1834
1835 def create_rate_difference_line(self, cr, uid, ids, move_id, context):
1836 """
1837- Create a move line for the gain/loss currency difference
1838-
1839- @param self: The object pointer
1840- @param cr: the current row, from the database cursor,
1841- @param uid: the current user’s ID for security checks,
1842- @param ids: List of the wizard IDs (commonly the first element is the current ID)
1843- @param move_id: ID of the move
1844- @param context: A standard dictionary for contextual values
1845-
1846- @return:
1847+ Placeholder for creation of a move line
1848+ for the gain/loss currency difference
1849+
1850+ :param move_id: ID of the move
1851 """
1852
1853- pass
1854-
1855- def consolidate_account(self, cr, uid, ids, consolidation_mode, subsidiary_period_ids, state, move_id,
1856+ def consolidate_account(self, cr, uid, ids, consolidation_mode,
1857+ subsidiary_period_ids, state, move_id,
1858 holding_account_id, subsidiary_id, context=None):
1859 """
1860 Consolidates the subsidiary account on the holding account
1861 Creates move lines on the move with id "move_id"
1862
1863- @param self: The object pointer
1864- @param cr: the current row, from the database cursor,
1865- @param uid: the current user’s ID for security checks,
1866- @param ids: List of the wizard IDs (commonly the first element is the current ID)
1867- @param consolidation_mode: consolidate by Periods or Year To Date ('period' or 'ytd')
1868- @param subsidiary_period_ids: IDs of periods for which we want to sum the debit/credit
1869- @param state: state of the moves to consolidate ('all' or 'posted')
1870- @param move_id: ID of the move on which all the created move lines will be linked
1871- @param holding_account_id: ID of the account to consolidate (on the holding), the method will find the subsidiary's corresponding account
1872- @param subsidiary_id: ID of the subsidiary to consolidate
1873- @param context: A standard dictionary for contextual values
1874+ :param consolidation_mode: consolidate by Periods or
1875+ Year To Date ('period' or 'ytd')
1876+ :param subsidiary_period_ids: IDs of periods for which we
1877+ want to sum the debit/credit
1878+ :param state: state of the moves to consolidate ('all' or 'posted')
1879+ :param move_id: ID of the move on which all the
1880+ created move lines will be linked
1881+ :param holding_account_id: ID of the account to consolidate
1882+ (on the holding), the method will
1883+ find the subsidiary's corresponding account
1884+ :param subsidiary_id: ID of the subsidiary to consolidate
1885
1886- @return: list of IDs of the created move lines
1887+ :return: list of IDs of the created move lines
1888 """
1889+ if context is None:
1890+ context = {}
1891
1892 account_obj = self.pool.get('account.account')
1893 move_obj = self.pool.get('account.move')
1894@@ -197,26 +193,27 @@
1895 currency_obj = self.pool.get('res.currency')
1896
1897 move = move_obj.browse(cr, uid, move_id, context=context)
1898- holding_account = account_obj.browse(cr, uid, holding_account_id, context=context)
1899+ holding_account = account_obj.browse(
1900+ cr, uid, holding_account_id, context=context)
1901
1902- subsidiary_account_id = account_obj.search(cr, uid,
1903- [('code', '=', holding_account.code),
1904- ('company_id', '=', subsidiary_id)],
1905- context=context)
1906+ subsidiary_account_id = account_obj.search(
1907+ cr, uid,
1908+ [('code', '=', holding_account.code),
1909+ ('company_id', '=', subsidiary_id)],
1910+ context=context)
1911
1912 if not subsidiary_account_id:
1913- return [] # an account may exist on the holding and not in the subsidiaries, nothing to do
1914+ # an account may exist on the holding and not in the subsidiaries,
1915+ # nothing to do
1916+ return []
1917
1918- browse_ctx = context.copy()
1919- browse_ctx.update({
1920- 'state': state,
1921- 'periods': subsidiary_period_ids,
1922- })
1923- # subsidiary_account_id[0] because only one account per company for one code is permitted
1924- subs_account = account_obj.browse(cr, uid, subsidiary_account_id[0], context=browse_ctx)
1925+ browse_ctx = dict(context, state=state, periods=subsidiary_period_ids)
1926+ # 1st item because the account's code is unique per company
1927+ subs_account = account_obj.browse(
1928+ cr, uid, subsidiary_account_id[0], context=browse_ctx)
1929
1930 vals = {
1931- 'name': _("Consolidation line in %s mode") % (consolidation_mode,),
1932+ 'name': _("Consolidation line in %s mode") % consolidation_mode,
1933 'account_id': holding_account.id,
1934 'move_id': move.id,
1935 'journal_id': move.journal_id.id,
1936@@ -225,16 +222,24 @@
1937 'date': move.date
1938 }
1939
1940- if holding_account.company_currency_id.id != subs_account.company_currency_id.id:
1941- currency_rate_type = self._currency_rate_type(cr, uid, ids, holding_account, context=context)
1942+ if (holding_account.company_currency_id.id ==
1943+ subs_account.company_currency_id.id):
1944+ vals.update({
1945+ 'debit': subs_account.debit,
1946+ 'credit': subs_account.credit,
1947+ })
1948+ else:
1949+ currency_rate_type = self._currency_rate_type(
1950+ cr, uid, ids, holding_account, context=context)
1951
1952- currency_value = currency_obj.compute(cr, uid,
1953- holding_account.company_currency_id.id,
1954- subs_account.company_currency_id.id,
1955- subs_account.balance,
1956- currency_rate_type_from=False, # means spot
1957- currency_rate_type_to=currency_rate_type,
1958- context=context)
1959+ currency_value = currency_obj.compute(
1960+ cr, uid,
1961+ holding_account.company_currency_id.id,
1962+ subs_account.company_currency_id.id,
1963+ subs_account.balance,
1964+ currency_rate_type_from=False, # means spot
1965+ currency_rate_type_to=currency_rate_type,
1966+ context=context)
1967 vals.update({
1968 'currency_id': subs_account.company_currency_id.id,
1969 'amount_currency': subs_account.balance,
1970@@ -242,72 +247,73 @@
1971 'credit': currency_value < 0 and -currency_value or 0.0
1972 })
1973
1974- else:
1975- vals.update({
1976- 'debit': subs_account.debit,
1977- 'credit': subs_account.credit,
1978- })
1979-
1980 move_line_id = move_line_obj.create(cr, uid, vals, context=context)
1981
1982 return move_line_id
1983
1984- def reverse_moves(self, cr, uid, ids, subsidiary_id, journal_id, reversal_date, context):
1985+ def reverse_moves(self, cr, uid, ids, subsidiary_id, journal_id,
1986+ reversal_date, context=None):
1987 """
1988- Reverse all account moves of a journal which have the "To be reversed" flag
1989-
1990- @param self: The object pointer
1991- @param cr: the current row, from the database cursor,
1992- @param uid: the current user’s ID for security checks,
1993- @param ids: List of the wizard IDs (commonly the first element is the current ID)
1994- @param subsidiary_id: ID of the subsidiary moves to reverse
1995- @param journal_id: ID of the journal with moves to reverse
1996- @param reversal_date: date when to create the reversal
1997- @param context: A standard dictionary for contextual values
1998-
1999- @return: tuple with : list of IDs of the reversed moves, list of IDs of the reversal moves
2000+ Reverse all account moves of a journal which have
2001+ the "To be reversed" flag
2002+
2003+ :param subsidiary_id: ID of the subsidiary moves to reverse
2004+ :param journal_id: ID of the journal with moves to reverse
2005+ :param reversal_date: date when to create the reversal
2006+
2007+ :return: tuple with : list of IDs of the reversed moves,
2008+ list of IDs of the reversal moves
2009 """
2010 move_obj = self.pool.get('account.move')
2011- reversed_ids = move_obj.search(cr, uid,
2012- [('journal_id', '=', journal_id),
2013- ('to_be_reversed', '=', True),
2014- ('consol_company_id', '=', subsidiary_id)],
2015- context=context)
2016- reversal_ids = move_obj.create_reversals(cr, uid, reversed_ids, reversal_date, context=context)
2017+ reversed_ids = move_obj.search(
2018+ cr, uid,
2019+ [('journal_id', '=', journal_id),
2020+ ('to_be_reversed', '=', True),
2021+ ('consol_company_id', '=', subsidiary_id)],
2022+ context=context)
2023+ reversal_ids = move_obj.create_reversals(
2024+ cr, uid, reversed_ids, reversal_date, context=context)
2025 return reversed_ids, reversal_ids
2026
2027- def consolidate_subsidiary(self, cr, uid, ids, subsidiary_id, context=None):
2028+ def consolidate_subsidiary(self, cr, uid, ids,
2029+ subsidiary_id, context=None):
2030 """
2031 Consolidate one subsidiary on the Holding.
2032 Create a move per subsidiary and consolidation type (YTD/Period)
2033 and an move line per account of the subsidiary
2034- Plus a move line for the currency gain / loss # FIXME to check!
2035-
2036- @param self: The object pointer
2037- @param cr: the current row, from the database cursor,
2038- @param uid: the current user’s ID for security checks,
2039- @param ids: List of the wizard IDs (commonly the first element is the current ID)
2040- @param subsidiary_id: ID of the subsidiary to consolidate on the holding
2041- @param context: A standard dictionary for contextual values
2042-
2043- @return: Tuple of (list of IDs of the YTD moves, list of IDs of the Period Moves)
2044+
2045+ :param subsidiary_id: ID of the subsidiary to consolidate
2046+ on the holding
2047+
2048+ :return: Tuple of form:
2049+ (list of IDs of the YTD moves,
2050+ list of IDs of the Period Moves)
2051 """
2052-
2053- context = context or {}
2054+ if context is None:
2055+ context = {}
2056+
2057+ if isinstance(ids, (int, long)):
2058+ ids = [ids]
2059+ assert len(ids) == 1, "only 1 id expected"
2060+
2061 company_obj = self.pool.get('res.company')
2062 move_obj = self.pool.get('account.move')
2063 period_obj = self.pool.get('account.period')
2064+
2065 form = self.browse(cr, uid, ids[0], context=context)
2066 subsidiary = company_obj.browse(cr, uid, subsidiary_id, context=None)
2067
2068- data_ctx = context.copy()
2069- data_ctx.update({'holding_coa': True})
2070- holding_accounts_data = self._chart_accounts_data(cr, uid, ids,
2071- form.holding_chart_account_id.id,
2072- context=data_ctx)
2073- subs_accounts_codes = self._chart_accounts_data(cr, uid, ids,
2074- subsidiary.consolidation_chart_account_id.id,
2075- context=context)
2076+ data_ctx = dict(context, holding_coa=True)
2077+ holding_accounts_data = self._chart_accounts_data(
2078+ cr, uid,
2079+ ids,
2080+ form.holding_chart_account_id.id,
2081+ context=data_ctx)
2082+ subs_accounts_codes = self._chart_accounts_data(
2083+ cr, uid,
2084+ ids,
2085+ subsidiary.consolidation_chart_account_id.id,
2086+ context=context)
2087 holding_accounts = [values for key, values
2088 in holding_accounts_data.iteritems()
2089 if key in subs_accounts_codes]
2090@@ -316,12 +322,14 @@
2091 # a move per type will be created
2092 consolidation_modes = {'ytd': [], 'period': []}
2093 for account in holding_accounts:
2094- cm = self._consolidation_mode(cr, uid, ids, account, context=context)
2095+ cm = self._consolidation_mode(
2096+ cr, uid, ids, account, context=context)
2097 consolidation_modes[cm].append(account)
2098
2099- period_ids = period_obj.build_ctx_periods(cr, uid,
2100- form.from_period_id.id,
2101- form.to_period_id.id)
2102+ period_ids = period_obj.build_ctx_periods(
2103+ cr, uid,
2104+ form.from_period_id.id,
2105+ form.to_period_id.id)
2106
2107 generic_move_vals = {
2108 'journal_id': form.journal_id.id,
2109@@ -337,15 +345,18 @@
2110
2111 # get list of periods for which we have to create a move
2112 # in period mode : a move per period
2113- # in ytd mode : a move at the last period (which will contains lines from 1st january to last period)
2114- move_period_ids = consolidation_mode == 'period' \
2115- and period_ids \
2116- or [form.to_period_id.id]
2117+ # in ytd mode : a move at the last period
2118+ # (which will contains lines from 1st january to last period)
2119+ move_period_ids = (period_ids
2120+ if consolidation_mode == 'period'
2121+ else [form.to_period_id.id])
2122
2123 for move_period_id in move_period_ids:
2124- period = period_obj.browse(cr, uid, move_period_id, context=context)
2125+ period = period_obj.browse(
2126+ cr, uid, move_period_id, context=context)
2127
2128- # in ytd we compute the amount from the first day of the fiscal year
2129+ # in ytd we compute the amount from the first
2130+ # day of the fiscal year
2131 # in period, only for the period
2132 if consolidation_mode == 'ytd':
2133 date_from = period.fiscalyear_id.date_start
2134@@ -353,50 +364,51 @@
2135 date_from = period.date_start
2136 date_to = period.date_stop
2137
2138- period_ctx = context.copy()
2139- period_ctx.update({
2140- 'company_id': subsidiary.id,
2141- })
2142- compute_from_period_id = period_obj.find(cr, uid, date_from, context=period_ctx)[0]
2143- compute_to_period_id = period_obj.find(cr, uid, date_to, context=period_ctx)[0]
2144- compute_period_ids = period_obj.build_ctx_periods(cr, uid,
2145- compute_from_period_id,
2146- compute_to_period_id)
2147+ period_ctx = dict(context, company_id=subsidiary.id)
2148+ compute_from_period_id = period_obj.find(
2149+ cr, uid, date_from, context=period_ctx)[0]
2150+ compute_to_period_id = period_obj.find(
2151+ cr, uid, date_to, context=period_ctx)[0]
2152+ compute_period_ids = period_obj.build_ctx_periods(
2153+ cr, uid,
2154+ compute_from_period_id,
2155+ compute_to_period_id)
2156
2157 # reverse previous entries with flag 'to_be_reversed' (YTD)
2158- self.reverse_moves(cr, uid, ids, subsidiary.id, form.journal_id.id, date_to, context=context)
2159-
2160- # TODO if moves found for the same period : skip ?
2161+ self.reverse_moves(
2162+ cr, uid,
2163+ ids,
2164+ subsidiary.id,
2165+ form.journal_id.id,
2166+ date_to,
2167+ context=context)
2168
2169 # create the account move
2170 # at the very last date of the end period
2171- move_vals = generic_move_vals.copy()
2172- move_vals.update({
2173- 'ref': _("Consolidation %s") % (consolidation_mode,),
2174- 'period_id': period.id,
2175- 'date': period.date_stop,
2176- })
2177+ move_vals = dict(
2178+ generic_move_vals,
2179+ ref=_("Consolidation %s") % consolidation_mode,
2180+ period_id=period.id,
2181+ date=period.date_stop)
2182 move_id = move_obj.create(cr, uid, move_vals, context=context)
2183
2184 move_line_ids = []
2185 # create a move line per account
2186 for account in accounts:
2187 move_line_ids.append(
2188- self.consolidate_account(cr, uid, ids,
2189- consolidation_mode,
2190- compute_period_ids,
2191- form.target_move,
2192- move_id,
2193- account.id,
2194- subsidiary.id,
2195- context=context)
2196+ self.consolidate_account(
2197+ cr, uid, ids,
2198+ consolidation_mode,
2199+ compute_period_ids,
2200+ form.target_move,
2201+ move_id,
2202+ account.id,
2203+ subsidiary.id,
2204+ context=context)
2205 )
2206
2207- # TODO calculate currency rate difference (all move lines debit - all move lines credit) and post a move line
2208- # on the gain / loss account
2209- # will works IF : counterparts are always configured with the same mode (YTD/Periods)
2210- self.create_rate_difference_line(cr, uid, ids,
2211- move_id, context=context)
2212+ self.create_rate_difference_line(
2213+ cr, uid, ids, move_id, context=context)
2214
2215 locals()[consolidation_mode + '_move_ids'].append(move_id)
2216
2217@@ -407,15 +419,10 @@
2218 Consolidate all selected subsidiaries Virtual Chart of Accounts
2219 on the Holding Chart of Account
2220
2221- @param self: The object pointer
2222- @param cr: the current row, from the database cursor,
2223- @param uid: the current user’s ID for security checks,
2224- @param ids: List of the wizard IDs (commonly the first element is the current ID)
2225- @param context: A standard dictionary for contextual values
2226-
2227- @return: dict to open an Entries view filtered on the created moves
2228+ :return: dict to open an Entries view filtered on the created moves
2229 """
2230- super(account_consolidation_consolidate, self).run_consolidation(cr, uid, ids, context=context)
2231+ super(account_consolidation_consolidate, self).run_consolidation(
2232+ cr, uid, ids, context=context)
2233
2234 mod_obj = self.pool.get('ir.model.data')
2235 act_obj = self.pool.get('ir.actions.act_window')
2236@@ -425,20 +432,23 @@
2237 move_ids = []
2238 ytd_move_ids = []
2239 for subsidiary in form.subsidiary_ids:
2240- new_move_ids = self.consolidate_subsidiary(cr, uid, ids, subsidiary.id, context=context)
2241- ytd_move_ids.extend(new_move_ids[0])
2242- move_ids.extend(sum(new_move_ids, []))
2243+ new_move_ids = self.consolidate_subsidiary(
2244+ cr, uid, ids, subsidiary.id, context=context)
2245+ ytd_move_ids += new_move_ids[0]
2246+ move_ids += sum(new_move_ids, [])
2247
2248 # YTD moves have to be reversed on the next consolidation
2249- move_obj.write(cr, uid, ytd_move_ids, {'to_be_reversed': True}, context=context)
2250+ move_obj.write(
2251+ cr, uid,
2252+ ytd_move_ids,
2253+ {'to_be_reversed': True},
2254+ context=context)
2255
2256 context.update({'move_ids': move_ids})
2257- action_ref = mod_obj.get_object_reference(cr, uid, 'account', 'action_move_journal_line')
2258- action_id = action_ref and action_ref[1] or False
2259+ __, action_id = mod_obj.get_object_reference(
2260+ cr, uid, 'account', 'action_move_journal_line')
2261 action = act_obj.read(cr, uid, [action_id], context=context)[0]
2262 action['domain'] = unicode([('id', 'in', move_ids)])
2263 action['name'] = _('Consolidated Entries')
2264 action['context'] = unicode({'search_default_to_be_reversed': 0})
2265 return action
2266-
2267-account_consolidation_consolidate()
2268
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 <openerp>
2274 <data>
2275
2276- <record id="view_consolidation_consolidate_form" model="ir.ui.view">
2277+ <record id="view_consolidation_consolidate_form" model="ir.ui.view">
2278 <field name="name">account.consolidation.consolidate.form</field>
2279 <field name="model">account.consolidation.consolidate</field>
2280 <field name="type">form</field>
2281 <field name="arch" type="xml">
2282- <form string="Consolidation: Consolidate">
2283- <group col="4" colspan="6">
2284- <field name="company_id" on_change="on_change_company_id(company_id)" invisible="True"/>
2285- <field name="fiscalyear_id" invisible="True"/>
2286- <field name="from_period_id" on_change="on_change_from_period_id(from_period_id, to_period_id)" domain="[('company_id', '=', company_id)]"/>
2287- <field name="to_period_id" domain="[('company_id', '=', company_id)]"/>
2288- <field name="journal_id" domain="[('company_id', '=', company_id)]"/>
2289- <field name="target_move"/>
2290- <separator string="Holding Chart of Accounts" colspan="4"/>
2291- <field name="holding_chart_account_id" domain="[('company_id', '=', company_id), ('parent_id', '=', False)]"/>
2292+ <form string="Consolidation: Consolidate" version="7.0">
2293+ <label string="Run the consolidation for the selected periods and subsidiaries."/>
2294+ <group>
2295+ <field name="company_id"
2296+ on_change="on_change_company_id(company_id)"
2297+ invisible="True"/>
2298+ <field name="fiscalyear_id" invisible="True"/>
2299+ <field name="from_period_id"
2300+ on_change="on_change_from_period_id(from_period_id, to_period_id)"
2301+ domain="[('company_id', '=', company_id)]"/>
2302+ <field name="to_period_id"
2303+ domain="[('company_id', '=', company_id)]"/>
2304+ <field name="journal_id"
2305+ domain="[('company_id', '=', company_id)]"/>
2306+ <field name="target_move"/>
2307+ <separator string="Holding Chart of Accounts" colspan="4"/>
2308+ <field name="holding_chart_account_id"
2309+ domain="[('company_id', '=', company_id), ('parent_id', '=', False)]"/>
2310
2311- <!--<separator string="Consolidation Difference Accounts" colspan="4"/>-->
2312- <!--<field name="gain_account_id" domain="[('type','&lt;&gt;','view'), ('id', 'child_of', [holding_chart_account_id])]"/>-->
2313- <!--<field name="loss_account_id" domain="[('type','&lt;&gt;','view'), ('id', 'child_of', [holding_chart_account_id])]"/>-->
2314- <separator string="Subsidiaries to Consolidate" colspan="4"/>
2315- <field name="subsidiary_ids" colspan="4" nolabel="1" required="True">
2316- <tree>
2317- <field name="name"/>
2318- <field name="consolidation_chart_account_id"/>
2319- </tree>
2320- </field>
2321- </group>
2322- <separator colspan="4"/>
2323- <group col="2" colspan="4">
2324- <button special="cancel" string="Cancel" icon='gtk-cancel'/>
2325- <button name="run_consolidation" string="Consolidate" colspan="1" type="object" icon="gtk-execute"/>
2326- </group>
2327- </form>
2328+ <separator string="Subsidiaries to Consolidate" colspan="4"/>
2329+ <field name="subsidiary_ids" colspan="4"
2330+ nolabel="1" required="True">
2331+ <tree>
2332+ <field name="name"/>
2333+ <field name="consolidation_chart_account_id"/>
2334+ </tree>
2335+ </field>
2336+ </group>
2337+ <separator colspan="4"/>
2338+ <footer>
2339+ <button name="run_consolidation"
2340+ string="Consolidate"
2341+ type="object"
2342+ class="oe_highlight"/>
2343+ or
2344+ <button string="Cancel" class="oe_link" special="cancel"/>
2345+ </footer>
2346+ </form>
2347 </field>
2348 </record>
2349
2350@@ -44,9 +54,8 @@
2351 <field name="res_model">account.consolidation.consolidate</field>
2352 <field name="view_type">form</field>
2353 <field name="view_mode">form</field>
2354- <field name="help">Run the consolidation for the selected periods and subsidiaries.</field>
2355 <field name="target">new</field>
2356 </record>
2357
2358- </data>
2359+ </data>
2360 </openerp>

Subscribers

People subscribed via source and target branches