[FIX]coda note with int not str, import wizard returns to banks statement tree
authordle@openerp.com <>
Fri, 7 Dec 2012 14:31:44 +0000 (15:31 +0100)
committerdle@openerp.com <>
Fri, 7 Dec 2012 14:31:44 +0000 (15:31 +0100)
bzr revid: dle@openerp.com-20121207143144-13vfmr4o37e1rntb

addons/l10n_be_coda/l10n_be_coda_wizard.xml
addons/l10n_be_coda/wizard/account_coda_import.py

index 427e0c1..92b16db 100644 (file)
       </field>
     </record>
 
-    <record id="account_coda_import_result_view" model="ir.ui.view">
-      <field name="name">Import CODA File</field>
-      <field name="model">account.coda.import</field>
-      <field name="priority">2</field>
-      <field name="arch" type="xml">
-        <form string="Import CODA File" version="7.0">
-          <header>
-              <button name="action_open_coda_statements" string="View CODA Bank Statement(s)" type="object" class="oe_highlight"/>
-              <button name="action_open_bank_statements" string="View Bank Statement(s)" type="object" class="oe_highlight"/>
-              or
-              <button string="Cancel" class="oe_link" special="cancel"/>
-          </header>
-          <group string="Results :">
-              <field name="note" nolabel="1" colspan="2"/>
-          </group>
-        </form>
-      </field>
-    </record>
-
     <record id="action_account_coda_import" model="ir.actions.act_window">
       <field name="name">Import CODA File</field>
       <field name="type">ir.actions.act_window</field>
index 9513d7a..1118f5a 100644 (file)
@@ -89,10 +89,10 @@ class account_coda_import(osv.osv_memory):
                         raise osv.except_osv(_('Error') + 'R1002', _('Foreign bank accounts with IBAN structure are not supported '))
                     else:  # Something else, not supported
                         raise osv.except_osv(_('Error') + 'R1003', _('Unsupported bank account structure '))
-                ids = self.pool.get('res.partner.bank').search(cr, uid, [('acc_number', '=', statement['acc_number'])])
+                bank_ids = self.pool.get('res.partner.bank').search(cr, uid, [('acc_number', '=', statement['acc_number'])])
                 not_found_except = osv.except_osv(_('Error') + 'R1004', _("No matching CODA Bank Account Configuration record found. Please check if the 'Bank Account Number' and 'Currency' fields of your configuration record match with '%s' and '%s'.") % (statement['acc_number'], statement['currency']))
-                if ids and len(ids) > 0:
-                    bank_accs = self.pool.get('res.partner.bank').browse(cr, uid, ids)
+                if bank_ids and len(bank_ids) > 0:
+                    bank_accs = self.pool.get('res.partner.bank').browse(cr, uid, bank_ids)
                     for bank_acc in bank_accs:
                         statement['journal_id'] = bank_acc.journal_id
                         if (statement['journal_id'].currency and statement['journal_id'].currency.name != statement['currency']) and (not statement['journal_id'].currency and statement['journal_id'].company_id.currency_id.name != statement['currency']):
@@ -246,9 +246,9 @@ class account_coda_import(osv.osv_memory):
                         line['transaction_family'] = transaction_family[0]
                         if line['transaction_code'] in transaction_family[1]:
                             line['transaction_code'] = transaction_family[1][line['transaction_code']]
-                    statement['coda_note'] = "\n".join([statement['coda_note'], line['type'].title() + ' #' + str(line['sequence']), 'Date: ' + str(line['entryDate']), 'Ref: ' + str(line['ref']), 'Communication: ' + line['communication'],'\n'])
+                    statement['coda_note'] = "\n".join([statement['coda_note'], line['type'].title() + ' #' + str(line['sequence']), 'Date: ' + str(line['entryDate']), 'Ref: ' + str(line['ref']), 'Communication: ' + line['communication'], '\n'])
                 elif line['type'] == 'communication':
-                    statement['coda_note'] = "\n".join([statement['coda_note'], line['type'].title() + ' #' + str(line['sequence']), 'Ref: ' + str(line['ref']), 'Communication: ' + line['communication'],'\n'])
+                    statement['coda_note'] = "\n".join([statement['coda_note'], line['type'].title() + ' #' + str(line['sequence']), 'Ref: ' + str(line['ref']), 'Communication: ' + line['communication'], '\n'])
                 elif line['type'] == 'normal':
                     note = []
                     if 'counterpartyName' in line and line['counterpartyName'] != '':
@@ -383,6 +383,14 @@ class account_coda_import(osv.osv_memory):
                     self.pool.get('account.bank.statement.line').create(cr, uid, data, context=context)
             if statement['coda_note'] != '':
                 self.pool.get('account.bank.statement').write(cr, uid, [statement['id']], {'coda_note': statement['coda_note']}, context=context)
+        return {
+            'view_type': 'form',
+            'view_mode': 'tree',
+            'res_model': 'account.bank.statement',
+            'view_id': False,
+            'context': context,
+            'type': 'ir.actions.act_window',
+        }
 account_coda_import()
 
 transaction_types = {