[RFR] Adapt NL Clieop module to API changes in 6.1

[FIX] Clieop export counter per day was always 1
This commit is contained in:
Stefan Rijnhart
2012-03-10 14:51:08 +01:00
parent 62ef884425
commit 6f4c8f0351
2 changed files with 34 additions and 21 deletions

View File

@@ -59,7 +59,7 @@ class clieop_export(osv.osv):
('INCASSO', 'Direct Debit Batch'),
], 'File Type', size=7, readonly=True, select=True),
'date_generated':
fields.datetime('Generation Date', readonly=True, select=True),
fields.date('Generation Date', readonly=True, select=True),
'file':
fields.binary('ClieOp File', readonly=True),
'state':
@@ -69,24 +69,26 @@ class clieop_export(osv.osv):
('done', 'Reconciled'),
], 'State', readonly=True),
}
def _get_daynr(self, cursor, uid, ids, context):
def get_daynr(self, cr, uid, context=None):
'''
Return highest day number
'''
last = cursor.execute('SELECT max(daynumber) '
'FROM banking_export_clieop '
'WHERE date_generated = "%s"' %
date.today().strftime('%Y-%m-%d')
).fetchone()
if last:
return int(last) +1
return 1
last = 1
last_ids = self.search(cr, uid, [
('date_generated', '=',
fields.date.context_today(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)])
return last
_defaults = {
'date_generated': lambda *a: date.today().strftime('%Y-%m-%d'),
'duplicates': lambda *a: 1,
'state': lambda *a: 'draft',
'daynumber': _get_daynr,
'date_generated': fields.date.context_today,
'duplicates': 1,
'state': 'draft',
'daynumber': get_daynr,
}
clieop_export()

View File

@@ -237,11 +237,15 @@ class banking_export_clieop_wizard(osv.osv_memory):
# 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_nr = payment_order.mode.bank_id.acc_number
if not our_account_nr and payment_order.mode.bank_id.iban:
our_account_nr = sepa.IBAN(
payment_order.mode.bank_id.iban
).localized_BBAN
if payment_order.mode.bank_id.state == 'iban':
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
).localized_BBAN
else:
our_account_nr = payment_order.mode.bank_id.acc_number
if not our_account_nr:
raise osv.except_osv(
_('Error'),
@@ -255,6 +259,9 @@ class banking_export_clieop_wizard(osv.osv_memory):
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(
cursor, uid, context=context),
test = clieop_export['test']
)
@@ -292,7 +299,11 @@ class banking_export_clieop_wizard(osv.osv_memory):
)
if line.communication2:
kwargs['messages'] = [line.communication2]
other_account_nr = line.bank_id.acc_number
other_account_nr = (
line.bank_id.state == 'iban' and
line.bank_id.acc_number_domestic or
line.bank_id.acc_number
)
iban = sepa.IBAN(other_account_nr)
# Is this an IBAN account?
if iban.valid:
@@ -351,7 +362,7 @@ class banking_export_clieop_wizard(osv.osv_memory):
Cancel the ClieOp: just drop the file
'''
clieop_export = self.read(cursor, uid, ids, ['file_id'], context)[0]
self.pool.get('banking.export.clieop').unlink(cursor, uid, clieop_export['file_id'])
self.pool.get('banking.export.clieop').unlink(cursor, uid, clieop_export['file_id'][0])
return {'type': 'ir.actions.act_window_close'}
def save_clieop(self, cursor, uid, ids, context):