From 024d12454e3ac1392536b81187d3d9a0f98eabf9 Mon Sep 17 00:00:00 2001 From: Sandy Carter Date: Thu, 21 Aug 2014 13:37:43 -0400 Subject: [PATCH] PEP8 on account_banking_nl_clieop --- account_banking_nl_clieop/__init__.py | 9 +- account_banking_nl_clieop/__openerp__.py | 4 +- .../account_banking_nl_clieop.py | 17 +-- .../6.1.0.63/post-fill-ir_model_id.py | 40 ++--- .../6.1.0.64/post-set-payment-order-type.py | 27 ++-- account_banking_nl_clieop/wizard/__init__.py | 7 +- account_banking_nl_clieop/wizard/clieop.py | 83 +++++++---- .../wizard/export_clieop.py | 141 ++++++++++-------- 8 files changed, 181 insertions(+), 147 deletions(-) diff --git a/account_banking_nl_clieop/__init__.py b/account_banking_nl_clieop/__init__.py index aecaf7f24..30d067840 100644 --- a/account_banking_nl_clieop/__init__.py +++ b/account_banking_nl_clieop/__init__.py @@ -11,8 +11,8 @@ # garantees and support are strongly adviced to contract EduSense BV # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, @@ -24,7 +24,6 @@ # along with this program. If not, see . # ############################################################################## -import wizard -import account_banking_nl_clieop -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +from . import wizard +from . import account_banking_nl_clieop diff --git a/account_banking_nl_clieop/__openerp__.py b/account_banking_nl_clieop/__openerp__.py index e1744aa95..f64e99f89 100644 --- a/account_banking_nl_clieop/__openerp__.py +++ b/account_banking_nl_clieop/__openerp__.py @@ -4,8 +4,8 @@ # All Rights Reserved # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, diff --git a/account_banking_nl_clieop/account_banking_nl_clieop.py b/account_banking_nl_clieop/account_banking_nl_clieop.py index 97925c8f4..147989121 100644 --- a/account_banking_nl_clieop/account_banking_nl_clieop.py +++ b/account_banking_nl_clieop/account_banking_nl_clieop.py @@ -5,8 +5,8 @@ # All Rights Reserved # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, @@ -19,7 +19,6 @@ # ############################################################################## -from datetime import date from openerp.osv import orm, fields from openerp.tools.translate import _ @@ -45,7 +44,7 @@ class clieop_export(orm.Model): 'duplicates': fields.integer('Number of Duplicates', readonly=True), 'prefered_date': - fields.date('Prefered Processing Date',readonly=True), + fields.date('Prefered Processing Date', readonly=True), 'no_transactions': fields.integer('Number of Transactions', readonly=True), 'check_no_accounts': @@ -81,13 +80,13 @@ class clieop_export(orm.Model): ''' last = 1 last_ids = self.search(cr, uid, [ - ('date_generated', '=', - fields.date.context_today(self, cr,uid,context)) - ], context=context) + ('date_generated', '=', fields.date.context_today( + self, cr, uid, context)), + ], context=context) if last_ids: last = 1 + max([x['daynumber'] for x in self.read( - cr, uid, last_ids, ['daynumber'], - context=context)]) + cr, uid, last_ids, ['daynumber'], context=context)] + ) return last _defaults = { diff --git a/account_banking_nl_clieop/migrations/6.1.0.63/post-fill-ir_model_id.py b/account_banking_nl_clieop/migrations/6.1.0.63/post-fill-ir_model_id.py index a0a2810b9..018f21816 100644 --- a/account_banking_nl_clieop/migrations/6.1.0.63/post-fill-ir_model_id.py +++ b/account_banking_nl_clieop/migrations/6.1.0.63/post-fill-ir_model_id.py @@ -4,8 +4,8 @@ # Copyright (C) 2011 Therp BV () # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, @@ -20,25 +20,27 @@ """ This script covers the migration of the payment wizards from old style to new style (osv_memory). It guarantees an easy upgrade for early adopters -of the 6.0 branch of this OpenERP module. Note that a migration from OpenERP +of the 6.0 branch of this OpenERP module. Note that a migration from OpenERP 5.0 to OpenERP 6.0 with respect to this module is not covered by this script. """ -__name__ = "payment.mode.type:: Add new style payment wizards to existing payment mode types" +__name__ = ("payment.mode.type:: Add new style payment wizards to existing " + "payment mode types") + def migrate(cr, version): - cr.execute ("UPDATE payment_mode_type" - " SET ir_model_id = data1.res_id" - " FROM ir_model_data data1," - " ir_model_data data2" - " WHERE data2.res_id = payment_mode_type.id" - " AND data1.module = 'account_banking_nl_clieop'" - " AND data1.model = 'ir.model'" - " AND data1.name = 'model_banking_export_clieop_wizard'" - " AND data2.module = 'account_banking_nl_clieop'" - " AND data2.model = 'payment.mode.type'" - " AND data2.name IN ('export_clieop_inc'," - " 'export_clieop_pay'," - " 'export_clieop_sal'" - " )" - ) + cr.execute("UPDATE payment_mode_type" + " SET ir_model_id = data1.res_id" + " FROM ir_model_data data1," + " ir_model_data data2" + " WHERE data2.res_id = payment_mode_type.id" + " AND data1.module = 'account_banking_nl_clieop'" + " AND data1.model = 'ir.model'" + " AND data1.name = 'model_banking_export_clieop_wizard'" + " AND data2.module = 'account_banking_nl_clieop'" + " AND data2.model = 'payment.mode.type'" + " AND data2.name IN ('export_clieop_inc'," + " 'export_clieop_pay'," + " 'export_clieop_sal'" + " )" + ) diff --git a/account_banking_nl_clieop/migrations/6.1.0.64/post-set-payment-order-type.py b/account_banking_nl_clieop/migrations/6.1.0.64/post-set-payment-order-type.py index 720573d61..edb6b257c 100644 --- a/account_banking_nl_clieop/migrations/6.1.0.64/post-set-payment-order-type.py +++ b/account_banking_nl_clieop/migrations/6.1.0.64/post-set-payment-order-type.py @@ -4,8 +4,8 @@ # Copyright (C) 2011 Therp BV () # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, @@ -18,16 +18,19 @@ # ############################################################################## -""" r64: introduction of the payment_mode_type in order to support of debit orders +"""r64: introduction of the payment_mode_type in order to support of debit +orders """ -__name__ = "payment.mode.type:: set payment_mode_type to 'debit' for Clieop incasso export" +__name__ = ("payment.mode.type:: set payment_mode_type to 'debit' for Clieop " + "incasso export") + def migrate(cr, version): - cr.execute ("UPDATE payment_mode_type" - " SET payment_order_type = 'debit'" - " FROM ir_model_data " - " WHERE res_id = payment_mode_type.id" - " AND module = 'account_banking_nl_clieop'" - " AND model = 'payment.mode.type'" - " AND ir_model_data.name = 'export_clieop_inc'" - ) + cr.execute("UPDATE payment_mode_type" + " SET payment_order_type = 'debit'" + " FROM ir_model_data " + " WHERE res_id = payment_mode_type.id" + " AND module = 'account_banking_nl_clieop'" + " AND model = 'payment.mode.type'" + " AND ir_model_data.name = 'export_clieop_inc'" + ) diff --git a/account_banking_nl_clieop/wizard/__init__.py b/account_banking_nl_clieop/wizard/__init__.py index 487cbd5c6..b8355511d 100644 --- a/account_banking_nl_clieop/wizard/__init__.py +++ b/account_banking_nl_clieop/wizard/__init__.py @@ -5,8 +5,8 @@ # All Rights Reserved # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, @@ -18,6 +18,5 @@ # along with this program. If not, see . # ############################################################################## -import export_clieop -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +from . import export_clieop diff --git a/account_banking_nl_clieop/wizard/clieop.py b/account_banking_nl_clieop/wizard/clieop.py index 678301ff5..15eaf14ea 100644 --- a/account_banking_nl_clieop/wizard/clieop.py +++ b/account_banking_nl_clieop/wizard/clieop.py @@ -5,8 +5,8 @@ # All Rights Reserved # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, @@ -26,7 +26,8 @@ __all__ = ['DirectDebitBatch', 'PaymentsBatch', 'DirectDebit', 'Payment', 'DirectDebitFile', 'PaymentsFile', 'SalaryPaymentsFile', 'SalaryPaymentOrder', 'PaymentOrder', 'DirectDebitOrder', 'OrdersFile', - ] + ] + class SWIFTField(record.Field): ''' @@ -37,27 +38,24 @@ class SWIFTField(record.Field): kwargs['cast'] = convert.to_swift super(SWIFTField, self).__init__(*args, **kwargs) - #def take(self, buffer): - # return convert.to_swift(super(SWIFTField, self).take(buffer)) - - #def format(self, value): - # return convert.to_swift(super(SWIFTField, self).format(value)) class SWIFTFieldNoLeadingWhitespace(SWIFTField): def format(self, value): return super(SWIFTFieldNoLeadingWhitespace, self).format( self.cast(value).lstrip()) + def eleven_test(s): ''' Dutch eleven-test for validating 9-long local bank account numbers. ''' r = 0 l = len(s) - for i,c in enumerate(s): + for i, c in enumerate(s): r += (l-i) * int(c) return (r % 11) == 0 + def chunk(str, length): ''' Split a string in equal sized substrings of length @@ -66,7 +64,8 @@ def chunk(str, length): yield str[:length] str = str[length:] -class HeaderRecord(record.Record): #{{{ + +class HeaderRecord(record.Record): '''ClieOp3 header record''' _fields = [ record.Filler('recordcode', 4, '0001'), @@ -84,7 +83,7 @@ class HeaderRecord(record.Record): #{{{ self.sender_id = id or '' self.file_id = '%02d%02d' % (self.creation_date.day, seqno) self.duplicatecode = duplicate and '2' or '1' -#}}} + class FooterRecord(record.Record): '''ClieOp3 footer record''' @@ -94,6 +93,7 @@ class FooterRecord(record.Record): record.Filler('filler', 45), ] + class BatchHeaderRecord(record.Record): '''Header record preceding new batches''' _fields = [ @@ -107,6 +107,7 @@ class BatchHeaderRecord(record.Record): record.Filler('filler', 10), ] + class BatchFooterRecord(record.Record): '''Closing record for batches''' _fields = [ @@ -118,6 +119,7 @@ class BatchFooterRecord(record.Record): record.Filler('filler', 10), ] + class FixedMessageRecord(record.Record): '''Fixed message''' _fields = [ @@ -127,6 +129,7 @@ class FixedMessageRecord(record.Record): record.Filler('filler', 13), ] + class SenderRecord(record.Record): '''Ordering party''' _fields = [ @@ -140,6 +143,7 @@ class SenderRecord(record.Record): record.Filler('filler', 2), ] + class TransactionRecord(record.Record): '''Transaction''' _fields = [ @@ -152,6 +156,7 @@ class TransactionRecord(record.Record): record.Filler('filler', 9), ] + class NamePayerRecord(record.Record): '''Name payer''' _fields = [ @@ -161,6 +166,7 @@ class NamePayerRecord(record.Record): record.Filler('filler', 10), ] + class PaymentReferenceRecord(record.Record): '''Payment reference''' _fields = [ @@ -170,6 +176,7 @@ class PaymentReferenceRecord(record.Record): record.Filler('filler', 29), ] + class DescriptionRecord(record.Record): '''Description''' _fields = [ @@ -179,6 +186,7 @@ class DescriptionRecord(record.Record): record.Filler('filler', 13), ] + class NameBeneficiaryRecord(record.Record): '''Name receiving party''' _fields = [ @@ -188,6 +196,7 @@ class NameBeneficiaryRecord(record.Record): record.Filler('filler', 10), ] + class OrderRecord(record.Record): '''Order details''' _fields = [ @@ -203,23 +212,28 @@ class OrderRecord(record.Record): record.Filler('currency', 3, 'EUR'), record.Field('testcode', 1), ] + def __init__(self, *args, **kwargs): super(OrderRecord, self).__init__(*args, **kwargs) self.batch_medium = 'DATACOM' self.name_transactioncode = self._transactioncode + class SalaryPaymentOrder(OrderRecord): '''Salary payment batch record''' _transactioncode = 'SALARIS' + class PaymentOrder(OrderRecord): '''Payment batch record''' _transactioncode = 'CREDBET' + class DirectDebitOrder(OrderRecord): '''Direct debit payments batch record''' _transactioncode = 'INCASSO' + class Optional(object): '''Auxilliary class to handle optional records''' def __init__(self, klass, max=1): @@ -233,7 +247,7 @@ class Optional(object): super(Optional, self).__setattr__(attr, value) else: if self._guts and len(self._guts) > self._max: - raise ValueError, 'Only %d lines are allowed' % self._max + raise ValueError('Only %d lines are allowed' % self._max) newitem = self._klass() setattr(newitem, attr, value) self._guts.append(newitem) @@ -259,6 +273,7 @@ class Optional(object): '''Make sure to adapt''' return self._guts.__iter__() + class OrdersFile(object): '''A payment orders file''' def __init__(self, *args, **kwargs): @@ -271,18 +286,19 @@ class OrdersFile(object): ''' return '\r\n'.join(self.orders) + class Transaction(object): '''Generic transaction class''' def __init__(self, type_=0, name=None, reference=None, messages=[], accountno_beneficiary=None, accountno_payer=None, - amount=0 - ): + amount=0): self.transaction = TransactionRecord() self.paymentreference = Optional(PaymentReferenceRecord) self.description = Optional(DescriptionRecord, 4) self.transaction.transactiontype = type_ # Remove Postbank account marker 'P' - self.transaction.accountno_beneficiary = accountno_beneficiary.replace('P', '0') + self.transaction.accountno_beneficiary = accountno_beneficiary.replace( + 'P', '0') self.transaction.accountno_payer = accountno_payer.replace('P', '0') self.transaction.amount = int(round(amount * 100)) if reference: @@ -290,8 +306,7 @@ class Transaction(object): # Allow long message lines to redistribute over multiple message # records for msg in chunk(''.join(messages), - self.description.length('description') - ): + self.description.length('description')): try: self.description.description = msg except ValueError: @@ -321,13 +336,14 @@ class DirectDebit(Transaction): items.append(str(description)) return '\r\n'.join(items) + class Payment(Transaction): '''Payment transaction''' def __init__(self, *args, **kwargs): reknr = kwargs['accountno_beneficiary'] if len(reknr.lstrip('0')) > 7: if not eleven_test(reknr): - raise ValueError, '%s is not a valid bank account' % reknr + raise ValueError('%s is not a valid bank account' % reknr) kwargs['type_'] = 5 self.name = NameBeneficiaryRecord() super(Payment, self).__init__(*args, **kwargs) @@ -346,6 +362,7 @@ class Payment(Transaction): items.append(str(self.name)) return '\r\n'.join(items) + class SalaryPayment(Payment): '''Salary Payment transaction''' def __init__(self, *args, **kwargs): @@ -353,14 +370,14 @@ class SalaryPayment(Payment): kwargs['type_'] = len(reknr.lstrip('0')) <= 7 and 3 or 8 super(SalaryPayment, self).__init__(*args, **kwargs) + class Batch(object): '''Generic batch class''' transactionclass = None def __init__(self, sender, rekeningnr, execution_date=None, test=True, messages=[], transactiongroup=None, - batch_tracer=1, batch_id='' - ): + batch_tracer=1, batch_id=''): self.header = BatchHeaderRecord() self.fixed_message = Optional(FixedMessageRecord, 4) self.sender = SenderRecord() @@ -386,18 +403,16 @@ class Batch(object): @property def total_amount(self): '''total amount transferred''' - return reduce(lambda x,y: x + int(y.transaction.amount), - self.transactions, 0 - ) + return reduce(lambda x, y: x + int(y.transaction.amount), + self.transactions, 0) @property def total_accountnos(self): '''check number on account numbers''' - return reduce(lambda x,y: - x + int(y.transaction.accountno_payer) + \ - int(y.transaction.accountno_beneficiary), - self.transactions, 0 - ) + return reduce(lambda x, y: + x + int(y.transaction.accountno_payer) + + int(y.transaction.accountno_beneficiary), + self.transactions, 0) @property def rawdata(self): @@ -423,18 +438,22 @@ class Batch(object): self.transactions.append(retval) return retval + class DirectDebitBatch(Batch): '''Direct Debig Payment batch''' transactionclass = DirectDebit + class PaymentsBatch(Batch): '''Payment batch''' transactionclass = Payment + class SalaryBatch(Batch): '''Salary payment class''' transactionclass = SalaryPayment + class ClieOpFile(object): '''The grand unifying class''' def __init__(self, identification='1', execution_date=None, @@ -461,7 +480,7 @@ class ClieOpFile(object): def batch(self, *args, **kwargs): '''Create batch''' kwargs['transactiongroup'] = self.transactiongroup - kwargs['batch_tracer'] = len(self.batches) +1 + kwargs['batch_tracer'] = len(self.batches) + 1 kwargs['execution_date'] = self._execution_date kwargs['test'] = self._test args = (self._name_sender, self._accno_sender) @@ -489,22 +508,22 @@ class ClieOpFile(object): retval.total_accountnos = total_accountnos return retval + class DirectDebitFile(ClieOpFile): '''Direct Debit Payments file''' transactiongroup = '10' batchclass = DirectDebitBatch orderclass = DirectDebitOrder + class PaymentsFile(ClieOpFile): '''Payments file''' transactiongroup = '00' batchclass = PaymentsBatch orderclass = PaymentOrder + class SalaryPaymentsFile(PaymentsFile): '''Salary Payments file''' batchclass = SalaryBatch orderclass = SalaryPaymentOrder - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/account_banking_nl_clieop/wizard/export_clieop.py b/account_banking_nl_clieop/wizard/export_clieop.py index 915c46bb6..95d86f8de 100644 --- a/account_banking_nl_clieop/wizard/export_clieop.py +++ b/account_banking_nl_clieop/wizard/export_clieop.py @@ -6,8 +6,8 @@ # All Rights Reserved # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, @@ -21,7 +21,7 @@ ############################################################################## import base64 -from datetime import datetime, date, timedelta +from datetime import datetime, timedelta from openerp.osv import orm, fields from openerp.tools.translate import _ from openerp import netsvc @@ -29,14 +29,17 @@ from openerp.tools import DEFAULT_SERVER_DATE_FORMAT from openerp.addons.account_banking import sepa from openerp.addons.account_banking_nl_clieop.wizard import clieop + def strpdate(arg): '''shortcut''' return datetime.strptime(arg, DEFAULT_SERVER_DATE_FORMAT).date() + def strfdate(arg): '''shortcut''' return arg.strftime(DEFAULT_SERVER_DATE_FORMAT) + class banking_export_clieop_wizard(orm.TransientModel): _name = 'banking.export.clieop.wizard' _description = 'Client Opdrachten Export' @@ -67,10 +70,9 @@ class banking_export_clieop_wizard(orm.TransientModel): help=('This is the date the file should be processed by the bank. ' 'Don\'t choose a date beyond the nearest date in your ' 'payments. The latest allowed date is 30 days from now.\n' - 'Please keep in mind that banks only execute on working days ' - 'and typically use a delay of two days between execution date ' - 'and effective transfer date.' - ), + 'Please keep in mind that banks only execute on working ' + 'days and typically use a delay of two days between ' + 'execution date and effective transfer date.'), ), 'test': fields.boolean( 'Test Run', @@ -80,9 +82,8 @@ class banking_export_clieop_wizard(orm.TransientModel): ), 'fixed_message': fields.char( 'Fixed Message', size=32, - help=('A fixed message to apply to all transactions in addition to ' - 'the individual messages.' - ), + help=('A fixed message to apply to all transactions in addition ' + 'to the individual messages.'), ), # file fields 'file_id': fields.many2one( @@ -90,7 +91,7 @@ class banking_export_clieop_wizard(orm.TransientModel): 'ClieOp File', readonly=True ), - # fields.related does not seem to support + # fields.related does not seem to support # fields of type selection 'testcode': fields.selection( [('T', _('Yes')), ('P', _('No'))], @@ -175,7 +176,9 @@ class banking_export_clieop_wizard(orm.TransientModel): Also mind that rates for batches are way higher than those for transactions. It pays to limit the number of batches. ''' - today = strpdate(fields.date.context_today(self, cr, uid, context=context)) + today = strpdate(fields.date.context_today( + self, cr, uid, context=context + )) payment_order_obj = self.pool.get('payment.order') # Payment order ids are provided in the context @@ -199,12 +202,14 @@ class banking_export_clieop_wizard(orm.TransientModel): elif payment_order.date_prefered == 'now': execution_date = today elif payment_order.date_prefered == 'due': - # Max processing date is 30 days past now, so limiting beyond that - # will catch too early payments + # Max processing date is 30 days past now, so limiting beyond + # that will catch too early payments max_date = execution_date = today + timedelta(days=31) for line in payment_order.line_ids: if line.move_line_id.date_maturity: - date_maturity = strpdate(line.move_line_id.date_maturity) + date_maturity = strpdate( + line.move_line_id.date_maturity + ) if date_maturity < execution_date: execution_date = date_maturity else: @@ -212,7 +217,8 @@ class banking_export_clieop_wizard(orm.TransientModel): if execution_date and execution_date >= max_date: raise orm.except_orm( _('Error'), - _('You can\'t create ClieOp orders more than 30 days in advance.') + _('You can\'t create ClieOp orders more than 30 days ' + 'in advance.') ) if len(runs) != 1: raise orm.except_orm( @@ -233,17 +239,19 @@ class banking_export_clieop_wizard(orm.TransientModel): ''' Wizard to actually create the ClieOp3 file ''' - payment_order_obj = self.pool.get('payment.order') clieop_export = self.browse(cr, uid, ids, context)[0] clieopfile = None for payment_order in clieop_export.payment_order_ids: if not clieopfile: # Just once: create clieop file - our_account_owner = payment_order.mode.bank_id.owner_name \ - or payment_order.mode.bank_id.partner_id.name + our_account_owner = ( + payment_order.mode.bank_id.owner_name + or payment_order.mode.bank_id.partner_id.name + ) if payment_order.mode.bank_id.state == 'iban': - our_account_nr = payment_order.mode.bank_id.acc_number_domestic + our_account_nr = ( + payment_order.mode.bank_id.acc_number_domestic) if not our_account_nr: our_account_nr = sepa.IBAN( payment_order.mode.bank_id.acc_number @@ -253,21 +261,22 @@ class banking_export_clieop_wizard(orm.TransientModel): if not our_account_nr: raise orm.except_orm( _('Error'), - _('Your bank account has to have a valid account number') + _('Your bank account has to have a valid account ' + 'number') ) - clieopfile = {'CLIEOPPAY': clieop.PaymentsFile, - 'CLIEOPINC': clieop.DirectDebitFile, - 'CLIEOPSAL': clieop.SalaryPaymentsFile, - }[clieop_export['batchtype']]( - identification = clieop_export['reference'], - execution_date = clieop_export['execution_date'], - name_sender = our_account_owner, - accountno_sender = our_account_nr, - seqno = self.pool.get( - 'banking.export.clieop').get_daynr( - cr, uid, context=context), - test = clieop_export['test'] - ) + clieopfile = { + 'CLIEOPPAY': clieop.PaymentsFile, + 'CLIEOPINC': clieop.DirectDebitFile, + 'CLIEOPSAL': clieop.SalaryPaymentsFile, + }[clieop_export['batchtype']]( + identification=clieop_export['reference'], + execution_date=clieop_export['execution_date'], + name_sender=our_account_owner, + accountno_sender=our_account_nr, + seqno=self.pool.get('banking.export.clieop').get_daynr( + cr, uid, context=context), + test=clieop_export['test'] + ) # ClieOp3 files can contain multiple batches, but we put all # orders into one single batch. Ratio behind this is that a @@ -282,8 +291,8 @@ class banking_export_clieop_wizard(orm.TransientModel): # The first payment order processed sets the reference of the # batch. batch = clieopfile.batch( - messages = messages, - batch_id = clieop_export['reference'] + messages=messages, + batch_id=clieop_export['reference'] ) for line in payment_order.line_ids: @@ -294,12 +303,13 @@ class banking_export_clieop_wizard(orm.TransientModel): _('There is insufficient information.\r\n' 'Both destination address and account ' 'number must be provided' - ) + ) ) kwargs = dict( - name = line.bank_id.owner_name or line.bank_id.partner_id.name, - amount = line.amount_currency, - reference = line.communication or None, + name=line.bank_id.owner_name + or line.bank_id.partner_id.name, + amount=line.amount_currency, + reference=line.communication or None, ) if line.communication2: kwargs['messages'] = [line.communication2] @@ -324,32 +334,32 @@ class banking_export_clieop_wizard(orm.TransientModel): else: kwargs['accountno_beneficiary'] = other_account_nr kwargs['accountno_payer'] = our_account_nr - transaction = batch.transaction(**kwargs) + batch.transaction(**kwargs) # Generate the specifics of this clieopfile order = clieopfile.order file_id = self.pool.get('banking.export.clieop').create( cr, uid, dict( - filetype = order.name_transactioncode, - identification = order.identification, - prefered_date = strfdate(order.preferred_execution_date), - total_amount = int(order.total_amount) / 100.0, - check_no_accounts = order.total_accountnos, - no_transactions = order.nr_posts, - testcode = order.testcode, - file = base64.encodestring(clieopfile.rawdata), - filename = 'Clieop03-{0}.txt'.format(order.identification), - daynumber = int(clieopfile.header.file_id[2:]), - payment_order_ids = [ - [6, 0, [x.id for x in clieop_export['payment_order_ids']]] - ], - ), context) - self.write(cr, uid, [ids[0]], dict( - filetype = order.name_transactioncode, - testcode = order.testcode, - file_id = file_id, - state = 'finish', + filetype=order.name_transactioncode, + identification=order.identification, + prefered_date=strfdate(order.preferred_execution_date), + total_amount=int(order.total_amount) / 100.0, + check_no_accounts=order.total_accountnos, + no_transactions=order.nr_posts, + testcode=order.testcode, + file=base64.encodestring(clieopfile.rawdata), + filename='Clieop03-{0}.txt'.format(order.identification), + daynumber=int(clieopfile.header.file_id[2:]), + payment_order_ids=[ + [6, 0, [x.id + for x in clieop_export['payment_order_ids']]]], ), context) + self.write(cr, uid, [ids[0]], dict( + filetype=order.name_transactioncode, + testcode=order.testcode, + file_id=file_id, + state='finish', + ), context) return { 'name': _('Client Opdrachten Export'), 'view_type': 'form', @@ -367,7 +377,9 @@ class banking_export_clieop_wizard(orm.TransientModel): Cancel the ClieOp: just drop the file ''' clieop_export = self.read(cr, uid, ids, ['file_id'], context)[0] - self.pool.get('banking.export.clieop').unlink(cr, uid, clieop_export['file_id'][0]) + self.pool.get('banking.export.clieop').unlink( + cr, uid, clieop_export['file_id'][0] + ) return {'type': 'ir.actions.act_window_close'} def save_clieop(self, cr, uid, ids, context): @@ -378,11 +390,12 @@ class banking_export_clieop_wizard(orm.TransientModel): cr, uid, ids, context)[0] if not clieop_export['test']: clieop_obj = self.pool.get('banking.export.clieop') - payment_order_obj = self.pool.get('payment.order') - clieop_file = clieop_obj.write( + clieop_obj.write( cr, uid, clieop_export['file_id'].id, {'state': 'sent'} ) wf_service = netsvc.LocalService('workflow') for order in clieop_export['payment_order_ids']: - wf_service.trg_validate(uid, 'payment.order', order.id, 'sent', cr) + wf_service.trg_validate( + uid, 'payment.order', order.id, 'sent', cr + ) return {'type': 'ir.actions.act_window_close'}