From be99efc934cc40afee615aef97c6beb747eea36b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 21 Mar 2013 11:01:39 +0100 Subject: [PATCH 1/3] [MRG] restore default period in bank statement --- account_statement_ext/statement.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/account_statement_ext/statement.py b/account_statement_ext/statement.py index 9d34a2a4..6efd4c3b 100644 --- a/account_statement_ext/statement.py +++ b/account_statement_ext/statement.py @@ -104,6 +104,14 @@ class AccountBankSatement(Model): _inherit = "account.bank.statement" + def _default_period(self, cr, uid, context=None): + """ + Statement default period + """ + period_obj = self.pool.get('account.period') + periods = period_obj.find(cr, uid, dt=context.get('date'), context=context) + return periods and periods[0] or False + _columns = { 'profile_id': fields.many2one( 'account.statement.profile', @@ -139,7 +147,7 @@ class AccountBankSatement(Model): } _defaults = { - 'period_id': False, + 'period_id': _default_period, } def create(self, cr, uid, vals, context=None): From 830074b98615d6c63a63c5b00eb98e77221a7120 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Mar 2013 10:32:52 +0100 Subject: [PATCH 2/3] [FIX] set period id to invisible instead of readonly because on change period_id value is never send to server --- account_statement_ext/statement.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/account_statement_ext/statement.py b/account_statement_ext/statement.py index 6efd4c3b..400db597 100644 --- a/account_statement_ext/statement.py +++ b/account_statement_ext/statement.py @@ -18,7 +18,6 @@ # along with this program. If not, see . # ############################################################################## - from openerp.osv.orm import Model from openerp.osv import fields, osv from openerp.tools.translate import _ @@ -143,7 +142,11 @@ class AccountBankSatement(Model): store=True, readonly=True), 'period_id': fields.many2one( - 'account.period', 'Period', required=False, readonly=True), + 'account.period', + 'Period', + required=False, + readonly=False, + invisible="True"), } _defaults = { From 2800b90cfdaa3fe7907a93caae7de15e74987e1a Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Fri, 24 May 2013 11:26:39 +0200 Subject: [PATCH 3/3] [FIX] value of 'invisible' argument, ensured context is a dict --- account_statement_ext/statement.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/account_statement_ext/statement.py b/account_statement_ext/statement.py index 400db597..46763f80 100644 --- a/account_statement_ext/statement.py +++ b/account_statement_ext/statement.py @@ -107,6 +107,8 @@ class AccountBankSatement(Model): """ Statement default period """ + if context is None: + context = {} period_obj = self.pool.get('account.period') periods = period_obj.find(cr, uid, dt=context.get('date'), context=context) return periods and periods[0] or False @@ -146,7 +148,7 @@ class AccountBankSatement(Model): 'Period', required=False, readonly=False, - invisible="True"), + invisible=True), } _defaults = { @@ -466,7 +468,9 @@ class AccountBankSatementLine(Model): """ Return a period from a given date in the context. """ - date = context.get('date', None) + if context is None: + context = {} + date = context.get('date') periods = self.pool.get('account.period').find(cr, uid, dt=date) return periods and periods[0] or False