Merge with base branch

This commit is contained in:
Virgil Dupras
2013-06-12 10:59:10 -04:00
2 changed files with 31 additions and 10 deletions

View File

@@ -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):
"""
@@ -295,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")
@@ -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') %

View File

@@ -1,4 +1,4 @@
#-*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Nicolas Bessi, Joel Grand-Guillaume
@@ -125,6 +125,16 @@ class AccountBankSatement(Model):
_inherit = "account.bank.statement"
def _default_period(self, cr, uid, context=None):
"""
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
_columns = {
'profile_id': fields.many2one(
'account.statement.profile',
@@ -156,11 +166,15 @@ 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 = {
'period_id': False,
'period_id': _default_period,
}
def create(self, cr, uid, vals, context=None):
@@ -536,7 +550,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