From 6f4c8f0351feeae9dfd668fcd05111a90cfc5ee0 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Sat, 10 Mar 2012 14:51:08 +0100 Subject: [PATCH 1/4] [RFR] Adapt NL Clieop module to API changes in 6.1 [FIX] Clieop export counter per day was always 1 --- .../account_banking_nl_clieop.py | 30 ++++++++++--------- .../wizard/export_clieop.py | 25 +++++++++++----- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/account_banking_nl_clieop/account_banking_nl_clieop.py b/account_banking_nl_clieop/account_banking_nl_clieop.py index eae9a88e1..69fc306db 100644 --- a/account_banking_nl_clieop/account_banking_nl_clieop.py +++ b/account_banking_nl_clieop/account_banking_nl_clieop.py @@ -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() diff --git a/account_banking_nl_clieop/wizard/export_clieop.py b/account_banking_nl_clieop/wizard/export_clieop.py index 2088c8d98..36b00049c 100644 --- a/account_banking_nl_clieop/wizard/export_clieop.py +++ b/account_banking_nl_clieop/wizard/export_clieop.py @@ -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): From a128b23585e4b6c71a7c0c044fbaf0f0191c0181 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Sat, 14 Apr 2012 10:58:58 +0200 Subject: [PATCH 2/4] [FIX] Do not write obsolete field 'code' to res.bank [ADD] Write bic field to res.partner.bank when found [FIX] Super() called with wrong object name [FIX] Disable invalid xpath expression --- account_banking/account_banking.py | 9 +++++++-- account_banking/banking_import_transaction.py | 2 +- account_banking/data/account_banking_data.xml | 7 +++++++ account_banking/wizard/banktools.py | 1 + account_direct_debit/view/account_payment.xml | 12 +++++++----- account_iban_preserve_domestic/res_partner_bank.py | 3 --- 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/account_banking/account_banking.py b/account_banking/account_banking.py index 146e4c525..7d1c6092d 100644 --- a/account_banking/account_banking.py +++ b/account_banking/account_banking.py @@ -1142,6 +1142,9 @@ class res_partner_bank(osv.osv): def write(self, cr, uid, ids, vals, context=None): ''' Create dual function IBAN account for SEPA countries + + Update the domestic account number when the IBAN is + written, or clear the domestic number on regular account numbers. ''' if ids and isinstance(ids, (int, long)): ids = [ids] @@ -1149,7 +1152,7 @@ class res_partner_bank(osv.osv): cr, uid, ids, ['state', 'acc_number']): if 'state' in vals or 'acc_number' in vals: account.update(vals) - if 'state' in vals and vals['state'] == 'iban': + if account['state'] == 'iban': vals['acc_number'], vals['acc_number_domestic'] = ( self._correct_IBAN(account['acc_number'])) else: @@ -1361,12 +1364,14 @@ class res_partner_bank(osv.osv): bank_id, country_id = get_or_create_bank( self.pool, cursor, uid, info.bic or iban_acc.BIC_searchkey, - code = info.code, name = info.bank + name = info.bank ) values['country_id'] = country_id or \ country_ids and country_ids[0] or \ False values['bank'] = bank_id or False + if info.bic: + values['bank_bic'] = info.bic else: info = None if info is None: diff --git a/account_banking/banking_import_transaction.py b/account_banking/banking_import_transaction.py index a745934ad..89ac70143 100644 --- a/account_banking/banking_import_transaction.py +++ b/account_banking/banking_import_transaction.py @@ -1934,7 +1934,7 @@ class account_bank_statement_line(osv.osv): for line in self.browse(cr, uid, ids, context=context): if line.state == 'confirmed': raise osv.except_osv(_('Confirmed Statement Line'), _("You cannot delete a confirmed Statement Line: '%s'" % line.name)) - return super(account_bank_statement,self).unlink(cr, uid, ids, context=context) + return super(account_bank_statement_line,self).unlink(cr, uid, ids, context=context) account_bank_statement_line() diff --git a/account_banking/data/account_banking_data.xml b/account_banking/data/account_banking_data.xml index 87471c7f4..6a662268d 100644 --- a/account_banking/data/account_banking_data.xml +++ b/account_banking/data/account_banking_data.xml @@ -13,6 +13,13 @@ + + + + Manual Bank Transfer diff --git a/account_banking/wizard/banktools.py b/account_banking/wizard/banktools.py index 49ba3bf48..9cd3b014a 100644 --- a/account_banking/wizard/banktools.py +++ b/account_banking/wizard/banktools.py @@ -373,6 +373,7 @@ def create_bank_account(pool, cursor, uid, partner_id, if bic: values.bank = get_or_create_bank(pool, cursor, uid, bic)[0] + values.bank_bic = bic # Create bank account and return return pool.get('res.partner.bank').create(cursor, uid, values) diff --git a/account_direct_debit/view/account_payment.xml b/account_direct_debit/view/account_payment.xml index 1bb2b7847..1b559616a 100644 --- a/account_direct_debit/view/account_payment.xml +++ b/account_direct_debit/view/account_payment.xml @@ -12,7 +12,8 @@ payment.order form tree,form - {'search_payment_order_type': 'debit'} + {'search_payment_order_type': 'debit', + 'default_payment_order_type': 'debit'} [('payment_order_type', '=', 'debit')] A debit order is a debit request from your company to collect customer invoices. Here you can register all debit orders that should be done, keep track of all debit orders and mention the invoice reference and the partner the withdrawal should be done for. @@ -45,10 +46,11 @@ icon="gtk-find" /> - - - - + diff --git a/account_iban_preserve_domestic/res_partner_bank.py b/account_iban_preserve_domestic/res_partner_bank.py index 204a52cae..828bf70b0 100644 --- a/account_iban_preserve_domestic/res_partner_bank.py +++ b/account_iban_preserve_domestic/res_partner_bank.py @@ -7,6 +7,3 @@ class res_partner_bank(osv.osv): 'acc_number_domestic': fields.char( 'Domestic Account Number', size=64) } - -res_partner_bank() - From 4f554436c0dc090515853f87ccd6d6cde6aae680 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Mon, 16 Apr 2012 09:35:36 +0200 Subject: [PATCH 3/4] [FIX] check partner_id on statement line is defined before browsing further [FIX] translation typo --- account_banking/banking_import_transaction.py | 2 +- account_banking/i18n/nl.po | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/account_banking/banking_import_transaction.py b/account_banking/banking_import_transaction.py index e49f5960b..5b34fb072 100644 --- a/account_banking/banking_import_transaction.py +++ b/account_banking/banking_import_transaction.py @@ -1844,7 +1844,7 @@ class account_bank_statement_line(osv.osv): # Define the voucher voucher = { 'journal_id': st_line.statement_id.journal_id.id, - 'partner_id': st_line.partner_id.id, + 'partner_id': st_line.partner_id and st_line.partner_id.id, 'company_id': st_line.company_id.id, 'type':voucher_type, 'company_id': st_line.company_id.id, diff --git a/account_banking/i18n/nl.po b/account_banking/i18n/nl.po index 0eb6fdf61..34d19939e 100644 --- a/account_banking/i18n/nl.po +++ b/account_banking/i18n/nl.po @@ -1192,7 +1192,7 @@ msgstr "remote_owner_custno" #: view:account.banking.imported.file:0 #: field:account.banking.imported.file,log:0 msgid "Import Log" -msgstr "Impotlog" +msgstr "Importlog" #. module: account_banking #: field:banking.import.line,date:0 From d9c5b7ea06122f65eee4b6f3992966f471a31372 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Tue, 17 Apr 2012 12:58:38 +0200 Subject: [PATCH 4/4] [FIX] Assign False, not browse_null as empty value for new record --- account_banking/banking_import_transaction.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/account_banking/banking_import_transaction.py b/account_banking/banking_import_transaction.py index 5b34fb072..722e6cd49 100644 --- a/account_banking/banking_import_transaction.py +++ b/account_banking/banking_import_transaction.py @@ -1515,7 +1515,7 @@ class banking_import_transaction(osv.osv): stline_pool = self.pool.get('account.bank.statement.line') res = {} - + for transaction in self.browse(cr, uid, ids, context): if transaction.move_line_id: @@ -1844,7 +1844,7 @@ class account_bank_statement_line(osv.osv): # Define the voucher voucher = { 'journal_id': st_line.statement_id.journal_id.id, - 'partner_id': st_line.partner_id and st_line.partner_id.id, + 'partner_id': st_line.partner_id and st_line.partner_id.id or False, 'company_id': st_line.company_id.id, 'type':voucher_type, 'company_id': st_line.company_id.id,