[FIX] account_banking: backported bugfixes and small improvements from v6

merge proposal (Stefan Rijnhart - Therp)
This commit is contained in:
Pieter J. Kersten
2011-04-27 13:42:52 +02:00
parent 55d79a7caa
commit 913d74413a
9 changed files with 35 additions and 16 deletions

View File

@@ -25,7 +25,7 @@
##############################################################################
{
'name': 'Account Banking',
'version': '0.1.58',
'version': '0.1.59',
'license': 'GPL-3',
'author': 'EduSense BV',
'website': 'http://www.edusense.nl',

View File

@@ -890,6 +890,8 @@ class payment_order(osv.osv):
to the absence of filters on writes and hence the requirement to
filter on the client(=OpenERP server) side.
'''
if not hasattr(ids, '__iter__'):
ids = [ids]
payment_line_obj = self.pool.get('payment.line')
line_ids = payment_line_obj.search(
cursor, uid, [
@@ -911,7 +913,6 @@ class payment_order(osv.osv):
Set both self and payment lines to state 'sent'.
'''
self._write_payment_lines(cursor, uid, ids, export_state='sent')
self.write(cursor, uid, ids, {'state': 'rejected'})
wf_service = netsvc.LocalService('workflow')
for id in ids:
wf_service.trg_validate(uid, 'payment.order', id, 'sent', cursor)
@@ -922,22 +923,21 @@ class payment_order(osv.osv):
Set both self and payment lines to state 'rejected'.
'''
self._write_payment_lines(cursor, uid, ids, export_state='rejected')
self.write(cursor, uid, ids, {'state': 'rejected'})
wf_service = netsvc.LocalService('workflow')
for id in ids:
wf_service.trg_validate(uid, 'payment.order', id, 'rejected', cursor)
return True
def set_done(self, cursor, uid, id, *args):
def set_done(self, cursor, uid, ids, *args):
'''
Extend standard transition to update children as well.
'''
self._write_payment_lines(cursor, uid, [id],
self._write_payment_lines(cursor, uid, ids,
export_state='done',
date_done=time.strftime('%Y-%m-%d')
)
return super(payment_order, self).set_done(
cursor, uid, id, *args
cursor, uid, ids, *args
)
def get_wizard(self, type):
@@ -1188,14 +1188,21 @@ class res_partner_bank(osv.osv):
elif partner_id:
partner_obj = self.pool.get('res.partner')
country = partner_obj.browse(cursor, uid, partner_id).country
country_ids = [country.id]
country_ids = country and [country.id] or []
# 4. Without any of the above, take the country from the company of
# the handling user
if not country_ids:
user = self.pool.get('res.users').browse(cursor, uid, uid)
# Try users address first
if user.address_id and user.address_id.country_id:
country = user.address_id.country_id
country_ids = [country.id]
# Last try user companies partner
elif (user.company_id and
user.company_id.partner_id and
user.company_id.partner_id.country
):
country_ids = [user.company_id.partner_id.country.id]
else:
# Ok, tried everything, give up and leave it to the user
return warning(_('Insufficient data'),

View File

@@ -131,10 +131,13 @@ def BBAN_is_IBAN(bank_acc):
else:
iban_acc = IBAN(bank_acc)
return struct(
iban = str(iban_acc),
account = str(bank_acc),
country_id = iban_acc.countrycode,
code = iban_acc.BIC_searchkey
# Note: BIC can not be constructed here!
bic = False,
bank = False,
)
_account_info = {

View File

@@ -753,6 +753,8 @@ class banking_import(wizard.interface):
results.log)
if not period_id:
results.trans_skipped_cnt += 1
if not injected:
i += 1
continue
# When bank costs are part of transaction itself, split it.
@@ -922,7 +924,7 @@ class banking_import(wizard.interface):
"AND id IN (%s)"
")" % (','.join([str(x) for x in payment_line_ids]))
)
order_ids = cursor.fetchall()
order_ids = [x[0] for x in cursor.fetchall()]
if order_ids:
# Use workflow logics for the orders. Recode logic from
# account_payment, in order to increase efficiency.

View File

@@ -148,16 +148,23 @@ def get_or_create_partner(pool, cursor, uid, name, address, postal_code, city,
address_ids = address_obj.search(cursor, uid, filter)
key = name.lower()
partner_ids = [x.partner_id.id
# Make sure to get a unique list
partner_ids = list(set([x.partner_id.id
for x in address_obj.browse(cursor, uid, address_ids)
# Beware for dangling addresses
if _has_attr(x.partner_id, 'name') and
x.partner_id.name.lower() in key
]
]))
if not partner_ids:
if (not country_code) or not country_id:
country_id = pool.get('res.user').browse(cursor, uid, uid)\
.company_id.partner_id.country.id
user = pool.get('res.user').browse(cursor, uid, uid)
country_id = (
user.company_id and
user.company_id.partner_id and
user.company_id.partner_id.country and
user.company_id.partner_id.country.id or
False
)
partner_id = partner_obj.create(cursor, uid, dict(
name=name, active=True, comment='Generated from Bank Statements Import',
address=[(0,0,{

View File

@@ -26,7 +26,7 @@
##############################################################################
{
'name': 'Account Banking PATU module',
'version': '0.58',
'version': '0.59',
'license': 'GPL-3',
'author': 'Sami Haahtinen',
'website': 'http://ressukka.net',

View File

@@ -25,7 +25,7 @@
##############################################################################
{
'name': 'Account Banking NL ClieOp',
'version': '0.58',
'version': '0.59',
'license': 'GPL-3',
'author': 'EduSense BV',
'website': 'http://www.edusense.nl',

View File

@@ -25,7 +25,7 @@
##############################################################################
{
'name': 'Account Banking - Girotel',
'version': '0.58',
'version': '0.59',
'license': 'GPL-3',
'author': 'EduSense BV',
'website': 'http://www.edusense.nl',

View File

@@ -25,7 +25,7 @@
##############################################################################
{
'name': 'Account Banking',
'version': '0.58',
'version': '0.59',
'license': 'GPL-3',
'author': 'EduSense BV',
'website': 'http://www.edusense.nl',