From 5b16ae402ab7280f77b8d32e9a39412cbfba8075 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Mon, 18 Jun 2007 04:10:14 +0000 Subject: [PATCH] Default value for the period within the journal bzr revid: fp@tinyerp.com-5b8439a0b6e41d2faa77bc1ebb7459f24c6fc46e --- addons/account/wizard/wizard_journal.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/addons/account/wizard/wizard_journal.py b/addons/account/wizard/wizard_journal.py index 764f3974efe..93b8e8e0cbb 100644 --- a/addons/account/wizard/wizard_journal.py +++ b/addons/account/wizard/wizard_journal.py @@ -37,9 +37,22 @@ _journal_form = ''' ''' +def _period_get(self, cr, uid, datas, ctx={}): + try: + pool = pooler.get_pool(cr.dbname) + ids = pool.get('account.period').find(cr, uid, context=ctx) + return {'period_id': ids[0]} + except: + return {} + _journal_fields = { 'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True}, - 'period_id': {'string':'Period', 'type':'many2one', 'relation':'account.period', 'required':True} + 'period_id': { + 'string':'Period', + 'type':'many2one', + 'relation':'account.period', + 'required':True, + } } def _action_open_window(self, cr, uid, data, context): @@ -68,7 +81,7 @@ def _action_open_window(self, cr, uid, data, context): class wiz_journal(wizard.interface): states = { 'init': { - 'actions': [], + 'actions': [_period_get], 'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('open','Open Journal')]} }, 'open': {