From c93258148e591a9314c14a85237a31c28bdbe60b Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Sun, 23 Mar 2014 11:06:13 +0100 Subject: [PATCH] [FIX] Workaround for lp:1296229, defaults functions are passed context as a positional argument --- account_banking/account_banking.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/account_banking/account_banking.py b/account_banking/account_banking.py index dad9b118c..971df55ee 100644 --- a/account_banking/account_banking.py +++ b/account_banking/account_banking.py @@ -331,6 +331,8 @@ class account_bank_statement(orm.Model): without a value. For that reason, we need to be tolerant and allow for the situation in which no period exists for the current date (i.e. when no date is specified). + + Cannot be used directly as a defaults method due to lp:1296229 """ local_ctx = dict(context or {}, account_period_prefer_normal=True) try: @@ -482,6 +484,12 @@ class account_bank_statement_line(orm.Model): return self.pool['account.bank.statement']._get_period( cr, uid, date=date, context=context) + def _get_period_context(self, cr, uid, context=None): + """ + Workaround for lp:1296229, context is passed positionally + """ + return self._get_period(cr, uid, context=context) + def _get_currency(self, cr, uid, context=None): ''' Get the default currency (required to allow other modules to function, @@ -544,7 +552,7 @@ class account_bank_statement_line(orm.Model): } _defaults = { - 'period_id': _get_period, + 'period_id': _get_period_context, 'currency': _get_currency, }