mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
Undo style changes and changes in error messages
This commit is contained in:
@@ -768,6 +768,8 @@ class payment_order(osv.osv):
|
|||||||
# Therefore, if we want to pass the id in the context safely we have to
|
# Therefore, if we want to pass the id in the context safely we have to
|
||||||
# pass it under a different name.
|
# pass it under a different name.
|
||||||
#
|
#
|
||||||
|
# TODO: migrate old style wizards to osv_memory
|
||||||
|
#
|
||||||
'id_proxy': fields.function(
|
'id_proxy': fields.function(
|
||||||
_get_id_proxy, method=True, string='Copy ID', type='integer',
|
_get_id_proxy, method=True, string='Copy ID', type='integer',
|
||||||
store={
|
store={
|
||||||
@@ -913,8 +915,7 @@ class payment_order(osv.osv):
|
|||||||
self._write_payment_lines(cursor, uid, ids, export_state='rejected')
|
self._write_payment_lines(cursor, uid, ids, export_state='rejected')
|
||||||
wf_service = netsvc.LocalService('workflow')
|
wf_service = netsvc.LocalService('workflow')
|
||||||
for id in ids:
|
for id in ids:
|
||||||
wf_service.trg_validate(
|
wf_service.trg_validate(uid, 'payment.order', id, 'rejected', cursor)
|
||||||
uid, 'payment.order', id, 'rejected', cursor)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def set_done(self, cursor, uid, ids, *args):
|
def set_done(self, cursor, uid, ids, *args):
|
||||||
@@ -1199,8 +1200,8 @@ class res_partner_bank(osv.osv):
|
|||||||
else:
|
else:
|
||||||
# Ok, tried everything, give up and leave it to the user
|
# Ok, tried everything, give up and leave it to the user
|
||||||
return warning(_('Insufficient data'),
|
return warning(_('Insufficient data'),
|
||||||
_('Insufficient country information to '
|
_('Insufficient data to select online '
|
||||||
'select online conversion database')
|
'conversion database')
|
||||||
)
|
)
|
||||||
result = {'value': values}
|
result = {'value': values}
|
||||||
# Complete data with online database when available
|
# Complete data with online database when available
|
||||||
@@ -1217,17 +1218,17 @@ class res_partner_bank(osv.osv):
|
|||||||
info.bic or iban_acc.BIC_searchkey,
|
info.bic or iban_acc.BIC_searchkey,
|
||||||
code = info.code, name = info.bank
|
code = info.code, name = info.bank
|
||||||
)
|
)
|
||||||
values['country_id'] = (
|
values['country_id'] = country_id or \
|
||||||
country_id or country_ids and country_ids[0] or
|
country_ids and country_ids[0] or \
|
||||||
False)
|
False
|
||||||
values['bank'] = bank_id or False
|
values['bank'] = bank_id or False
|
||||||
else:
|
else:
|
||||||
info = None
|
info = None
|
||||||
if info is None:
|
if info is None:
|
||||||
result.update(warning(
|
result.update(warning(
|
||||||
_('Invalid data'),
|
_('Invalid data'),
|
||||||
_('Could not verify the account number\'s validity '
|
_('The account number appears to be invalid for %(country)s')
|
||||||
'for %(country)s') % {'country': country.name}
|
% {'country': country.name}
|
||||||
))
|
))
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
if country.code in sepa.IBAN.countries:
|
if country.code in sepa.IBAN.countries:
|
||||||
@@ -1238,8 +1239,8 @@ class res_partner_bank(osv.osv):
|
|||||||
values['acc_number'] = acc_number
|
values['acc_number'] = acc_number
|
||||||
result.update(warning(
|
result.update(warning(
|
||||||
_('Invalid format'),
|
_('Invalid format'),
|
||||||
_('The account number has the wrong format for '
|
_('The account number has the wrong format for %(country)s')
|
||||||
'%(country)s') % {'country': country.name}
|
% {'country': country.name}
|
||||||
))
|
))
|
||||||
else:
|
else:
|
||||||
values['acc_number'] = acc_number
|
values['acc_number'] = acc_number
|
||||||
|
|||||||
@@ -126,7 +126,6 @@ def BBAN_is_IBAN(bank_acc):
|
|||||||
Intelligent copy, valid for SEPA members who switched to SEPA from old
|
Intelligent copy, valid for SEPA members who switched to SEPA from old
|
||||||
standards before SEPA actually started.
|
standards before SEPA actually started.
|
||||||
'''
|
'''
|
||||||
iban_acc = False
|
|
||||||
if isinstance(bank_acc, IBAN):
|
if isinstance(bank_acc, IBAN):
|
||||||
iban_acc = bank_acc
|
iban_acc = bank_acc
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -173,13 +173,12 @@ class banking_import(wizard.interface):
|
|||||||
# TODO: Not sure what side effects are created when payments are done
|
# TODO: Not sure what side effects are created when payments are done
|
||||||
# for credited customer invoices, which will be matched later on too.
|
# for credited customer invoices, which will be matched later on too.
|
||||||
digits = dp.get_precision('Account')(cursor)[1]
|
digits = dp.get_precision('Account')(cursor)[1]
|
||||||
candidates = [x for x in payment_lines if (
|
candidates = [x for x in payment_lines
|
||||||
x.communication == trans.reference and
|
if x.communication == trans.reference
|
||||||
round(x.amount, digits) == -round(
|
and round(x.amount, digits) == -round(trans.transferred_amount, digits)
|
||||||
trans.transferred_amount, digits) and
|
and trans.remote_account in (x.bank_id.acc_number,
|
||||||
trans.remote_account in (x.bank_id.acc_number,
|
x.bank_id.iban)
|
||||||
x.bank_id.iban)
|
]
|
||||||
)]
|
|
||||||
if len(candidates) == 1:
|
if len(candidates) == 1:
|
||||||
candidate = candidates[0]
|
candidate = candidates[0]
|
||||||
# Check cache to prevent multiple matching of a single payment
|
# Check cache to prevent multiple matching of a single payment
|
||||||
@@ -513,14 +512,15 @@ class banking_import(wizard.interface):
|
|||||||
check_total = amount,
|
check_total = amount,
|
||||||
invoice_line = invoice_lines,
|
invoice_line = invoice_lines,
|
||||||
))
|
))
|
||||||
|
invoice = invoice_obj.browse(cursor, uid, invoice_id)
|
||||||
# Create workflow
|
# Create workflow
|
||||||
invoice_obj.button_compute(cursor, uid, [invoice_id],
|
invoice_obj.button_compute(cursor, uid, [invoice_id],
|
||||||
{'type': 'in_invoice'}, set_total=True)
|
{'type': 'in_invoice'}, set_total=True)
|
||||||
wf_service = netsvc.LocalService('workflow')
|
wf_service = netsvc.LocalService('workflow')
|
||||||
# Move to state 'open'
|
# Move to state 'open'
|
||||||
wf_service.trg_validate(uid, 'account.invoice', invoice_id,
|
wf_service.trg_validate(uid, 'account.invoice', invoice.id,
|
||||||
'invoice_open', cursor)
|
'invoice_open', cursor)
|
||||||
invoice = invoice_obj.browse(cursor, uid, invoice_id)
|
|
||||||
# return move_lines to mix with the rest
|
# return move_lines to mix with the rest
|
||||||
return [x for x in invoice.move_id.line_id if x.account_id.reconcile]
|
return [x for x in invoice.move_id.line_id if x.account_id.reconcile]
|
||||||
|
|
||||||
@@ -568,6 +568,7 @@ class banking_import(wizard.interface):
|
|||||||
|
|
||||||
# Parse the file
|
# Parse the file
|
||||||
statements = parser.parse(data)
|
statements = parser.parse(data)
|
||||||
|
|
||||||
if any([x for x in statements if not x.is_valid()]):
|
if any([x for x in statements if not x.is_valid()]):
|
||||||
raise wizard.except_wizard(
|
raise wizard.except_wizard(
|
||||||
_('ERROR!'),
|
_('ERROR!'),
|
||||||
@@ -730,8 +731,8 @@ class banking_import(wizard.interface):
|
|||||||
))
|
))
|
||||||
imported_statement_ids.append(statement_id)
|
imported_statement_ids.append(statement_id)
|
||||||
|
|
||||||
# move each transaction to the right period and try to match it
|
# move each transaction to the right period and try to match it with an
|
||||||
# with an invoice or payment
|
# invoice or payment
|
||||||
subno = 0
|
subno = 0
|
||||||
injected = []
|
injected = []
|
||||||
i = 0
|
i = 0
|
||||||
@@ -743,8 +744,8 @@ class banking_import(wizard.interface):
|
|||||||
transaction = injected.pop(0)
|
transaction = injected.pop(0)
|
||||||
else:
|
else:
|
||||||
transaction = statement.transactions[i]
|
transaction = statement.transactions[i]
|
||||||
# Keep a tracer for identification of order in a statement
|
# Keep a tracer for identification of order in a statement in case
|
||||||
# in case of missing transaction ids.
|
# of missing transaction ids.
|
||||||
subno += 1
|
subno += 1
|
||||||
|
|
||||||
# Link accounting period
|
# Link accounting period
|
||||||
@@ -799,16 +800,15 @@ class banking_import(wizard.interface):
|
|||||||
if partner_banks:
|
if partner_banks:
|
||||||
partner_ids = [x.partner_id.id for x in partner_banks]
|
partner_ids = [x.partner_id.id for x in partner_banks]
|
||||||
elif transaction.remote_owner:
|
elif transaction.remote_owner:
|
||||||
iban = None
|
iban = sepa.IBAN(transaction.remote_account)
|
||||||
country_code = None
|
if iban.valid:
|
||||||
if transaction.remote_account:
|
|
||||||
iban = sepa.IBAN(transaction.remote_account)
|
|
||||||
if iban and iban.valid:
|
|
||||||
country_code = iban.countrycode
|
country_code = iban.countrycode
|
||||||
elif transaction.remote_owner_country_code:
|
elif transaction.remote_owner_country_code:
|
||||||
country_code = transaction.remote_owner_country_code
|
country_code = transaction.remote_owner_country_code
|
||||||
elif hasattr(parser, 'country_code') and parser.country_code:
|
elif hasattr(parser, 'country_code') and parser.country_code:
|
||||||
country_code = parser.country_code
|
country_code = parser.country_code
|
||||||
|
else:
|
||||||
|
country_code = None
|
||||||
partner_id = get_or_create_partner(
|
partner_id = get_or_create_partner(
|
||||||
self.pool, cursor, uid, transaction.remote_owner,
|
self.pool, cursor, uid, transaction.remote_owner,
|
||||||
transaction.remote_owner_address,
|
transaction.remote_owner_address,
|
||||||
@@ -931,12 +931,12 @@ class banking_import(wizard.interface):
|
|||||||
# account_payment, in order to increase efficiency.
|
# account_payment, in order to increase efficiency.
|
||||||
payment_order_obj.set_done(cursor, uid, order_ids,
|
payment_order_obj.set_done(cursor, uid, order_ids,
|
||||||
{'state': 'done'}
|
{'state': 'done'}
|
||||||
)
|
)
|
||||||
wf_service = netsvc.LocalService('workflow')
|
wf_service = netsvc.LocalService('workflow')
|
||||||
for id in order_ids:
|
for id in order_ids:
|
||||||
wf_service.trg_validate(uid, 'payment.order', id, 'done',
|
wf_service.trg_validate(uid, 'payment.order', id, 'done',
|
||||||
cursor
|
cursor
|
||||||
)
|
)
|
||||||
|
|
||||||
# Original code. Didn't take workflow logistics into account...
|
# Original code. Didn't take workflow logistics into account...
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user