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