From be99efc934cc40afee615aef97c6beb747eea36b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 21 Mar 2013 11:01:39 +0100 Subject: [PATCH 1/5] [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/5] [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 ccc419b34926b287ebf0ab72665196bea922bbbe Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 Apr 2013 11:39:29 +0200 Subject: [PATCH 3/5] [FIX] better error log for completion rules + global error message is logged --- account_statement_base_completion/statement.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/account_statement_base_completion/statement.py b/account_statement_base_completion/statement.py index 7c5b434e..96beb109 100644 --- a/account_statement_base_completion/statement.py +++ b/account_statement_base_completion/statement.py @@ -45,6 +45,9 @@ class ErrorTooManyPartner(Exception): def __str__(self): return repr(self.value) + def __repr__(self): + return repr(self.value) + class AccountStatementProfil(orm.Model): """ @@ -303,12 +306,14 @@ class AccountStatementCompletionRule(orm.Model): pairs = cr.fetchall() for pair in pairs: context['label_memoizer'][pair[0]].append(partner) + if st_line['id'] in context['label_memoizer']: found_partner = context['label_memoizer'][st_line['id']] if len(found_partner) > 1: - raise ErrorTooManyPartner(_('Line named "%s" (Ref:%s) was matched by ' - 'more than one partner while looking on partner label') % - (st_line['name'], st_line['ref'])) + msg = (_('Line named "%s" (Ref:%s) was matched by ' + 'more than one partner while looking on partner label: %s') % + (st_line['name'], st_line['ref'], ','.join([x.name for x in found_partner]))) + raise ErrorTooManyPartner(msg) res['partner_id'] = found_partner[0].id st_vals = st_obj.get_values_for_line(cr, uid, @@ -451,8 +456,8 @@ class AccountBankSatement(orm.Model): log = log if log else "" completion_date = datetime.datetime.now().strftime(DEFAULT_SERVER_DATETIME_FORMAT) - message = (_("%s Bank Statement ID %s has %s lines completed by %s \n%s\n") % - (completion_date, stat_id, number_imported, user_name, log)) + message = (_("%s Bank Statement ID %s has %s lines completed by %s \n%s\n%s\n") % + (completion_date, stat_id, number_imported, user_name, error_msg, log)) self.write(cr, uid, [stat_id], {'completion_logs': message}, context=context) body = (_('Statement ID %s auto-completed for %s lines completed') % From dbdc2d2610f866f4e84a304f4b6fa286ec675cce Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 Apr 2013 11:51:39 +0200 Subject: [PATCH 4/5] [FIX] inversion in regex --- account_statement_base_completion/statement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_statement_base_completion/statement.py b/account_statement_base_completion/statement.py index 96beb109..dd67e095 100644 --- a/account_statement_base_completion/statement.py +++ b/account_statement_base_completion/statement.py @@ -298,7 +298,7 @@ class AccountStatementCompletionRule(orm.Model): line_ids = context.get('line_ids', []) for partner in partner_obj.browse(cr, uid, partner_ids, context=context): vals = '|'.join(re.escape(x.strip()) for x in partner.bank_statement_label.split(';')) - or_regex = ".*%s*." % vals + or_regex = ".*%s.*" % vals sql = ("SELECT id from account_bank_statement_line" " WHERE id in %s" " AND name ~* %s") From 2800b90cfdaa3fe7907a93caae7de15e74987e1a Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Fri, 24 May 2013 11:26:39 +0200 Subject: [PATCH 5/5] [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