Merge lp:~camptocamp/account-closing/7.0-port-account_unrelized_currency_gain_loss-20120115 into lp:~account-core-editors/account-closing/7.0

Proposed by Yannick Vaucher @ Camptocamp
Status: Merged
Merged at revision: 33
Proposed branch: lp:~camptocamp/account-closing/7.0-port-account_unrelized_currency_gain_loss-20120115
Merge into: lp:~account-core-editors/account-closing/7.0
Diff against target: 819 lines (+351/-201)
16 files modified
account_multicurrency_revaluation/__openerp__.py (+58/-22)
account_multicurrency_revaluation/account.py (+20/-21)
account_multicurrency_revaluation/account_view.xml (+4/-4)
account_multicurrency_revaluation/i18n/de.po (+16/-0)
account_multicurrency_revaluation/i18n/en.po (+16/-0)
account_multicurrency_revaluation/i18n/es.po (+16/-0)
account_multicurrency_revaluation/i18n/fr.po (+16/-0)
account_multicurrency_revaluation/report/currency_unrealized_report.py (+0/-2)
account_multicurrency_revaluation/report/templates/unrealized_currency_gain_loss.mako (+1/-1)
account_multicurrency_revaluation/res_company.py (+42/-44)
account_multicurrency_revaluation/res_company_view.xml (+31/-23)
account_multicurrency_revaluation/res_currency_view.xml (+0/-4)
account_multicurrency_revaluation/wizard/print_currency_unrealized_report.py (+36/-8)
account_multicurrency_revaluation/wizard/print_currency_unrealized_report_view.xml (+12/-10)
account_multicurrency_revaluation/wizard/wizard_currency_revaluation.py (+69/-47)
account_multicurrency_revaluation/wizard/wizard_currency_revaluation_view.xml (+14/-15)
To merge this branch: bzr merge lp:~camptocamp/account-closing/7.0-port-account_unrelized_currency_gain_loss-20120115
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Approve
Review via email: mp+143283@code.launchpad.net

Description of the change

Port of module account_unrealized_currency_gain_loss renamed as account_multicurrency_revaluation

To post a comment you must log in.
46. By Yannick Vaucher @ Camptocamp

[FIX] button style in revaluation wizard

47. By Frederic Clementi - Camptocamp

[IMP] module description

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Space after comma
456 + 'account.period', 'Period to use',required=True),

Extraneous parenthesis
674 + (fiscalyear.code,)))

Beside those minor points, LGTM

review: Approve
48. By Yannick Vaucher @ Camptocamp

[IMP] python formating

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Here we go, this is fixed.

Thx for the review

49. By Yannick Vaucher @ Camptocamp

[ADD] po files

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed directory 'account_unrealized_currency_gain_loss' => 'account_multicurrency_revaluation'
2=== modified file 'account_multicurrency_revaluation/__openerp__.py'
3--- account_unrealized_currency_gain_loss/__openerp__.py 2013-01-04 10:32:06 +0000
4+++ account_multicurrency_revaluation/__openerp__.py 2013-01-15 15:51:25 +0000
5@@ -19,32 +19,68 @@
6 #
7 ##############################################################################
8
9-{"name": "Unrealized currency gain & loss",
10+{"name": "Multicurrency revaluation",
11 "version": "6.1",
12 "category": "Finance",
13 "description": """
14-Add a wizard to generate the unrealized currency gain & loss entries. This adjusts accounts' balance of account with a foreign currency.
15-
16-To configure it, Foreign currency gain & loss account have been added in company parameters.
17-
18-For UK (Revaluation) :
19- LOSS GAIN
20-- Revaluation account [x] [x]
21-- Provision B.S account [ ] [ ]
22-- Provision P&L account [ ] [ ]
23-
24-For CH (Provision) :
25- LOSS GAIN
26-- Revaluation account [ ] [ ]
27-- Provision B.S account [x] [ ]
28-- Provision P&L account [x] [ ]
29+===========================
30+ Multicurrency revaluation
31+===========================
32+
33+The *Multicurrency revaluation* module allows you generate automatically multicurrency revaluation journal entries. You will also find here a Revaluation report
34+
35+Note that an extra aggregation by currency on general ledger & partner ledger (from module : *account_financial_report*) has been added in order to get more details.
36+
37+---------------
38+ Main Features
39+---------------
40+
41+* A checkbox *Allow currency revaluation* on accounts.
42+* A wizard to generate the revaluation journal entries. It adjusts account balance having *Allow currency revaluation* checked.
43+* A wizard to print a report of revaluation.
44+
45+The report uses webkit report system.
46+
47+---------------
48+ Configuration
49+---------------
50+
51+Due to the various legislation according the country, in the Company settings you can set the way you want to generate revaluation journal entries.
52+
53+Please, find below adviced account settings for 3 countries :
54+
55+For UK (Revaluation)
56+====================
57+(l10n_uk Chart of account)
58+
59+::
60+
61+ LOSS GAIN
62+ Revaluation account [7700] [7700]
63+ Provision B.S account [ ] [ ]
64+ Provision P&L account [ ] [ ]
65+
66+For CH (Provision)
67+==================
68+(l10n_ch Chart of account)
69+
70+::
71+
72+ LOSS GAIN
73+ Revaluation account [ ] [ ]
74+ Provision B.S account [2331] [2331]
75+ Provision P&L account [3906] [4906]
76
77 For FR
78- LOSS GAIN
79-- Revaluation account [x] [x]
80-- Provision B.S account [x] [ ]
81-- Provision P&L account [x] [ ]
82-
83+======
84+(l10n_fr Chart of account)
85+
86+::
87+
88+ LOSS GAIN
89+ Revaluation account [ 476] [ 477]
90+ Provision B.S account [1515] [ ]
91+ Provision P&L account [6865] [ ]
92 """,
93
94 "author": "Camptocamp",
95@@ -61,7 +97,7 @@
96 "update_xml": ['report/report.xml'],
97 #"test": ["test/currency_revaluation.yml"],
98 "demo_xml": [],
99- 'installable': False,
100+ 'installable': True,
101 "active": False,
102 # 'certificate': 'certificate',
103 }
104
105=== modified file 'account_multicurrency_revaluation/account.py'
106--- account_unrealized_currency_gain_loss/account.py 2012-06-19 10:47:52 +0000
107+++ account_multicurrency_revaluation/account.py 2013-01-15 15:51:25 +0000
108@@ -19,25 +19,26 @@
109 #
110 ##############################################################################
111
112-from osv import osv, fields
113-
114-
115-class AccountAccountLine(osv.osv):
116-
117+from openerp.osv import fields, orm
118+
119+
120+class AccountAccountLine(orm.Model):
121 _inherit = 'account.move.line'
122 # By convention added columns stats with gl_.
123- _columns = {'gl_foreign_balance': fields.float('Aggregated Amount curency'),
124- 'gl_balance': fields.float('Aggregated Amount'),
125- 'gl_revaluated_balance': fields.float('Revaluated Amount'),
126- 'gl_currency_rate': fields.float('Currency rate')}
127-
128-
129-class AccountAccount(osv.osv):
130-
131+ _columns = {
132+ 'gl_foreign_balance': fields.float('Aggregated Amount curency'),
133+ 'gl_balance': fields.float('Aggregated Amount'),
134+ 'gl_revaluated_balance': fields.float('Revaluated Amount'),
135+ 'gl_currency_rate': fields.float('Currency rate')}
136+
137+
138+class AccountAccount(orm.Model):
139 _inherit = 'account.account'
140
141- _columns = {'currency_revaluation':
142- fields.boolean("Allow Currency revaluation")}
143+ _columns = {
144+ 'currency_revaluation': fields.boolean(
145+ "Allow Currency revaluation")
146+ }
147
148 _defaults = {'currency_revaluation': False}
149
150@@ -45,10 +46,10 @@
151 'balance': "COALESCE(SUM(l.debit),0) - COALESCE(SUM(l.credit), 0) as balance",
152 'debit': "COALESCE(SUM(l.debit), 0) as debit",
153 'credit': "COALESCE(SUM(l.credit), 0) as credit",
154- 'foreign_balance': "COALESCE(SUM(l.amount_currency), 0) as foreign_balance"}
155- def _revaluation_query(self,
156- cr, uid,
157- ids,
158+ 'foreign_balance': "COALESCE(SUM(l.amount_currency), 0) as foreign_balance",
159+ }
160+
161+ def _revaluation_query(self, cr, uid, ids,
162 revaluation_date,
163 context=None):
164
165@@ -102,6 +103,4 @@
166
167 return accounts
168
169-AccountAccount()
170-
171 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
172
173=== modified file 'account_multicurrency_revaluation/account_view.xml'
174--- account_unrealized_currency_gain_loss/account_view.xml 2012-03-21 16:34:12 +0000
175+++ account_multicurrency_revaluation/account_view.xml 2013-01-15 15:51:25 +0000
176@@ -8,12 +8,12 @@
177 <field name="type">form</field>
178 <field name="inherit_id" ref="account.view_account_form"/>
179 <field name="arch" type="xml">
180- <xpath expr="//page[@string='General Information']/group[2]" position="after">
181- <group col="2" colspan="2">
182- <separator string="Currency Revaluation"/>
183+ <label for="note" position="before">
184+ <separator string="Currency Revaluation"/>
185+ <group>
186 <field name="currency_revaluation"/>
187 </group>
188- </xpath>
189+ </label>
190 </field>
191 </record>
192
193
194=== added file 'account_multicurrency_revaluation/i18n/de.po'
195--- account_multicurrency_revaluation/i18n/de.po 1970-01-01 00:00:00 +0000
196+++ account_multicurrency_revaluation/i18n/de.po 2013-01-15 15:51:25 +0000
197@@ -0,0 +1,16 @@
198+# Translation of OpenERP Server.
199+# This file contains the translation of the following modules:
200+#
201+msgid ""
202+msgstr ""
203+"Project-Id-Version: OpenERP Server 7.0\n"
204+"Report-Msgid-Bugs-To: \n"
205+"POT-Creation-Date: 2013-01-15 15:47+0000\n"
206+"PO-Revision-Date: 2013-01-15 15:47+0000\n"
207+"Last-Translator: <>\n"
208+"Language-Team: \n"
209+"MIME-Version: 1.0\n"
210+"Content-Type: text/plain; charset=UTF-8\n"
211+"Content-Transfer-Encoding: \n"
212+"Plural-Forms: \n"
213+
214
215=== added file 'account_multicurrency_revaluation/i18n/en.po'
216--- account_multicurrency_revaluation/i18n/en.po 1970-01-01 00:00:00 +0000
217+++ account_multicurrency_revaluation/i18n/en.po 2013-01-15 15:51:25 +0000
218@@ -0,0 +1,16 @@
219+# Translation of OpenERP Server.
220+# This file contains the translation of the following modules:
221+#
222+msgid ""
223+msgstr ""
224+"Project-Id-Version: OpenERP Server 7.0\n"
225+"Report-Msgid-Bugs-To: \n"
226+"POT-Creation-Date: 2013-01-15 15:47+0000\n"
227+"PO-Revision-Date: 2013-01-15 15:47+0000\n"
228+"Last-Translator: <>\n"
229+"Language-Team: \n"
230+"MIME-Version: 1.0\n"
231+"Content-Type: text/plain; charset=UTF-8\n"
232+"Content-Transfer-Encoding: \n"
233+"Plural-Forms: \n"
234+
235
236=== added file 'account_multicurrency_revaluation/i18n/es.po'
237--- account_multicurrency_revaluation/i18n/es.po 1970-01-01 00:00:00 +0000
238+++ account_multicurrency_revaluation/i18n/es.po 2013-01-15 15:51:25 +0000
239@@ -0,0 +1,16 @@
240+# Translation of OpenERP Server.
241+# This file contains the translation of the following modules:
242+#
243+msgid ""
244+msgstr ""
245+"Project-Id-Version: OpenERP Server 7.0\n"
246+"Report-Msgid-Bugs-To: \n"
247+"POT-Creation-Date: 2013-01-15 15:47+0000\n"
248+"PO-Revision-Date: 2013-01-15 15:47+0000\n"
249+"Last-Translator: <>\n"
250+"Language-Team: \n"
251+"MIME-Version: 1.0\n"
252+"Content-Type: text/plain; charset=UTF-8\n"
253+"Content-Transfer-Encoding: \n"
254+"Plural-Forms: \n"
255+
256
257=== added file 'account_multicurrency_revaluation/i18n/fr.po'
258--- account_multicurrency_revaluation/i18n/fr.po 1970-01-01 00:00:00 +0000
259+++ account_multicurrency_revaluation/i18n/fr.po 2013-01-15 15:51:25 +0000
260@@ -0,0 +1,16 @@
261+# Translation of OpenERP Server.
262+# This file contains the translation of the following modules:
263+#
264+msgid ""
265+msgstr ""
266+"Project-Id-Version: OpenERP Server 7.0\n"
267+"Report-Msgid-Bugs-To: \n"
268+"POT-Creation-Date: 2013-01-15 15:47+0000\n"
269+"PO-Revision-Date: 2013-01-15 15:47+0000\n"
270+"Last-Translator: <>\n"
271+"Language-Team: \n"
272+"MIME-Version: 1.0\n"
273+"Content-Type: text/plain; charset=UTF-8\n"
274+"Content-Transfer-Encoding: \n"
275+"Plural-Forms: \n"
276+
277
278=== modified file 'account_multicurrency_revaluation/report/currency_unrealized_report.py'
279--- account_unrealized_currency_gain_loss/report/currency_unrealized_report.py 2012-04-23 12:29:53 +0000
280+++ account_multicurrency_revaluation/report/currency_unrealized_report.py 2013-01-15 15:51:25 +0000
281@@ -98,7 +98,6 @@
282 'period_name': self._get_period_name,
283 'report_name': _('Exchange Rate Gain and Loss Report')})
284
285-
286 def sort_accounts_with_structure(self, root_account_ids, account_ids, context=None):
287 """Sort accounts by code respecting their structure. code Take from
288 financial webkit report in order not to depends from it"""
289@@ -196,7 +195,6 @@
290 res_ids = [res_id for res_id in res_ids if res_id in only_ids]
291 return res_ids
292
293-
294 def set_context(self, objects, data, ids, report_type=None):
295 """Populate a ledger_lines attribute on each browse record that will be used
296 by mako template"""
297
298=== modified file 'account_multicurrency_revaluation/report/templates/unrealized_currency_gain_loss.mako'
299--- account_unrealized_currency_gain_loss/report/templates/unrealized_currency_gain_loss.mako 2012-04-23 12:29:53 +0000
300+++ account_multicurrency_revaluation/report/templates/unrealized_currency_gain_loss.mako 2013-01-15 15:51:25 +0000
301@@ -10,7 +10,7 @@
302 </style>
303 </head>
304 <body>
305-<%setLang(user.context_lang)%>
306+<%setLang(user.lang)%>
307 <div class="act_as_table data_table">
308 <div class="act_as_row labels">
309 <div class="act_as_cell">${_('Report')}</div>
310
311=== modified file 'account_multicurrency_revaluation/res_company.py'
312--- account_unrealized_currency_gain_loss/res_company.py 2012-03-21 16:34:12 +0000
313+++ account_multicurrency_revaluation/res_company.py 2013-01-15 15:51:25 +0000
314@@ -19,54 +19,52 @@
315 #
316 ##############################################################################
317
318-from osv import osv, fields
319-
320-
321-class ResCompany(osv.osv):
322-
323+from openerp.osv import fields, orm
324+
325+
326+class ResCompany(orm.Model):
327 _inherit = "res.company"
328
329- _columns = {'revaluation_loss_account_id':
330- fields.many2one('account.account',
331- 'Revaluation loss account',
332- domain=[('type', '=', 'other')]),
333- 'revaluation_gain_account_id':
334- fields.many2one('account.account',
335- 'Revaluation gain account',
336- domain=[('type', '=', 'other')]),
337- 'revaluation_analytic_account_id':
338- fields.many2one('account.analytic.account',
339- 'Revaluation Analytic account'),
340- 'provision_bs_loss_account_id':
341- fields.many2one('account.account',
342- 'Provision B.S loss account',
343- domain=[('type', '=', 'other')]),
344- 'provision_bs_gain_account_id':
345- fields.many2one('account.account',
346- 'Provision B.S gain account',
347- domain=[('type', '=', 'other')]),
348- 'provision_pl_loss_account_id':
349- fields.many2one('account.account',
350- 'Provision P&L loss account',
351- domain=[('type', '=', 'other')]),
352- 'provision_pl_gain_account_id':
353- fields.many2one('account.account',
354- 'Provision P&L gain account',
355- domain=[('type', '=', 'other')]),
356- 'default_currency_reval_journal_id':
357- fields.many2one('account.journal',
358- 'Currency gain & loss Default Journal',
359- domain=[('type', '=', 'general')]),
360- 'reversable_revaluations':
361- fields.boolean('Reversable Revaluations',
362- help="Revaluations entries will be created"
363- " as \"To Be Reversed\".")
364- }
365+ _columns = {
366+ 'revaluation_loss_account_id': fields.many2one(
367+ 'account.account',
368+ 'Revaluation loss account',
369+ domain=[('type', '=', 'other')]),
370+ 'revaluation_gain_account_id': fields.many2one(
371+ 'account.account',
372+ 'Revaluation gain account',
373+ domain=[('type', '=', 'other')]),
374+ 'revaluation_analytic_account_id': fields.many2one(
375+ 'account.analytic.account',
376+ 'Revaluation Analytic account'),
377+ 'provision_bs_loss_account_id': fields.many2one(
378+ 'account.account',
379+ 'Provision B.S loss account',
380+ domain=[('type', '=', 'other')]),
381+ 'provision_bs_gain_account_id': fields.many2one(
382+ 'account.account',
383+ 'Provision B.S gain account',
384+ domain=[('type', '=', 'other')]),
385+ 'provision_pl_loss_account_id': fields.many2one(
386+ 'account.account',
387+ 'Provision P&L loss account',
388+ domain=[('type', '=', 'other')]),
389+ 'provision_pl_gain_account_id': fields.many2one(
390+ 'account.account',
391+ 'Provision P&L gain account',
392+ domain=[('type', '=', 'other')]),
393+ 'default_currency_reval_journal_id': fields.many2one(
394+ 'account.journal',
395+ 'Currency gain & loss Default Journal',
396+ domain=[('type', '=', 'general')]),
397+ 'reversable_revaluations': fields.boolean(
398+ 'Reversable Revaluations',
399+ help="Revaluations entries will be created"
400+ " as \"To Be Reversed\".")
401+ }
402
403 _defaults = {
404 'reversable_revaluations': True,
405- }
406-
407-ResCompany()
408+ }
409
410 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
411
412=== modified file 'account_multicurrency_revaluation/res_company_view.xml'
413--- account_unrealized_currency_gain_loss/res_company_view.xml 2012-03-21 16:34:12 +0000
414+++ account_multicurrency_revaluation/res_company_view.xml 2013-01-15 15:51:25 +0000
415@@ -9,30 +9,38 @@
416 <field name="inherit_id" ref="base.view_company_form" />
417 <field name="arch" type="xml">
418 <xpath expr="//page[@string='Configuration']" position="inside">
419- <group colspan="5">
420 <separator string="Foreign currency gain &amp; loss" colspan="5"/>
421- <field name="reversable_revaluations"/>
422- <newline/>
423- <label colspan="1"/>
424- <separator string="LOSS"/>
425- <separator string="GAIN"/>
426- <separator string="ANALYTIC ACCOUNT"/>
427- <newline/>
428- <label string="Revaluation accounts:" colspan="1"/>
429- <field name="revaluation_loss_account_id" nolabel="1"/>
430- <field name="revaluation_gain_account_id" nolabel="1"/>
431- <field name="revaluation_analytic_account_id" nolabel="1"/>
432- <newline/>
433- <label string="Provision B.S accounts:" colspan="1"/>
434- <field name="provision_bs_loss_account_id" nolabel="1"/>
435- <field name="provision_bs_gain_account_id" nolabel="1"/>
436- <newline/>
437- <label string="Provision P&amp;L accounts:" colspan="1"/>
438- <field name="provision_pl_loss_account_id" nolabel="1"/>
439- <field name="provision_pl_gain_account_id" nolabel="1"/>
440- <newline/>
441- <separator colspan="5"/>
442- <field name="default_currency_reval_journal_id"/>
443+ <group>
444+ <field name="reversable_revaluations"/>
445+ </group>
446+ <table colspan="2">
447+ <tr>
448+ <th></th>
449+ <th width="250px"><label string="LOSS"/></th>
450+ <th width="250px"><label string="GAIN"/></th>
451+ <th width="250px"><label string="ANALYTIC ACCOUNT"/></th>
452+ </tr>
453+ <tr>
454+ <th><label string="Revaluation accounts"/></th>
455+ <td> <field name="revaluation_loss_account_id" nolabel="1"/> </td>
456+ <td> <field name="revaluation_gain_account_id" nolabel="1"/> </td>
457+ <td> <field name="revaluation_analytic_account_id" nolabel="1"/> </td>
458+ </tr>
459+ <tr>
460+ <th><label string="Provision B.S accounts"/></th>
461+ <td> <field name="provision_bs_loss_account_id" nolabel="1"/> </td>
462+ <td> <field name="provision_bs_gain_account_id" nolabel="1"/> </td>
463+ <td> </td>
464+ </tr>
465+ <tr>
466+ <th><label string="Provision P&amp;L accounts"/></th>
467+ <td> <field name="provision_pl_loss_account_id" nolabel="1"/> </td>
468+ <td> <field name="provision_pl_gain_account_id" nolabel="1"/> </td>
469+ <td> </td>
470+ </tr>
471+ </table>
472+ <group>
473+ <field name="default_currency_reval_journal_id"/>
474 </group>
475 </xpath>
476 </field>
477
478=== modified file 'account_multicurrency_revaluation/res_currency_view.xml'
479--- account_unrealized_currency_gain_loss/res_currency_view.xml 2012-02-24 16:41:09 +0000
480+++ account_multicurrency_revaluation/res_currency_view.xml 2013-01-15 15:51:25 +0000
481@@ -8,15 +8,11 @@
482 <field name="type">form</field>
483 <field name="inherit_id" ref="base.view_currency_form"/>
484 <field name="arch" type="xml">
485- <xpath expr="//form[@string='Rates']/field[@name='rate']" position="after">
486- <field name="currency_rate_type_id"/>
487- </xpath>
488 <xpath expr="//tree[@string='Rates']/field[@name='rate']" position="after">
489 <field name="currency_rate_type_id"/>
490 </xpath>
491 </field>
492 </record>
493
494-
495 </data>
496 </openerp>
497
498=== modified file 'account_multicurrency_revaluation/wizard/print_currency_unrealized_report.py'
499--- account_unrealized_currency_gain_loss/wizard/print_currency_unrealized_report.py 2012-04-23 12:29:53 +0000
500+++ account_multicurrency_revaluation/wizard/print_currency_unrealized_report.py 2013-01-15 15:51:25 +0000
501@@ -1,25 +1,53 @@
502-from openerp.osv.orm import TransientModel, fields
503-
504-class UnrealizedCurrencyReportPrinter(TransientModel):
505+# -*- coding: utf-8 -*-
506+##############################################################################
507+#
508+# Author: Guewen Baconnier, Yannick Vaucher
509+# Copyright 2012 Camptocamp SA
510+#
511+# This program is free software: you can redistribute it and/or modify
512+# it under the terms of the GNU Affero General Public License as
513+# published by the Free Software Foundation, either version 3 of the
514+# License, or (at your option) any later version.
515+#
516+# This program is distributed in the hope that it will be useful,
517+# but WITHOUT ANY WARRANTY; without even the implied warranty of
518+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
519+# GNU Affero General Public License for more details.
520+#
521+# You should have received a copy of the GNU Affero General Public License
522+# along with this program. If not, see <http://www.gnu.org/licenses/>.
523+#
524+##############################################################################
525+
526+from openerp.osv import fields, orm
527+
528+
529+class UnrealizedCurrencyReportPrinter(orm.TransientModel):
530 _name = "unrealized.report.printer"
531
532- _columns = {'chart_account_id': fields.many2one('account.account', 'Chart root',
533+ _columns = {
534+ 'chart_account_id': fields.many2one(
535+ 'account.account', 'Chart root',
536 domain=[('parent_id', '=', False)]),
537- 'period_id': fields.many2one('account.period', 'Period to use',required=True)}
538-
539+ 'period_id': fields.many2one(
540+ 'account.period', 'Period to use', required=True),
541+ }
542
543 def print_report(self, cursor, uid, wid, data, context=None):
544+ """
545+ Show the report
546+ """
547 context = context or {}
548 # we update form with display account value
549 if isinstance(wid, list):
550 wid = wid[0]
551- current = self.browse(cursor, uid, wid, context)
552+ current = self.browse(cursor, uid, wid, context=context)
553 form = {}
554 form['period_id'] = current.period_id.id
555 form['period_name'] = current.period_id.name
556 form['account_ids'] = [current.chart_account_id.id]
557 data['form'] = form
558- print data
559+
560 return {'type': 'ir.actions.report.xml',
561 'report_name': 'currency_unrealized',
562 'datas': data}
563
564=== modified file 'account_multicurrency_revaluation/wizard/print_currency_unrealized_report_view.xml'
565--- account_unrealized_currency_gain_loss/wizard/print_currency_unrealized_report_view.xml 2012-04-23 12:29:53 +0000
566+++ account_multicurrency_revaluation/wizard/print_currency_unrealized_report_view.xml 2013-01-15 15:51:25 +0000
567@@ -7,18 +7,20 @@
568 <field name="model">unrealized.report.printer</field>
569 <field name="type">form</field>
570 <field name="arch" type="xml">
571- <form>
572- <field name="period_id"/>
573- <field name="chart_account_id" />
574- <newline/>
575- <group col="3" colspan="4">
576- <button special="cancel" string="Cancel" icon='gtk-cancel'/>
577- <button name="print_report" string="Print" colspan="1" type="object" icon="gtk-execute"/>
578- </group>
579- </form>
580+ <form string="Print Currency Unrealized" version="7.0">
581+ <group>
582+ <field name="period_id"/>
583+ <field name="chart_account_id"/>
584+ </group>
585+ <footer>
586+ <button name="print_report" type="object" string="_Print" class="oe_highlight"/>
587+ or
588+ <button string="Cancel" class="oe_link" special="cancel" />
589+ </footer>
590+ </form>
591 </field>
592 </record>
593-
594+
595 <record id="currency_urealized_report_action_wizard" model="ir.actions.act_window">
596 <field name="name">Print Currency Unrealized</field>
597 <field name="type">ir.actions.act_window</field>
598
599=== modified file 'account_multicurrency_revaluation/wizard/wizard_currency_revaluation.py'
600--- account_unrealized_currency_gain_loss/wizard/wizard_currency_revaluation.py 2012-08-21 09:49:04 +0000
601+++ account_multicurrency_revaluation/wizard/wizard_currency_revaluation.py 2013-01-15 15:51:25 +0000
602@@ -21,34 +21,38 @@
603
604 from datetime import date
605
606-from osv import osv, fields
607+from openerp.osv import fields, orm, osv
608 from tools.translate import _
609
610-class WizardCurrencyrevaluation(osv.osv_memory):
611+
612+class WizardCurrencyrevaluation(orm.TransientModel):
613 _name = 'wizard.currency.revaluation'
614
615- _columns = {'revaluation_date': fields.date('Revaluation Date',
616- required=True),
617- 'journal_id': fields.many2one(
618- 'account.journal',
619- 'Journal',
620- domain="[('type','=','general')]",
621- help="You can set the default "
622- "journal in company settings.",
623- required=True),
624- 'currency_type': fields.many2one(
625- 'res.currency.rate.type',
626- 'Currency Type',
627- help="If no currency_type is selected,"
628- " only rates with no type will be browsed.",
629- required=False),
630- 'label': fields.char(
631- 'Entry description',
632- size=100,
633- help="This label will be inserted in entries description."
634- " You can use %(account)s, %(currency)s"
635- " and %(rate)s keywords.",
636- required=True)}
637+ _columns = {
638+ 'revaluation_date': fields.date(
639+ 'Revaluation Date',
640+ required=True),
641+ 'journal_id': fields.many2one(
642+ 'account.journal',
643+ 'Journal',
644+ domain="[('type','=','general')]",
645+ help="You can set the default "
646+ "journal in company settings.",
647+ required=True),
648+ 'currency_type': fields.many2one(
649+ 'res.currency.rate.type',
650+ 'Currency Type',
651+ help="If no currency_type is selected,"
652+ " only rates with no type will be browsed.",
653+ required=False),
654+ 'label': fields.char(
655+ 'Entry description',
656+ size=100,
657+ help="This label will be inserted in entries description."
658+ " You can use %(account)s, %(currency)s"
659+ " and %(rate)s keywords.",
660+ required=True),
661+ }
662
663 def _get_default_revaluation_date(self, cr, uid, context):
664 """
665@@ -85,10 +89,12 @@
666 journal = cp.default_currency_reval_journal_id
667 return journal and journal.id or False
668
669- _defaults = {'label': "%(currency)s %(account)s "
670- "%(rate)s currency revaluation",
671- 'revaluation_date': _get_default_revaluation_date,
672- 'journal_id': _get_default_journal_id}
673+ _defaults = {
674+ 'label': "%(currency)s %(account)s "
675+ "%(rate)s currency revaluation",
676+ 'revaluation_date': _get_default_revaluation_date,
677+ 'journal_id': _get_default_journal_id,
678+ }
679
680 def on_change_revaluation_date(self, cr, uid, id, revaluation_date):
681 if not revaluation_date:
682@@ -157,7 +163,7 @@
683 ctx_rate['currency_rate_type_id'] = type_id
684 user_obj = self.pool.get('res.users')
685 cp_currency_id = user_obj.browse(cr, uid, uid, context=context).company_id.currency_id.id
686-
687+
688 currency = currency_obj.browse(cr, uid, currency_id, context=ctx_rate)
689
690 foreign_balance = adjusted_balance = balances.get(
691@@ -178,7 +184,7 @@
692 unrealized_gain_loss = 0.0 - balance
693 else:
694 unrealized_gain_loss = 0.0
695- else:
696+ else:
697 unrealized_gain_loss = 0.0
698 return {'unrealized_gain_loss': unrealized_gain_loss,
699 'currency_rate': currency.rate,
700@@ -407,35 +413,53 @@
701 context=context)
702
703 if not fiscalyear_ids:
704- raise osv.except_osv(_('Error!'),
705- _('No fiscalyear found for company %s on %s.'
706- % (company.name, form.revaluation_date)))
707+ raise osv.except_osv(
708+ _('Error!'),
709+ _('No fiscalyear found for company %s on %s.' %
710+ (company.name, form.revaluation_date)))
711
712 fiscalyear = fiscalyear_obj.browse(
713 cr, uid, fiscalyear_ids[0], context=context)
714-
715+
716 special_period_ids = [p.id for p in fiscalyear.period_ids
717 if p.special == True]
718 if not special_period_ids:
719- raise osv.except_osv(_('Error!'),
720- _('No special period found for the fiscalyear %s' %
721- (fiscalyear.code,)))
722-
723+ raise osv.except_osv(
724+ _('Error!'),
725+ _('No special period found for the fiscalyear %s' %
726+ (fiscalyear.code,)))
727+
728 opening_move_ids = []
729 if special_period_ids:
730-
731+
732 opening_move_ids = move_obj.search(
733 cr, uid, [('period_id', '=', special_period_ids[0])])
734- if not opening_move_ids or not special_period_ids:
735- raise osv.except_osv(_('Error!'),
736- _('No opening entries in opening period for this fiscal year %s' %
737- (fiscalyear.code,)))
738-
739+ if not opening_move_ids:
740+
741+ # if the first move is on this fiscalyear, this is the first
742+ # financial year
743+ first_move_id = move_obj.search(
744+ cr, uid, [('company_id', '=', company.id)],
745+ order='date', limit=1)
746+
747+ if not first_move_id:
748+ raise osv.except_osv(_('Error!'),
749+ _('No fiscal entries found'))
750+
751+ first_move = move_obj.browse(
752+ cr, uid, first_move_id[0], context=context)
753+
754+ if fiscalyear != first_move.period_id.fiscalyear_id:
755+ raise osv.except_osv(
756+ _('Error!'),
757+ _('No opening entries in opening period for this fiscal year %s' %
758+ (fiscalyear.code,)))
759+
760 period_ids = [p.id for p in fiscalyear.period_ids]
761 if not period_ids:
762 raise osv.except_osv(_('Error!'),
763 _('No period found for the fiscalyear %s' %
764- (fiscalyear.code,)))
765+ fiscalyear.code))
766
767
768 # Get balance sums
769@@ -495,6 +519,4 @@
770 raise osv.except_osv(_("Warning"),
771 _("No accounting entry have been posted."))
772
773-WizardCurrencyrevaluation()
774-
775 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
776
777=== modified file 'account_multicurrency_revaluation/wizard/wizard_currency_revaluation_view.xml'
778--- account_unrealized_currency_gain_loss/wizard/wizard_currency_revaluation_view.xml 2012-05-23 13:10:02 +0000
779+++ account_multicurrency_revaluation/wizard/wizard_currency_revaluation_view.xml 2013-01-15 15:51:25 +0000
780@@ -7,25 +7,24 @@
781 <field name="model">wizard.currency.revaluation</field>
782 <field name="type">form</field>
783 <field name="arch" type="xml">
784- <form string="Currency Revaluation" col="4">
785- <field name="revaluation_date" on_change="on_change_revaluation_date(revaluation_date)"/>
786- <newline/>
787- <field name="journal_id"/>
788- <newline/>
789- <field name="currency_type"/>
790- <newline/>
791- <separator string="" colspan="6"/>
792- <field name="label"/>
793- <newline/>
794- <label/>
795+ <form string="Currency Revaluation" version="7.0">
796+ <label string="This will reevaluate the currency gain &amp; loss"/>
797+ <group>
798+ <field name="revaluation_date" on_change="on_change_revaluation_date(revaluation_date)"/>
799+ <field name="journal_id"/>
800+ <field name="currency_type"/>
801+ <separator string="" colspan="6"/>
802+ <field name="label"/>
803+ </group>
804 <group>
805 <label string="%%(account)s : Account for which the revaluation is applied"/>
806- <newline/>
807 <label string="%%(rate)s : Value of rate applied during revaluation"/>
808 </group>
809- <newline/>
810- <button special="cancel" string="Cancel" icon="gtk-cancel" />
811- <button name="revaluate_currency" string="Validate" type="object" icon="gtk-execute"/>
812+ <footer>
813+ <button name="revaluate_currency" type="object" string="_Validate" class="oe_highlight"/>
814+ or
815+ <button string="Cancel" class="oe_link" special="cancel" />
816+ </footer>
817 </form>
818 </field>
819 </record>

Subscribers

People subscribed via source and target branches