← Back to team overview

banking-addons-team team mailing list archive

[Merge] lp:~ruchir.shukla/banking-addons/ba7.0-future-ui-improvement into lp:banking-addons

 

Ruchir Shukla has proposed merging lp:~ruchir.shukla/banking-addons/ba7.0-future-ui-improvement into lp:banking-addons.

Requested reviews:
  Banking Addons Core Editors (banking-addons-team)

For more details, see:
https://code.launchpad.net/~ruchir.shukla/banking-addons/ba7.0-future-ui-improvement/+merge/176898

Hello !

Here are UI improvement changes are decided. 
Only one this is missing that "Wizard form view in Pop-up not have 100% width and height"

-- 
https://code.launchpad.net/~ruchir.shukla/banking-addons/ba7.0-future-ui-improvement/+merge/176898
Your team Banking Addons Core Editors is requested to review the proposed merge of lp:~ruchir.shukla/banking-addons/ba7.0-future-ui-improvement into lp:banking-addons.
=== modified file 'account_banking/__init__.py'
--- account_banking/__init__.py	2012-01-16 16:15:55 +0000
+++ account_banking/__init__.py	2013-07-25 08:56:25 +0000
@@ -11,16 +11,16 @@
 #    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 General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking/__openerp__.py'
--- account_banking/__openerp__.py	2013-06-10 10:19:50 +0000
+++ account_banking/__openerp__.py	2013-07-25 08:56:25 +0000
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 ##############################################################################
 #
 #    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
@@ -8,50 +9,51 @@
 #
 #    All Rights Reserved
 #
-#    WARNING: This program as such is intended to be used by professional
-#    programmers who take the whole responsability of assessing all potential
-#    consequences resulting from its eventual inadequacies and bugs
-#    End users who are looking for a ready-to-use solution with commercial
-#    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 General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
+
 {
     'name': 'Account Banking',
     'version': '0.1.136',
-    'license': 'GPL-3',
+    'license': 'AGPL-3',
     'author': 'Banking addons community',
     'website': 'https://launchpad.net/banking-addons',
     'category': 'Banking addons',
-    'depends': ['base', 'account', 'base_iban', 'account_payment',
-                'account_iban_preserve_domestic'],
-    'init_xml': [],
-    'update_xml': [
+    'depends': [
+        'account_voucher',
+        'account_iban_preserve_domestic',
+        ],
+    'data': [
         'security/ir.model.access.csv',
         'data/account_banking_data.xml',
         'wizard/bank_import_view.xml',
         'account_banking_view.xml',
-        'account_banking_workflow.xml',
         'wizard/banking_transaction_wizard.xml',
         'wizard/link_partner.xml',
         'workflow/account_invoice.xml',
     ],
+<<<<<<< TREE
     'js': [
         'static/src/js/account_banking.js',
     ],
     'demo_xml': [],
+=======
+    'js': [
+        'static/src/js/account_banking.js',
+    ],
+>>>>>>> MERGE-SOURCE
     'external_dependencies': {
         'python' : ['BeautifulSoup'],
     },
@@ -110,6 +112,5 @@
       + No special configuration needed for the parsers, new parsers are
         recognized and made available at server (re)start.
     ''',
-    'active': False,
     'installable': True,
 }

=== modified file 'account_banking/account_banking.py'
--- account_banking/account_banking.py	2013-03-20 19:25:57 +0000
+++ account_banking/account_banking.py	2013-07-25 08:56:25 +0000
@@ -1,20 +1,24 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
 ##############################################################################
 #
 #    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
+#              (C) 2011 - 2013 Therp BV (<http://therp.nl>).
+#            
+#    All other contributions are (C) by their respective contributors
+#
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
@@ -57,20 +61,20 @@
     default behavior is to flag the orders as 'sent', not as 'done'.
     Rejected payments from the bank receive on import the status 'rejected'.
 '''
-import time
-import sepa
-from osv import osv, fields
-from tools.translate import _
-from wizard.banktools import get_or_create_bank
-import decimal_precision as dp
-import netsvc
-from openerp import SUPERUSER_ID
+
+from openerp.osv import orm, fields
+from openerp.tools.translate import _
+from openerp import netsvc, SUPERUSER_ID
+from openerp.addons.decimal_precision import decimal_precision as dp
+from openerp.addons.account_banking import sepa
+from openerp.addons.account_banking.wizard.banktools import get_or_create_bank
 
 def warning(title, message):
     '''Convenience routine'''
     return {'warning': {'title': title, 'message': message}}
 
-class account_banking_account_settings(osv.osv):
+
+class account_banking_account_settings(orm.Model):
     '''Default Journal for Bank Account'''
     _name = 'account.banking.account.settings'
     _description = __doc__
@@ -122,13 +126,6 @@
                  ),
         ),
 
-        #'multi_currency': fields.boolean(
-        #    'Multi Currency Bank Account', required=True,
-        #    help=('Select this if your bank account is able to handle '
-        #          'multiple currencies in parallel without coercing to '
-        #          'a single currency.'
-        #         ),
-        #),
     }
 
     def _default_company(self, cr, uid, context=None):
@@ -162,7 +159,8 @@
         if not company_id:
             company_id = self._default_company(cr, uid, context=context)
         partner_id = self.pool.get('res.company').read(
-            cr, uid, company_id, ['partner_id'], context=context)['partner_id'][0]
+            cr, uid, company_id, ['partner_id'],
+            context=context)['partner_id'][0]
         bank_ids = self.pool.get('res.partner.bank').search(
             cr, uid, [('partner_id', '=', partner_id)], context=context)
         return bank_ids and bank_ids[0] or False
@@ -177,7 +175,8 @@
             'res.partner', context=localcontext)
         return account_def and account_def.id or False
 
-    def _default_credit_account_id(self, cr, uid, context=None, company_id=False):
+    def _default_credit_account_id(
+            self, cr, uid, context=None, company_id=False):
         localcontext = context and context.copy() or {}
         localcontext['force_company'] = (
             company_id or self._default_company(cr, uid, context=context))
@@ -187,9 +186,9 @@
         return account_def and account_def.id or False
 
     def find(self, cr, uid, journal_id, partner_bank_id=False, context=None):
-        domain = [('journal_id','=',journal_id)]
+        domain = [('journal_id', '=', journal_id)]
         if partner_bank_id:
-            domain.append(('partner_bank_id','=',partner_bank_id))
+            domain.append(('partner_bank_id', '=', partner_bank_id))
         return self.search(cr, uid, domain, context=context)
 
     def onchange_partner_bank_id(
@@ -225,15 +224,22 @@
         'default_debit_account_id': _default_debit_account_id,
         'default_credit_account_id': _default_credit_account_id,
         'partner_bank_id': _default_partner_bank_id,
-        #'multi_currency': lambda *a: False,
     }
 account_banking_account_settings()
 
-class account_banking_imported_file(osv.osv):
+
+class account_banking_imported_file(orm.Model):
     '''Imported Bank Statements File'''
     _name = 'account.banking.imported.file'
     _description = __doc__
     _rec_name = 'date'
+        
+    def _get_file_name(self, cr, uid, ids, name, args, context={}):
+        ret_val = {}
+        for rec_id in ids:
+            ret_val[rec_id] = "{0}_{1}.txt".format(self._table, rec_id)
+        return ret_val
+    
     _columns = {
         'company_id': fields.many2one('res.company', 'Company',
                                       select=True, readonly=True
@@ -265,76 +271,18 @@
                                          'banking_id', 'Statements',
                                          readonly=False,
                                   ),
+        'file_name': fields.function(_get_file_name, method=True,
+                                 string="File Name", type="char",
+                                 size=256),
     }
     _defaults = {
-        'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
-        'user_id': lambda self, cursor, uid, context: uid,
+        'date': fields.date.context_today,
+        'user_id': lambda self, cr, uid, context: uid,
     }
 account_banking_imported_file()
 
-class payment_mode_type(osv.osv):
-    _name= 'payment.mode.type'
-    _description= 'Payment Mode Type'
-    _columns= {
-        'name': fields.char(
-            'Name', size=64, required=True,
-            help='Payment Type'
-            ),
-        'code': fields.char(
-            'Code', size=64, required=True,
-            help='Specify the Code for Payment Type'
-            ),
-        # Setting suitable_bank_types to required pending
-        # https://bugs.launchpad.net/openobject-addons/+bug/786845
-        'suitable_bank_types': fields.many2many(
-            'res.partner.bank.type',
-            'bank_type_payment_type_rel',
-            'pay_type_id','bank_type_id',
-            'Suitable bank types', required=True),
-        'ir_model_id': fields.many2one(
-            'ir.model', 'Payment wizard',
-            help=('Select the Payment Wizard for payments of this type. '
-                  'Leave empty for manual processing'),
-            domain=[('osv_memory', '=', True)],
-            ),
-        'payment_order_type': fields.selection(
-            [('payment', 'Payment'),('debit', 'Direct debit')],
-            'Payment order type', required=True,
-            ),
-    }
-
-    _defaults = {
-        'payment_order_type': lambda *a: 'payment',
-        }
-
-payment_mode_type()
-
-class payment_mode(osv.osv):
-    ''' Restoring the payment type from version 5,
-    used to select the export wizard (if any) '''
-    _inherit = "payment.mode"
-
-    def suitable_bank_types(self, cr, uid, payment_mode_id=None, context=None):
-        """ Reinstates functional code for suitable bank type filtering.
-        Current code in account_payment is disfunctional.
-        """
-        res = []
-        payment_mode = self.browse(
-            cr, uid, payment_mode_id, context)
-        if (payment_mode and payment_mode.type and
-            payment_mode.type.suitable_bank_types):
-            res = [type.code for type in payment_mode.type.suitable_bank_types]
-        return res
-
-    _columns = {
-        'type': fields.many2one(
-            'payment.mode.type', 'Payment type',
-            help='Select the Payment Type for the Payment Mode.'
-            ),
-        }
-payment_mode()
-
-class account_bank_statement(osv.osv):
+
+class account_bank_statement(orm.Model):
     '''
     Extensions from account_bank_statement:
         1. Removed period_id (transformed to optional boolean) - as it is no
@@ -347,45 +295,6 @@
     '''
     _inherit = 'account.bank.statement'
     _order = 'id'
-    _abf_others = []
-    _abf_others_loaded = False
-
-    def __init__(self, *args, **kwargs):
-        '''
-        See where we stand in the order of things
-        '''
-        super(account_bank_statement, self).__init__(*args, **kwargs)
-        if not self._abf_others_loaded:
-            self._abf_others_loaded = True
-            self._abf_others = [x for x in self.__class__.__mro__
-                                   if x.__module__.split('.')[0] not in [
-                                       'osv', 'account', 'account_banking',
-                                       '__builtin__'
-                                   ]
-                               ]
-
-    #def _currency(self, cursor, user, ids, name, args, context=None):
-    #    '''
-    #    Calculate currency from contained transactions
-    #    '''
-    #    res = {}
-    #    res_currency_obj = self.pool.get('res.currency')
-    #    res_users_obj = self.pool.get('res.users')
-    #    default_currency = res_users_obj.browse(cursor, user,
-    #            user, context=context).company_id.currency_id
-    #    for statement in self.browse(cursor, user, ids, context=context):
-    #        currency = statement.journal_id.currency
-    #        if not currency:
-    #            currency = default_currency
-    #        res[statement.id] = currency.id
-    #    currency_names = {}
-    #    for currency_id, currency_name in res_currency_obj.name_get(cursor,
-    #            user, res.values(), context=context):
-    #        currency_names[currency_id] = currency_name
-    #    for statement_id in res.keys():
-    #        currency_id = res[statement_id]
-    #        res[statement_id] = (currency_id, currency_names[currency_id])
-    #    return res
 
     _columns = {
         'period_id': fields.many2one('account.period', 'Period',
@@ -393,13 +302,10 @@
         'banking_id': fields.many2one('account.banking.imported.file',
                                      'Imported File', readonly=True,
                                      ),
-    #    'currency': fields.function(_currency, method=True, string='Currency',
-    #        type='many2one', relation='res.currency'),
     }
 
     _defaults = {
-        'period_id': lambda *a: False,
-    #    'currency': _currency,
+        'period_id': False,
     }
 
     def _check_company_id(self, cr, uid, ids, context=None):
@@ -408,283 +314,175 @@
         move of period_id to the statement line
         """
         for statement in self.browse(cr, uid, ids, context=context):
-            if (statement.period_id and
-                statement.company_id.id != statement.period_id.company_id.id):
-                return False
             for line in statement.line_ids:
                 if (line.period_id and
                     statement.company_id.id != line.period_id.company_id.id):
                     return False
-        return True
+                if not statement.period_id:
+                    statement.write({'period_id': line.period_id.id})
+        return super(account_bank_statement, self)._check_company_id(
+            cr, uid, ids, context=context)
     
     # Redefine the constraint, or it still refer to the original method
     _constraints = [
-        (_check_company_id, 'The journal and period chosen have to belong to the same company.', ['journal_id','period_id']),
-    ]
+        (_check_company_id,
+         'The journal and period chosen have to belong to the same company.',
+         ['journal_id','period_id']),
+        ]
 
-    def _get_period(self, cursor, uid, date, context=None):
+    def _get_period(self, cr, uid, date, context=None):
         '''
         Find matching period for date, not meant for _defaults.
         '''
         period_obj = self.pool.get('account.period')
-        periods = period_obj.find(cursor, uid, dt=date, context=context)
+        periods = period_obj.find(cr, uid, dt=date, context=context)
         return periods and periods[0] or False
 
-    #def compute(self, cursor, uid, ids, context=None):
-    #    '''
-    #    Compute start and end balance with mixed currencies.
-    #    '''
-    #    return None
+    def _prepare_move(
+            self, cr, uid, st_line, st_line_number, context=None):
+        """
+        Add the statement line's period to the move, overwriting
+        the period on the statement
+        """
+        res = super(account_bank_statement, self)._prepare_move(
+            cr, uid, st_line, st_line_number, context=context)
+        if context and context.get('period_id'):
+            res['period_id'] = context['period_id']
+        return res
+
+    def _prepare_move_line_vals(
+            self, cr, uid, st_line, move_id, debit, credit, currency_id=False,
+            amount_currency=False, account_id=False, analytic_id=False,
+            partner_id=False, context=None):
+        """
+        Add the statement line's period to the move lines, overwriting
+        the period on the statement
+        """
+        res = super(account_bank_statement, self)._prepare_move_line_vals(
+            cr, uid, st_line, move_id, debit, credit, currency_id=currency_id,
+            amount_currency=amount_currency, account_id=account_id,
+            analytic_id=analytic_id, partner_id=partner_id, context=context)
+        if context and context.get('period_id'):
+            res['period_id'] = context['period_id']
+        return res
 
     def create_move_from_st_line(self, cr, uid, st_line_id,
                                  company_currency_id, st_line_number,
                                  context=None):
-        # This is largely a copy of the original code in account
-        # Modifications are marked with AB
-        # Modifications by account_voucher are merged below.
-        # As there is no valid inheritance mechanism for large actions, this
-        # is the only option to add functionality to existing actions.
-        # WARNING: when the original code changes, this trigger has to be
-        # updated in sync.
-
         if context is None:
             context = {}
-        res_currency_obj = self.pool.get('res.currency')
         account_move_obj = self.pool.get('account.move')
         account_move_line_obj = self.pool.get('account.move.line')
         account_bank_statement_line_obj = self.pool.get(
             'account.bank.statement.line')
         st_line = account_bank_statement_line_obj.browse(
             cr, uid, st_line_id, context=context)
+
+        # Take period from statement line and write to context
+        # this will be picked up by the _prepare_move* methods
         period_id = self._get_period(
-            cr, uid, st_line.date, context=context)    # AB
-        # Start account voucher
-        # Post the voucher and update links between statement and moves
+            cr, uid, st_line.date, context=context)
+        localctx = context.copy()
+        localctx['period_id'] = period_id
+
+        # Write date & period on the voucher, delegate to account_voucher's
+        # override of this method. Then post the related move and return.
         if st_line.voucher_id:
             voucher_pool = self.pool.get('account.voucher')
-            wf_service = netsvc.LocalService("workflow")
             voucher_pool.write(
                 cr, uid, [st_line.voucher_id.id], {
-                    'number': st_line_number,
                     'date': st_line.date,
-                    'period_id': period_id, # AB
+                    'period_id': period_id,
                 }, context=context)
-            if st_line.voucher_id.state == 'cancel':
-                voucher_pool.action_cancel_draft(
-                    cr, uid, [st_line.voucher_id.id], context=context)
-            wf_service.trg_validate(
-                uid, 'account.voucher', st_line.voucher_id.id, 'proforma_voucher', cr)
-            v = voucher_pool.browse(
-                cr, uid, st_line.voucher_id.id, context=context)
-            account_bank_statement_line_obj.write(cr, uid, [st_line_id], {
-                    'move_ids': [(4, v.move_id.id, False)]
-                    })
-            account_move_line_obj.write(
-                cr, uid, [x.id for x in v.move_ids],
-                {'statement_id': st_line.statement_id.id}, context=context)
-            # End of account_voucher
-            st_line.refresh()
-
-            # AB: The voucher journal isn't automatically posted, so post it (if needed)
+
+        res = super(account_bank_statement, self).create_move_from_st_line(
+            cr, uid, st_line_id, company_currency_id, st_line_number,
+            context=localctx)
+
+        st_line.refresh()
+        if st_line.voucher_id:
             if not st_line.voucher_id.journal_id.entry_posted:
-                account_move_obj.post(cr, uid, [st_line.voucher_id.move_id.id], context={})
-            return True
-
-        st = st_line.statement_id
-
-        context.update({'date': st_line.date})
-        ctxt = context.copy()                       # AB
-        ctxt['company_id'] = st_line.company_id.id  # AB
-
-        move_id = account_move_obj.create(cr, uid, {
-            'journal_id': st.journal_id.id,
-            'period_id': period_id, # AB
-            'date': st_line.date,
-            'name': st_line_number,
-        }, context=context)
-        account_bank_statement_line_obj.write(cr, uid, [st_line.id], {
-            'move_ids': [(4, move_id, False)]
-        })
-
-        torec = []
-        if st_line.amount >= 0:
-            account_id = st.journal_id.default_credit_account_id.id
+                account_move_obj.post(
+                    cr, uid, [st_line.voucher_id.move_id.id], context={})
         else:
-            account_id = st.journal_id.default_debit_account_id.id
-
-        acc_cur = ((st_line.amount <= 0 and
-                    st.journal_id.default_debit_account_id) or
-                   st_line.account_id)
-        context.update({
-                'res.currency.compute.account': acc_cur,
-            })
-        amount = res_currency_obj.compute(cr, uid, st.currency.id,
-                company_currency_id, st_line.amount, context=context)
-
-        val = {
-            'name': st_line.name,
-            'date': st_line.date,
-            'ref': st_line.ref,
-            'move_id': move_id,
-            'partner_id': (((st_line.partner_id) and st_line.partner_id.id) or
-                           False),
-            'account_id': (st_line.account_id) and st_line.account_id.id,
-            'credit': ((amount>0) and amount) or 0.0,
-            'debit': ((amount<0) and -amount) or 0.0,
-            'statement_id': st.id,
-            'journal_id': st.journal_id.id,
-            'period_id': period_id, # AB
-            'currency_id': st.currency.id,
-            'analytic_account_id': (st_line.analytic_account_id and
-                                    st_line.analytic_account_id.id or
-                                    False),
-        }
-
-        if st.currency.id <> company_currency_id:
-            amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
-                        st.currency.id, amount, context=context)
-            val['amount_currency'] = -amount_cur
-
-        if (st_line.account_id and st_line.account_id.currency_id and
-            st_line.account_id.currency_id.id <> company_currency_id):
-            val['currency_id'] = st_line.account_id.currency_id.id
-            amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
-                    st_line.account_id.currency_id.id, amount, context=context)
-            val['amount_currency'] = -amount_cur
-
-        move_line_id = account_move_line_obj.create(
-            cr, uid, val, context=context)
-        torec.append(move_line_id)
-
-        # Fill the secondary amount/currency
-        # if currency is not the same than the company
-        amount_currency = False
-        currency_id = False
-        if st.currency.id <> company_currency_id:
-            amount_currency = st_line.amount
-            currency_id = st.currency.id
-        account_move_line_obj.create(cr, uid, {
-            'name': st_line.name,
-            'date': st_line.date,
-            'ref': st_line.ref,
-            'move_id': move_id,
-            'partner_id': (((st_line.partner_id) and st_line.partner_id.id) or
-                           False),
-            'account_id': account_id,
-            'credit': ((amount < 0) and -amount) or 0.0,
-            'debit': ((amount > 0) and amount) or 0.0,
-            'statement_id': st.id,
-            'journal_id': st.journal_id.id,
-            'period_id': period_id, # AB
-            'amount_currency': amount_currency,
-            'currency_id': currency_id,
-            }, context=context)
-
-        for line in account_move_line_obj.browse(cr, uid, [x.id for x in
-                account_move_obj.browse(cr, uid, move_id,
-                    context=context).line_id],
-                context=context):
-            if line.state <> 'valid':
-                raise osv.except_osv(_('Error !'),
-                        _('Journal Item "%s" is not valid') % line.name)
-
-        # Bank statements will not consider boolean on journal entry_posted
-        account_move_obj.post(cr, uid, [move_id], context=context)
-        
-        """
-        Account-banking:
-        - Write stored reconcile_id
-        - Pay invoices through workflow 
-
-        Does not apply to voucher integration, but only to
-        payments and payment orders
-        """
-        if st_line.reconcile_id:
-            account_move_line_obj.write(cr, uid, torec, {
-                    (st_line.reconcile_id.line_partial_ids and 
-                     'reconcile_partial_id' or 'reconcile_id'): 
-                    st_line.reconcile_id.id }, context=context)
-            for move_line in (st_line.reconcile_id.line_id or []) + (
-                st_line.reconcile_id.line_partial_ids or []):
-                netsvc.LocalService("workflow").trg_trigger(
-                    uid, 'account.move.line', move_line.id, cr)
-        #""" End account-banking """
-
-        return move_id
+            # Write stored reconcile_id and pay invoices through workflow 
+            if st_line.reconcile_id:
+                move_ids = [move.id for move in st_line.move_ids]
+                torec = account_move_line_obj.search(
+                    cr, uid, [
+                        ('move_id', 'in', move_ids),
+                        ('account_id', '=', st_line.account_id.id)],
+                    context=context)
+                account_move_line_obj.write(cr, uid, torec, {
+                        (st_line.reconcile_id.line_partial_ids and 
+                         'reconcile_partial_id' or 'reconcile_id'): 
+                        st_line.reconcile_id.id }, context=context)
+                for move_line in (st_line.reconcile_id.line_id or []) + (
+                    st_line.reconcile_id.line_partial_ids or []):
+                    netsvc.LocalService("workflow").trg_trigger(
+                        uid, 'account.move.line', move_line.id, cr)
+        return res
 
     def button_confirm_bank(self, cr, uid, ids, context=None):
-        if context is None: context = {}
+        """
+        Assign journal sequence to statements without a name
+        """
+        if context is None:
+            context = {}
         obj_seq = self.pool.get('ir.sequence')
-        if not isinstance(ids, list): ids = [ids]
-        noname_ids = self.search(cr, uid, [('id','in',ids),('name','=','/')])
+        if ids and isinstance(ids, (int, long)):
+            ids = [ids]
+        noname_ids = self.search(
+            cr, uid, [('id', 'in', ids),('name', '=', '/')],
+            context=context)
         for st in self.browse(cr, uid, noname_ids, context=context):
-                if st.journal_id.sequence_id:
-                    year = self.pool.get('account.period').browse(cr, uid, self._get_period(cr, uid, st.date)).fiscalyear_id.id
-                    c = {'fiscalyear_id': year}
-                    st_number = obj_seq.get_id(cr, uid, st.journal_id.sequence_id.id, context=c)
-                    self.write(cr, uid, ids, {'name': st_number})
+            if st.journal_id.sequence_id:
+                period_id = self._get_period(cr, uid, st.date)
+                year = self.pool.get('account.period').browse(
+                    cr, uid, period_id, context=context).fiscalyear_id.id
+                c = {'fiscalyear_id': year}
+                st_number = obj_seq.get_id(
+                    cr, uid, st.journal_id.sequence_id.id, context=c)
+                self.write(
+                    cr, uid, ids, {'name': st_number}, context=context)
         
-        return super(account_bank_statement, self).button_confirm_bank(cr, uid, ids, context)
+        return super(account_bank_statement, self).button_confirm_bank(
+            cr, uid, ids, context)
 
 account_bank_statement()
 
-class account_voucher(osv.osv):
+
+class account_voucher(orm.Model):
     _inherit = 'account.voucher'
 
     def _get_period(self, cr, uid, context=None):
-        if context is None: context = {}
+        if context is None:
+            context = {}
         if not context.get('period_id') and context.get('move_line_ids'):
-            res = self.pool.get('account.move.line').browse(cr, uid , context.get('move_line_ids'))[0].period_id.id
-            context['period_id'] = res
+            return self.pool.get('account.move.line').browse(
+                cr, uid , context.get('move_line_ids'), context=context)[0].period_id.id
         return super(account_voucher, self)._get_period(cr, uid, context)
 
-    def create(self, cr, uid, values, context=None):
-        if values.get('period_id') == False and context.get('move_line_ids'):
-            values['period_id'] = self._get_period(cr, uid, context)
-        return super(account_voucher, self).create(cr, uid, values, context)
-
 account_voucher()
 
-class account_bank_statement_line(osv.osv):
+
+class account_bank_statement_line(orm.Model):
     '''
     Extension on basic class:
         1. Extra links to account.period and res.partner.bank for tracing and
            matching.
         2. Extra 'trans' field to carry the transaction id of the bank.
-        3. Extra 'international' flag to indicate the missing of a remote
-           account number. Some banks use seperate international banking
-           modules that do not integrate with the standard transaction files.
-        4. Readonly states for most fields except when in draft.
+        3. Readonly states for most fields except when in draft.
     '''
     _inherit = 'account.bank.statement.line'
     _description = 'Bank Transaction'
 
-    def _get_period(self, cursor, user, context=None):
+    def _get_period(self, cr, uid, context=None):
         date = context.get('date', None)
-        periods = self.pool.get('account.period').find(cursor, user, dt=date)
+        periods = self.pool.get('account.period').find(cr, uid, dt=date)
         return periods and periods[0] or False
 
-    def _seems_international(self, cursor, user, context=None):
-        '''
-        Some banks have seperate international banking modules which do not
-        translate correctly into the national formats. Instead, they
-        leave key fields blank and signal this anomaly with a special
-        transfer type.
-        With the introduction of SEPA, this may worsen greatly, as SEPA
-        payments are considered to be analogous to international payments
-        by most local formats.
-        '''
-        # Quick and dirty check: if remote bank account is missing, assume
-        # international transfer
-        return not (
-            context.get('partner_bank_id') and context['partner_bank_id']
-        )
-        # Not so dirty check: check if partner_id is set. If it is, check the
-        # default/invoice addresses country. If it is the same as our
-        # company's, its local, else international.
-        # TODO: to be done
-
-    def _get_currency(self, cursor, user, context=None):
+    def _get_currency(self, cr, uid, context=None):
         '''
         Get the default currency (required to allow other modules to function,
         which assume currency to be a calculated field and thus optional)
@@ -692,33 +490,9 @@
         which is inaccessible from within this method.
         '''
         res_users_obj = self.pool.get('res.users')
-        return res_users_obj.browse(cursor, user, user,
+        return res_users_obj.browse(cr, uid, uid,
                 context=context).company_id.currency_id.id
 
-    #def _reconcile_amount(self, cursor, user, ids, name, args, context=None):
-    #    '''
-    #    Redefinition from the original: don't use the statements currency, but
-    #    the transactions currency.
-    #    '''
-    #    if not ids:
-    #        return {}
-
-    #    res_currency_obj = self.pool.get('res.currency')
-    #    res_users_obj = self.pool.get('res.users')
-
-    #    res = {}
-    #    company_currency_id = res_users_obj.browse(cursor, user, user,
-    #            context=context).company_id.currency_id.id
-
-    #    for line in self.browse(cursor, user, ids, context=context):
-    #        if line.reconcile_id:
-    #            res[line.id] = res_currency_obj.compute(cursor, user,
-    #                    company_currency_id, line.currency.id,
-    #                    line.reconcile_id.total_entry, context=context)
-    #        else:
-    #            res[line.id] = 0.0
-    #    return res
-
     def _get_invoice_id(self, cr, uid, ids, name, args, context=None):
         res = {}
         for st_line in self.browse(cr, uid, ids, context):
@@ -736,7 +510,7 @@
         return res
 
     _columns = {
-        # Redefines
+        # Redefines. Todo: refactor away to view attrs
         'amount': fields.float('Amount', readonly=True,
                             digits_compute=dp.get_precision('Account'),
                             states={'draft': [('readonly', False)]}),
@@ -746,8 +520,6 @@
                             states={'draft': [('readonly', False)]}),
         'date': fields.date('Date', required=True, readonly=True,
                             states={'draft': [('readonly', False)]}),
-        #'reconcile_amount': fields.function(_reconcile_amount,
-        #    string='Amount reconciled', method=True, type='float'),
 
         # New columns
         'trans': fields.char('Bank Transaction ID', size=15, required=False,
@@ -762,12 +534,6 @@
                             states={'confirmed': [('readonly', True)]}),
         'currency': fields.many2one('res.currency', 'Currency', required=True,
                             states={'confirmed': [('readonly', True)]}),
-
-        # Not used yet, but usefull in the future.
-        'international': fields.boolean('International Transaction',
-                            required=False,
-                            states={'confirmed': [('readonly', True)]},
-                            ),
         'reconcile_id': fields.many2one(
             'account.move.reconcile', 'Reconciliation', readonly=True
             ),
@@ -779,427 +545,13 @@
 
     _defaults = {
         'period_id': _get_period,
-        'international': _seems_international,
         'currency': _get_currency,
     }
 
 account_bank_statement_line()
 
-class payment_line(osv.osv):
-    '''
-    Add extra export_state and date_done fields; make destination bank account
-    mandatory, as it makes no sense to send payments into thin air.
-    Edit: Payments can be by cash too, which is prohibited by mandatory bank
-    accounts.
-    '''
-    _inherit = 'payment.line'
-    _columns = {
-        # New fields
-        'export_state': fields.selection([
-            ('draft', 'Draft'),
-            ('open','Confirmed'),
-            ('cancel','Cancelled'),
-            ('sent', 'Sent'),
-            ('rejected', 'Rejected'),
-            ('done','Done'),
-            ], 'State', select=True
-        ),
-        'msg': fields.char('Message', size=255, required=False, readonly=True),
-
-        # Redefined fields: added states
-        'date_done': fields.datetime('Date Confirmed', select=True,
-                                     readonly=True),
-        'name': fields.char(
-            'Your Reference', size=64, required=True,
-            states={
-                'sent': [('readonly', True)],
-                'rejected': [('readonly', True)],
-                'done': [('readonly', True)]
-            },
-        ),
-        'communication': fields.char(
-            'Communication', size=64, required=False, 
-            help=("Used as the message between ordering customer and current "
-                  "company. Depicts 'What do you want to say to the recipient"
-                  " about this order ?'"
-                 ),
-            states={
-                'sent': [('readonly', True)],
-                'rejected': [('readonly', True)],
-                'done': [('readonly', True)]
-            },
-        ),
-        'communication2': fields.char(
-            'Communication 2', size=128,
-            help='The successor message of Communication.',
-            states={
-                'sent': [('readonly', True)],
-                'rejected': [('readonly', True)],
-                'done': [('readonly', True)]
-            },
-        ),
-        'move_line_id': fields.many2one(
-            'account.move.line', 'Entry line',
-            domain=[('reconcile_id','=', False),
-                    ('account_id.type', '=','payable')
-                   ],
-            help=('This Entry Line will be referred for the information of '
-                  'the ordering customer.'
-                 ),
-            states={
-                'sent': [('readonly', True)],
-                'rejected': [('readonly', True)],
-                'done': [('readonly', True)]
-            },
-        ),
-        'amount_currency': fields.float(
-            'Amount in Partner Currency', digits=(16,2),
-            required=True,
-            help='Payment amount in the partner currency',
-            states={
-                'sent': [('readonly', True)],
-                'rejected': [('readonly', True)],
-                'done': [('readonly', True)]
-            },
-        ),
-        'currency': fields.many2one(
-            'res.currency', 'Partner Currency', required=True,
-            states={
-                'sent': [('readonly', True)],
-                'rejected': [('readonly', True)],
-                'done': [('readonly', True)]
-            },
-        ),
-        'bank_id': fields.many2one(
-            'res.partner.bank', 'Destination Bank account',
-            states={
-                'sent': [('readonly', True)],
-                'rejected': [('readonly', True)],
-                'done': [('readonly', True)]
-            },
-        ),
-        'order_id': fields.many2one(
-            'payment.order', 'Order', required=True,
-            ondelete='cascade', select=True,
-            states={
-                'sent': [('readonly', True)],
-                'rejected': [('readonly', True)],
-                'done': [('readonly', True)]
-            },
-        ),
-        'partner_id': fields.many2one(
-            'res.partner', string="Partner", required=True,
-            help='The Ordering Customer',
-            states={
-                'sent': [('readonly', True)],
-                'rejected': [('readonly', True)],
-                'done': [('readonly', True)]
-            },
-        ),
-        'date': fields.date(
-            'Payment Date',
-            help=("If no payment date is specified, the bank will treat this "
-                  "payment line directly"
-                 ),
-            states={
-                'sent': [('readonly', True)],
-                'rejected': [('readonly', True)],
-                'done': [('readonly', True)]
-            },
-        ),
-        'state': fields.selection([
-            ('normal','Free'),
-            ('structured','Structured')
-            ], 'Communication Type', required=True,
-            states={
-                'sent': [('readonly', True)],
-                'rejected': [('readonly', True)],
-                'done': [('readonly', True)]
-            },
-        ),
-    }
-    _defaults = {
-        'export_state': lambda *a: 'draft',
-        'date_done': lambda *a: False,
-        'msg': lambda *a: '',
-    }
-
-    def fields_get(self, cr, uid, fields=None, context=None):
-        res = super(payment_line, self).fields_get(cr, uid, fields, context)
-        if 'communication' in res:
-            res['communication'].setdefault('states', {})
-            res['communication']['states']['structured'] = [('required', True)]
-        if 'communication2' in res:
-            res['communication2'].setdefault('states', {})
-            res['communication2']['states']['structured'] = [('readonly', True)]
-            res['communication2']['states']['normal'] = [('readonly', False)]
-
-        return res
-
-    """
-    Hooks for processing direct debit orders, such as implemented in
-    account_direct_debit module.
-    """
-    def get_storno_account_id(self, cr, uid, payment_line_id, amount,
-                     currency_id, context=None):
-        """
-        Hook for verifying a match of the payment line with the amount.
-        Return the account associated with the storno.
-        Used in account_banking interactive mode
-        :param payment_line_id: the single payment line id
-        :param amount: the (signed) amount debited from the bank account
-        :param currency: the bank account's currency *browse object*
-        :return: an account if there is a full match, False otherwise
-        :rtype: database id of an account.account resource.
-        """
-
-        return False
-
-    def debit_storno(self, cr, uid, payment_line_id, amount,
-                     currency_id, storno_retry=True, context=None):
-        """
-        Hook for handling a canceled item of a direct debit order.
-        Presumably called from a bank statement import routine.
-
-        Decide on the direction that the invoice's workflow needs to take.
-        You may optionally return an incomplete reconcile for the caller
-        to reconcile the now void payment.
-
-        :param payment_line_id: the single payment line id
-        :param amount: the (negative) amount debited from the bank account
-        :param currency: the bank account's currency *browse object*
-        :param boolean storno_retry: whether the storno is considered fatal \
-        or not.
-        :return: an incomplete reconcile for the caller to fill
-        :rtype: database id of an account.move.reconcile resource.
-        """
-
-        return False
-
-payment_line()
-
-class payment_order(osv.osv):
-    '''
-    Enable extra states for payment exports
-    '''
-    _inherit = 'payment.order'
-
-    _columns = {
-        'date_scheduled': fields.date(
-            'Scheduled date if fixed',
-            states={
-                'sent': [('readonly', True)],
-                'rejected': [('readonly', True)],
-                'done': [('readonly', True)]
-            },
-            help='Select a date if you have chosen Preferred Date to be fixed.'
-        ),
-        'reference': fields.char(
-            'Reference', size=128, required=True,
-            states={
-                'sent': [('readonly', True)],
-                'rejected': [('readonly', True)],
-                'done': [('readonly', True)]
-            },
-        ),
-        'mode': fields.many2one(
-            'payment.mode', 'Payment mode', select=True, required=True,
-            states={
-                'sent': [('readonly', True)],
-                'rejected': [('readonly', True)],
-                'done': [('readonly', True)]
-            },
-            help='Select the Payment Mode to be applied.',
-        ),
-        'state': fields.selection([
-            ('draft', 'Draft'),
-            ('open','Confirmed'),
-            ('cancel','Cancelled'),
-            ('sent', 'Sent'),
-            ('rejected', 'Rejected'),
-            ('done','Done'),
-            ], 'State', select=True
-        ),
-        'line_ids': fields.one2many(
-            'payment.line', 'order_id', 'Payment lines',
-            states={
-                'sent': [('readonly', True)],
-                'rejected': [('readonly', True)],
-                'done': [('readonly', True)]
-            },
-        ),
-        'user_id': fields.many2one(
-            'res.users','User', required=True,
-            states={
-                'sent': [('readonly', True)],
-                'rejected': [('readonly', True)],
-                'done': [('readonly', True)]
-            },
-        ),
-        'date_prefered': fields.selection([
-            ('now', 'Directly'),
-            ('due', 'Due date'),
-            ('fixed', 'Fixed date')
-            ], "Preferred date", change_default=True, required=True,
-            states={
-                'sent': [('readonly', True)],
-                'rejected': [('readonly', True)],
-                'done': [('readonly', True)]
-            },
-            help=("Choose an option for the Payment Order:'Fixed' stands for a "
-                  "date specified by you.'Directly' stands for the direct "
-                  "execution.'Due date' stands for the scheduled date of "
-                  "execution."
-                 )
-            ),
-        'payment_order_type': fields.selection(
-            [('payment', 'Payment'),('debit', 'Direct debit')],
-            'Payment order type', required=True,
-            ),
-        'date_sent': fields.date('Send date', readonly=True),
-    }
-
-    _defaults = {
-        'payment_order_type': lambda *a: 'payment',
-        }
-
-    def launch_wizard(self, cr, uid, ids, context=None):
-        """
-        Search for a wizard to launch according to the type.
-        If type is manual. just confirm the order.
-        Previously (pre-v6) in account_payment/wizard/wizard_pay.py
-        """
-        if context == None:
-            context = {}
-        result = {}
-        orders = self.browse(cr, uid, ids, context)
-        order = orders[0]
-        # check if a wizard is defined for the first order
-        if order.mode.type and order.mode.type.ir_model_id:
-            context['active_ids'] = ids
-            wizard_model = order.mode.type.ir_model_id.model
-            wizard_obj = self.pool.get(wizard_model)
-            wizard_id = wizard_obj.create(cr, uid, {}, context)
-            result = {
-                'name': wizard_obj._description or 'Payment Order Export',
-                'view_type': 'form',
-                'view_mode': 'form',
-                'res_model': wizard_model,
-                'domain': [],
-                'context': context,
-                'type': 'ir.actions.act_window',
-                'target': 'new',
-                'res_id': wizard_id,
-                'nodestroy': True,
-                }
-        else:
-            # should all be manual orders without type or wizard model
-            for order in orders[1:]:
-                if order.mode.type and order.mode.type.ir_model_id:
-                    raise osv.except_osv(
-                        _('Error'),
-                        _('You can only combine payment orders of the same type')
-                        )
-            # process manual payments
-            wf_service = netsvc.LocalService('workflow')
-            for order_id in ids:
-                wf_service.trg_validate(uid, 'payment.order', order_id, 'sent', cr)
-        return result
-
-    def _write_payment_lines(self, cursor, uid, ids, **kwargs):
-        '''
-        ORM method for setting attributes of corresponding payment.line objects.
-        Note that while this is ORM compliant, it is also very ineffecient due
-        to the absence of filters on writes and hence the requirement to
-        filter on the client(=OpenERP server) side.
-        '''
-        if not hasattr(ids, '__iter__'):
-            ids = [ids]
-        payment_line_obj = self.pool.get('payment.line')
-        line_ids = payment_line_obj.search(
-            cursor, uid, [
-                ('order_id', 'in', ids)
-            ])
-        payment_line_obj.write(cursor, uid, line_ids, kwargs)
-
-    def set_to_draft(self, cursor, uid, ids, *args):
-        '''
-        Set both self and payment lines to state 'draft'.
-        '''
-        self._write_payment_lines(cursor, uid, ids, export_state='draft')
-        return super(payment_order, self).set_to_draft(
-            cursor, uid, ids, *args
-        )
-
-    def action_sent(self, cursor, uid, ids, *args):
-        '''
-        Set both self and payment lines to state 'sent'.
-        '''
-        self._write_payment_lines(cursor, uid, ids, export_state='sent')
-        self.write(cursor, uid, ids, {'state':'sent',
-                                      'date_sent': time.strftime('%Y-%m-%d')})
-        return True
-
-    def action_rejected(self, cursor, uid, ids, *args):
-        '''
-        Set both self and payment lines to state 'rejected'.
-        '''
-        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)
-        return True
-
-    def set_done(self, cursor, uid, ids, *args):
-        '''
-        Extend standard transition to update children as well.
-        '''
-        self._write_payment_lines(cursor, uid, ids,
-                                  export_state='done',
-                                  date_done=time.strftime('%Y-%m-%d')
-                                 )
-        return super(payment_order, self).set_done(
-            cursor, uid, ids, *args
-        )
-
-    def get_wizard(self, type):
-        '''
-        Intercept manual bank payments to include 'sent' state. Default
-        'manual' payments are flagged 'done' immediately.
-        '''
-        if type == 'BANKMAN':
-            # Note that self._module gets overwritten by inheriters, so make
-            # the module name hard coded.
-            return 'account_banking', 'wizard_account_banking_payment_manual'
-        return super(payment_order, self).get_wizard(type)
-
-    """
-    Hooks for processing direct debit orders, such as implemented in
-    account_direct_debit module.
-    """
-    def debit_reconcile_transfer(
-        self, cr, uid, payment_order_id, amount, currency, context=None):
-        """
-        Reconcile the payment order if the amount is correct. Return the 
-        id of the reconciliation.
-        """
-        raise osv.except_osv(
-            _("Cannot reconcile"),
-            _("Cannot reconcile debit order: "+
-              "Not implemented."))
-
-    def debit_unreconcile_transfer(
-        self, cr, uid, payment_order_id, reconcile_id, amount, currency,
-        context=None):
-        """ Unreconcile the payment_order if at all possible """
-        raise osv.except_osv(
-            _("Cannot unreconcile"),
-            _("Cannot unreconcile debit order: "+
-              "Not implemented."))
-
-payment_order()
-
-class res_partner_bank(osv.osv):
+
+class res_partner_bank(orm.Model):
     '''
     This is a hack to circumvent the very limited but widely used base_iban
     dependency. The usage of __mro__ requires inside information of
@@ -1229,15 +581,13 @@
         self._founder.__init__(*args, **kwargs)
         mro = self.__class__.__mro__
         for i in range(len(mro)):
-            if mro[i].__module__.startswith('base.'):
+            if mro[i].__module__.startswith('openerp.addons.base.'):
                 self._founder = mro[i]
                 break
 
     def init(self, cr):
         '''
         Update existing iban accounts to comply to new regime
-        Note that usage of the ORM is not possible here, as the ORM cannot
-        search on values not provided by the client.
         '''
         
         partner_bank_obj = self.pool.get('res.partner.bank')
@@ -1265,15 +615,16 @@
         iban = sepa.IBAN(acc_number)
         return (str(iban), iban.localized_BBAN)
 
-    def create(self, cursor, uid, vals, context=None):
+    def create(self, cr, uid, vals, context=None):
         '''
         Create dual function IBAN account for SEPA countries
         '''
         if vals.get('state') == 'iban':
-            iban = vals.get('acc_number',False) or vals.get('acc_number_domestic',False)
+            iban = (vals.get('acc_number')
+                    or vals.get('acc_number_domestic', False))
             vals['acc_number'], vals['acc_number_domestic'] = (
                 self._correct_IBAN(iban))
-        return self._founder.create(cursor, uid, vals, context)
+        return self._founder.create(self, cr, uid, vals, context)
 
     def write(self, cr, uid, ids, vals, context=None):
         '''
@@ -1293,10 +644,10 @@
                         self._correct_IBAN(account['acc_number']))
                 else:
                     vals['acc_number_domestic'] = False
-            self._founder.write(cr, uid, account['id'], vals, context)
+            self._founder.write(self, cr, uid, account['id'], vals, context)
         return True
 
-    def search(self, cursor, uid, args, *rest, **kwargs):
+    def search(self, cr, uid, args, *rest, **kwargs):
         '''
         Overwrite search, as both acc_number and iban now can be filled, so
         the original base_iban 'search and search again fuzzy' tactic now can
@@ -1355,10 +706,9 @@
         # Extend search filter
         newargs = extended_search_expression(args)
         
-        # Original search (_founder)
-        results = self._founder.search(cursor, uid, newargs,
-                                       *rest, **kwargs
-                                      )
+        # Original search
+        results = super(res_partner_bank, self).search(
+            cr, uid, newargs, *rest, **kwargs)
         return results
 
     def read(
@@ -1369,7 +719,7 @@
         '''
         if fields and 'state' not in fields:
             fields.append('state')
-        records = self._founder.read(cr, uid, ids, fields, context, load)
+        records = self._founder.read(self, cr, uid, ids, fields, context, load)
         is_list = True
         if not isinstance(records, list):
             records = [records,]
@@ -1381,23 +731,23 @@
             return records
         return records[0]
 
-    def check_iban(self, cursor, uid, ids):
+    def check_iban(self, cr, uid, ids, context=None):
         '''
         Check IBAN number
         '''
-        for bank_acc in self.browse(cursor, uid, ids):
+        for bank_acc in self.browse(cr, uid, ids, context=context):
             if bank_acc.state == 'iban' and bank_acc.acc_number:
                 iban = sepa.IBAN(bank_acc.acc_number)
                 if not iban.valid:
                     return False
         return True
 
-    def get_bban_from_iban(self, cursor, uid, ids, context=None):
+    def get_bban_from_iban(self, cr, uid, ids, context=None):
         '''
         Return the local bank account number aka BBAN from the IBAN.
         '''
         res = {}
-        for record in self.browse(cursor, uid, ids, context):
+        for record in self.browse(cr, uid, ids, context):
             if not record.state == 'iban':
                 res[record.id] = False
             else:
@@ -1423,12 +773,15 @@
                 )
 
     def onchange_domestic(
-        self, cursor, uid, ids, acc_number,
+        self, cr, uid, ids, acc_number,
         partner_id, country_id, context=None):
         '''
         Trigger to find IBAN. When found:
             1. Reformat BBAN
             2. Autocomplete bank
+
+        TODO: prevent unnecessary assignment of country_ids and
+        browsing of the country
         '''
         if not acc_number:
             return {}
@@ -1442,7 +795,7 @@
         # which can be overridden by the user.
         # 1. Use provided country_id (manually filled)
         if country_id:
-            country = country_obj.browse(cursor, uid, country_id)
+            country = country_obj.browse(cr, uid, country_id, context=context)
             country_ids = [country_id]
         # 2. Use country_id of found bank accounts
         # This can be usefull when there is no country set in the partners
@@ -1450,7 +803,7 @@
         # account itself before this method was triggered.
         elif ids and len(ids) == 1:
             partner_bank_obj = self.pool.get('res.partner.bank')
-            partner_bank_id = partner_bank_obj.browse(cursor, uid, ids[0])
+            partner_bank_id = partner_bank_obj.browse(cr, uid, ids[0], context=context)
             if partner_bank_id.country_id:
                 country = partner_bank_id.country_id
                 country_ids = [country.id]
@@ -1461,12 +814,12 @@
         # bank account, hence the additional check.
         elif partner_id:
             partner_obj = self.pool.get('res.partner')
-            country = partner_obj.browse(cursor, uid, partner_id).country
+            country = partner_obj.browse(cr, uid, partner_id, context=context).country
             country_ids = country and [country.id] or []
         # 4. Without any of the above, take the country from the company of
         # the handling user
         if not country_ids:
-            user = self.pool.get('res.users').browse(cursor, uid, uid)
+            user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
             # Try user companies partner (user no longer has address in 6.1)
             if (user.company_id and
                   user.company_id.partner_id and
@@ -1487,7 +840,8 @@
         # Complete data with online database when available
         if country_ids:
             country = country_obj.browse(
-                cursor, uid, country_ids[0], context=context)
+                cr, uid, country_ids[0], context=context)
+            values['country_id'] = country_ids[0]
         if country and country.code in sepa.IBAN.countries:
             try:
                 info = sepa.online.account_info(country.code, acc_number)
@@ -1498,13 +852,12 @@
                         values['acc_number'] = unicode(iban_acc)
                         values['state'] = 'iban'
                         bank_id, country_id = get_or_create_bank(
-                            self.pool, cursor, uid,
+                            self.pool, cr, uid,
                             info.bic or iban_acc.BIC_searchkey,
                             name = info.bank
                             )
-                        values['country_id'] = country_id or \
-                                               country_ids and country_ids[0] or \
-                                               False
+                        if country_id:
+                            values['country_id'] = country_id
                         values['bank'] = bank_id or False
                         if info.bic:
                             values['bank_bic'] = info.bic
@@ -1513,8 +866,8 @@
                 if info is None:
                     result.update(warning(
                         _('Invalid data'),
-                        _('The account number appears to be invalid for %(country)s')
-                        % {'country': country.name}
+                        _('The account number appears to be invalid for %s')
+                        % country.name
                     ))
             except NotImplementedError:
                 if country.code in sepa.IBAN.countries:
@@ -1524,8 +877,8 @@
                     else:
                         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 %s')
+                            % country.name
                         ))
         return result
 
@@ -1558,22 +911,17 @@
                        _("The IBAN number doesn't seem to be correct")
                       )
 
-    _constraints = [
-        # Cannot have this as a constraint as it is rejecting valid numbers from GB and DE
-        # It works much better without this constraint!
-        #(check_iban, _("The IBAN number doesn't seem to be correct"), ["acc_number"])
-    ]
-
 res_partner_bank()
 
-class res_bank(osv.osv):
+
+class res_bank(orm.Model):
     '''
     Add a on_change trigger to automagically fill bank details from the 
     online SWIFT database. Allow hand filled names to overrule SWIFT names.
     '''
     _inherit = 'res.bank'
 
-    def onchange_bic(self, cursor, uid, ids, bic, name, context=None):
+    def onchange_bic(self, cr, uid, ids, bic, name, context=None):
         '''
         Trigger to auto complete other fields.
         '''
@@ -1586,7 +934,7 @@
 
         if address and address.country_id:
             country_id = self.pool.get('res.country').search(
-                cursor, uid, [('code','=',address.country_id)]
+                cr, uid, [('code','=',address.country_id)]
             )
             country_id = country_id and country_id[0] or False
         else:
@@ -1609,7 +957,8 @@
 
 res_bank()
 
-class invoice(osv.osv):
+
+class invoice(orm.Model):
     '''
     Create other reference types as well.
 
@@ -1622,6 +971,9 @@
 
     Don't forget to redefine the column "reference_type" as below or
     your method will never be triggered.
+
+    TODO: move 'structured' part to account_banking_payment module
+    where it belongs
     '''
     _inherit = 'account.invoice'
 
@@ -1651,13 +1003,16 @@
 
 invoice()
 
-class account_move_line(osv.osv):
+
+class account_move_line(orm.Model):
     _inherit = "account.move.line"
 
     def get_balance(self, cr, uid, ids, context=None):
         """ 
         Return the balance of any set of move lines.
-        Surely this exists somewhere in account base, but I missed it.
+
+        Not to be confused with the 'balance' field on this model, which
+        returns the account balance that the move line applies to.
         """
         total = 0.0
         if not ids:

=== modified file 'account_banking/account_banking_view.xml'
--- account_banking/account_banking_view.xml	2013-06-10 10:19:50 +0000
+++ account_banking/account_banking_view.xml	2013-07-25 08:56:25 +0000
@@ -17,6 +17,12 @@
             parent="account.menu_finance_configuration"
             />
 
+        <menuitem action="account.action_view_bank_statement_tree"
+            id="account.journal_cash_move_lines"
+            sequence="18"
+            parent="account.menu_finance_bank_and_cash"/>
+
+
         <!-- Add a shortcut menu for bank accounts -->
         <record model="ir.actions.act_window" id="action_account_banking_res_partner_banks">
             <field name="name">Bank Accounts</field>
@@ -36,7 +42,6 @@
         <record model="ir.ui.view" id="view_banking_account_settings_form">
             <field name="name">account.banking.account.settings.form</field>
             <field name="model">account.banking.account.settings</field>
-            <field name="type">form</field>
             <field name="arch" type="xml">
                 <form string="Default Import Settings for Bank Account">
                     <field name="company_id"
@@ -70,7 +75,6 @@
         <record model="ir.ui.view" id="view_banking_account_settings_tree">
             <field name="name">account.banking.account.settings.tree</field>
             <field name="model">account.banking.account.settings</field>
-            <field name="type">tree</field>
             <field name="arch" type="xml">
                 <tree string="Default Import Settings for Bank Account">
                     <field name="company_id" />
@@ -94,12 +98,11 @@
             action="action_account_banking_journals"
             sequence="20"
          />
-        
+
         <!-- Create new view on imported statement files -->
         <record model="ir.ui.view" id="view_account_banking_imported_file_form">
             <field name="name">account.banking.imported.file.form</field>
             <field name="model">account.banking.imported.file</field>
-            <field name="type">form</field>
             <field name="arch" type="xml">
                 <form string="Imported Bank Statements">
                     <notebook colspan="4">
@@ -108,7 +111,8 @@
                             <field name="date" />
                             <field name="user_id" />
                             <field name="state" />
-                            <field name="file"/>
+                            <field name="file_name" invisible="1"/>
+                            <field name="file" filename="file_name"/>
                             <field name="format" />
                         </page>
                         <page string="Statements">
@@ -124,7 +128,6 @@
         <record model="ir.ui.view" id="view_account_banking_imported_file_tree">
             <field name="name">account.banking.imported.file.tree</field>
             <field name="model">account.banking.imported.file</field>
-            <field name="type">tree</field>
             <field name="arch" type="xml">
                 <tree string="Imported Bank Statements Files" colors="red:state=='error';blue:state=='unfinished'">
                     <field name="company_id" />
@@ -134,16 +137,7 @@
                 </tree>
             </field>
         </record>
-        <record id="view_account_banking_imported_line_search" model="ir.ui.view">
-            <field name="name">account.banking.imported.line.search</field>
-            <field name="model">account.bank.imported.line</field>
-            <field name="type">search</field>
-            <field name="arch" type="xml">
-                <search string="Search Bank Statement files">
-                  <field name="company_id" />
-                </search>
-            </field>
-        </record>
+
         <record model="ir.actions.act_window" id="action_account_banking_imported_files">
             <field name="name">Imported Bank Statements Files</field>
             <field name="type">ir.actions.act_window</field>
@@ -155,17 +149,17 @@
         <!-- Add a menu item for it -->
         <menuitem name="Imported Bank Statements Files"
             id="menu_action_account_banking_imported_files"
-            parent="account_banking.menu_finance_banking_actions"
+            parent="account.menu_finance_bank_and_cash"
             action="action_account_banking_imported_files"
-            sequence="12"
+            sequence="15"
          />
 
         <!-- Add the import wizard to the menu -->
         <menuitem name="Import Bank Statements File"
             id="menu_account_banking_import_wizard"
-            parent="account_banking.menu_finance_banking_actions"
+            parent="account.menu_finance_bank_and_cash"
             action="wizard_account_banking_import_file"
-            sequence="15"/>
+            sequence="12"/>
 
         <!-- Add the import wizard to the statement's right menu -->
         <act_window name="Import Bank Statements File"
@@ -191,9 +185,13 @@
             <field name="name">account.bank.statement.tree.banking</field>
             <field name="inherit_id" ref="account.view_bank_statement_tree" />
             <field name="model">account.bank.statement</field>
-            <field name="type">tree</field>
             <field name="arch" type="xml">
-                <field name="period_id" position="replace"/>
+                <!-- Remove period from bank statement -->
+                <field name="period_id" position="replace">
+                    <!-- Add invisible column for identification of import file
+                    -->
+                    <field name="banking_id" invisible="True" />
+                </field>
             </field>
         </record>
         <record id="view_banking_bank_statement_form_1" model="ir.ui.view">
@@ -201,13 +199,20 @@
             <field name="inherit_id" ref="account.view_bank_statement_form" />
             <field name="model">account.bank.statement</field>
             <field name="sequence" eval="60"/>
-            <field name="type">form</field>
             <field name="arch" type="xml">
                 <data>
+                    <page string="Transactions" position="after">
+                        <page string="Journal Entries" name="move_live_ids">
+                            <field colspan="4" name="move_line_ids" nolabel="1"/>
+                        </page>
+                    </page>
                     <field name="period_id" position="replace"/>
-                    <xpath expr="/form/notebook/page[@string='Transaction']/field/tree" position="attributes">
+
+                    <xpath expr="//page[@string='Transactions']/field/tree"
+                           position="attributes">
                         <attribute name="colors">black:state == 'confirmed';darkmagenta:match_multi == True;crimson:duplicate == True;grey:state == 'draft';</attribute>
                     </xpath>
+<<<<<<< TREE
                     <xpath expr="/form/notebook/page[@string='Transaction']/field/tree/field[@name='name']" position="replace">
                         <field name="name" required="1"/>
                     </xpath>
@@ -293,19 +298,66 @@
                             type="object"
                             attrs="{'invisible': [('link_partner_ok', '=', False)]}"
                             />
+=======
+
+                    <xpath expr="//field[@name='line_ids']/tree/field[@name='name']"
+                           position="attributes">
+                        <attribute name="required">1</attribute>
+                    </xpath>
+
+                    <xpath expr="//field[@name='line_ids']/form//field[@name='name']"
+                           position="attributes">
+                        <attribute name="required">1</attribute>
+                    </xpath>
+
+                    <!-- Add invisible field for identification of import file
+                         on bank statements
+                    -->
+                    <field name="balance_end_real" position="after">
+                        <field name="banking_id" invisible="True"/>
+                    </field>
+
+                    <!-- Show bank accounts in account_bank_statement_line to
+                         enable manualcoupling of bank account numbers to
+                         statement lines and harvest info for future matching
+                         in the process.
+                    -->
+                    <xpath expr="//field[@name='line_ids']/tree/field[@name='partner_id']"
+                           position="after">
+                        <field name="link_partner_ok" invisible="1" />
+                        <button name="link_partner"
+                                string="Link partner"
+                                icon="terp-partner"
+                                type="object"
+                                attrs="{'invisible': [('link_partner_ok', '=', False)]}"
+                                />
+>>>>>>> MERGE-SOURCE
                         <!-- TODO set partner_id when partner_bank_id changes -->
                         <field name="partner_bank_id"/>
                     </xpath>
-                    <xpath expr="/form/notebook/page/field[@name='line_ids']/tree/field[@name='amount']" position="after">
+                    <xpath expr="//field[@name='line_ids']/form//field[@name='partner_id']"
+                           position="after">
+                        <field name="partner_bank_id"/>
+                    </xpath>
+
+                    <xpath expr="//field[@name='line_ids']/tree/field[@name='amount']"
+                           position="after">
                         <field name="match_type"/>
                         <field name="residual"/>
                         <field name="parent_id" invisible="1" />
                         <button name="match_wizard"
                                 string="Match"
                                 icon="terp-gtk-jump-to-ltr"
+<<<<<<< TREE
                                 attrs="{'invisible': ['|', ('parent_id', '!=', False),
                                                            ('state', '!=', 'draft')]}"
                                 type="object"/>
+=======
+                                attrs="{'invisible': ['|', ('parent_id', '!=', False),
+                                                           ('state', '!=', 'draft')]}"
+                                type="object"
+                                />
+>>>>>>> MERGE-SOURCE
                         <field name="match_multi" invisible="1"/>
                         <field name="duplicate" invisible="1"/>
                         <field name="state"/>
@@ -320,7 +372,9 @@
                         <field name="invoice_id"/>
                         <field name="reconcile_id"/>
                     </xpath>
-                    <xpath expr="/form/notebook/page/field[@name='line_ids']/form/field[@name='amount']" position="after">
+
+                    <xpath expr="//field[@name='line_ids']/form//field[@name='amount']"
+                           position="after">
                         <field name="state"/>
                         <field name="invoice_id"/>
                         <field name="reconcile_id"/>
@@ -328,6 +382,7 @@
                 </data>
             </field>
         </record>
+<<<<<<< TREE
         <record id="view_banking_bank_statement_form_6" model="ir.ui.view">
             <field name="name">account.bank.statement.form.banking-6</field>
             <field name="inherit_id" ref="account.view_bank_statement_form" />
@@ -387,11 +442,13 @@
                 </field>
             </field>
         </record-->
+=======
+
+>>>>>>> MERGE-SOURCE
         <record id="view_partner_bank_account_banking_form_2" model="ir.ui.view">
             <field name="name">res.partner.bank.form.banking-2</field>
             <field name="model">res.partner.bank</field>
             <field name="inherit_id" ref="base.view_partner_bank_form"/>
-            <field name="type">form</field>
             <field name="priority" eval="24"/>
             <field name="arch" type="xml">
                 <data>
@@ -405,59 +462,11 @@
             </field>
         </record>
 
-        <!-- Set trigger on IBAN and acc_number field in res_partner form -->
-        <!--record id="view_partner_account_banking_form_1" model="ir.ui.view">
-            <field name="name">res.partner.form.banking-1</field>
-            <field name="model">res.partner</field>
-            <field name="inherit_id" ref="base_iban.view_partner_iban_form"/>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <field name="iban" position="replace">
-                    <field name="iban" on_change="onchange_iban(iban)" /> 
-                </field>
-            </field>
-        </record-->
-        <record id="view_partner_account_banking_form_2" model="ir.ui.view">
-            <field name="name">res.partner.form.banking-2</field>
-            <field name="model">res.partner</field>
-            <field name="inherit_id" ref="account.view_partner_property_form"/>
-            <field name="priority" eval="24"/>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <data>
-                    <field name="acc_number" position="attributes">
-                        <attribute name="on_change">onchange_acc_number(acc_number, acc_number_domestic, state, partner_id, country_id)</attribute>
-                    </field>
-                    <field name="acc_number_domestic" position="attributes">
-                        <attribute name="on_change">onchange_domestic(acc_number_domestic, partner_id, country_id)</attribute>
-                    </field>
-                </data>
-            </field>
-        </record>
-        <record id="view_partner_account_banking_form_3" model="ir.ui.view">
-            <field name="name">res.partner.form.banking-3</field>
-            <field name="model">res.partner</field>
-            <field name="inherit_id" ref="account.view_partner_property_form"/>
-            <field name="priority" eval="24"/>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <data>
-                    <field name="acc_number" position="attributes">
-                        <attribute name="on_change">onchange_acc_number(acc_number, acc_number_domestic, state, partner_id, country_id)</attribute>
-                    </field>
-                    <field name="acc_number_domestic" position="attributes">
-                        <attribute name="on_change">onchange_domestic(acc_number_domestic, partner_id, country_id)</attribute>
-                    </field>
-                </data>
-            </field>
-        </record>
-        
         <!-- Set trigger on BIC in res_bank form -->
         <record id="view_res_bank_account_banking_form_1" model="ir.ui.view">
             <field name="name">res.bank.form.banking-1</field>
             <field name="model">res.bank</field>
             <field name="inherit_id" ref="base.view_res_bank_form"/>
-            <field name="type">form</field>
             <field name="arch" type="xml">
                 <field name="bic" position="replace">
                     <field name="bic" on_change="onchange_bic(bic, name)"/>
@@ -465,58 +474,9 @@
             </field>
         </record>
 
-        <!-- Insert payment_mode.type -->
-        <record id="view_payment_mode_form_inherit" model="ir.ui.view">
-            <field name="name">payment.mode.form.inherit</field>
-            <field name="model">payment.mode</field>
-            <field name="inherit_id" ref="account_payment.view_payment_mode_form"/>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <field name="company_id" position="after">
-                    <field name="type"/>
-                </field>
-            </field>
-        </record>
-        <record id="view_payment_mode_tree_inherit" model="ir.ui.view">
-            <field name="name">payment.mode.tree.inherit</field>
-            <field name="model">payment.mode</field>
-            <field name="inherit_id" ref="account_payment.view_payment_mode_tree"/>
-            <field name="type">tree</field>
-            <field name="arch" type="xml">
-                <field name="company_id" position="after">
-                    <field name="type"/>
-                </field>
-            </field>
-        </record>
-
-	<!-- basic view for payment mode type -->
-        <record model="ir.ui.view" id="view_payment_mode_type_form">
-            <field name="name">view.payment.mode.type.form</field>
-            <field name="model">payment.mode.type</field>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <form>
-		    <field name="name" />
-		    <field name="code" />
-		    <field name="suitable_bank_types"/>
-		    <field name="payment_order_type"/>
-		    <field name="ir_model_id"/>
-                </form>
-            </field>
-        </record>
-
-        <!-- fixes https://bugs.launchpad.net/openobject-addons/+bug/903156 for 6.0 
-             Note that 6.1 does not suffer from the problem 
-        -->
-        <record id="account_payment.action_create_payment_order" model="ir.actions.act_window">
-            <field name="view_id" ref="account_payment.view_create_payment_order"/>
-        </record>
-
-        
         <record model="ir.ui.view" id="view_bank_statement_line_tree">
             <field name="name">Bank statement line tree view</field>
             <field name="model">account.bank.statement.line</field>
-            <field name="type">tree</field>
             <field name="arch" type="xml">
                 <tree string="Statement lines" colors="black:state == 'confirmed';darkmagenta:match_multi == True;crimson:duplicate == True;grey:state=='draft';">
                     <field name="sequence" readonly="1" invisible="1"/>
@@ -538,6 +498,7 @@
                     <field domain="[('journal_id','=',parent.journal_id)]" name="account_id"/>
                     <field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('company_id', '=', parent.company_id), ('type', '&lt;&gt;', 'view')]"/>
                     <field name="amount"/>
+<<<<<<< TREE
                         <field name="match_type"/>
                         <field name="residual"/>
                         <field name="parent_id" invisible="1" />
@@ -560,6 +521,31 @@
                                 type="object"/>
                         <field name="invoice_id"/>
                         <field name="reconcile_id"/>
+=======
+                    <field name="match_type"/>
+                    <field name="residual"/>
+                    <field name="parent_id" invisible="1" />
+                    <button name="match_wizard" states="draft"
+                            string="Match"
+                            icon="terp-gtk-jump-to-ltr"
+                            attrs="{'invisible': ['|', ('parent_id', '!=', False),
+                                                       ('state', '!=', 'draft')]}"
+                            type="object"
+                            />
+                    <field name="match_multi" invisible="1"/>
+                    <field name="duplicate" invisible="1"/>
+                    <field name="state"/>
+                    <button name="confirm" states="draft"
+                            string="Confirm transaction"
+                            icon="gtk-ok"
+                            type="object"/>
+                    <button name="cancel" states="confirmed"
+                            string="Cancel transaction"
+                            icon="gtk-cancel"
+                            type="object"/>
+                    <field name="invoice_id"/>
+                    <field name="reconcile_id"/>
+>>>>>>> MERGE-SOURCE
                 </tree>
             </field>
         </record>

=== modified file 'account_banking/banking_import_transaction.py'
--- account_banking/banking_import_transaction.py	2013-06-10 10:19:50 +0000
+++ account_banking/banking_import_transaction.py	2013-07-25 08:56:25 +0000
@@ -1,45 +1,42 @@
-# -*- encoding: utf-8 -*-
 ##############################################################################
 #
 #    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
-#                  Contributions by Kaspars Vilkens (KNdati):
-#                  lenghty discussions, bugreports and bugfixes
-#    Refractoring (C) 2011 Therp BV (<http://therp.nl>).
-#                 (C) 2011 Smile (<http://smile.fr>).
+#              (C) 2011 Therp BV (<http://therp.nl>).
+#              (C) 2011 Smile (<http://smile.fr>).
+#            
+#    All other contributions are (C) by their respective contributors
 #
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
 
-from osv import osv, fields
-import netsvc
-import base64
 import datetime
-from tools import config
-from tools.translate import _
-from parsers import models
-from parsers.convert import *
-# from account_banking.struct import struct
-from account_banking import sepa
-from wizard.banktools import *
-import decimal_precision as dp
+from openerp.osv import orm, fields
+from openerp import netsvc
+from openerp.tools.translate import _
+from openerp.addons.decimal_precision import decimal_precision as dp
+from openerp.addons.account_banking.parsers import models
+from openerp.addons.account_banking.parsers import convert
+from openerp.addons.account_banking import sepa
+from openerp.addons.account_banking.wizard import banktools
 
 bt = models.mem_bank_transaction
 
-class banking_import_transaction(osv.osv):
+
+class banking_import_transaction(orm.Model):
     """ orm representation of mem_bank_transaction() for interactive and posthoc
     configuration of reconciliation in the bank statement view.
 
@@ -65,7 +62,7 @@
             return []
 
         digits = dp.get_precision('Account')(cr)[1]
-        amount = round(abs(trans.transferred_amount), digits)
+        amount = round(abs(trans.statement_line_id.amount), digits)
         # Make sure to be able to pinpoint our costs invoice for later
         # matching
         reference = '%s.%s: %s' % (trans.statement, trans.transaction, trans.reference)
@@ -123,6 +120,7 @@
         # return move_lines to mix with the rest
         return [x for x in invoice.move_id.line_id if x.account_id.reconcile]
 
+<<<<<<< TREE
     def _match_debit_order(
         self, cr, uid, trans, log, context=None):
 
@@ -161,6 +159,8 @@
                 )
         return False
 
+=======
+>>>>>>> MERGE-SOURCE
     def _match_invoice(self, cr, uid, trans, move_lines,
                        partner_ids, bank_account_ids,
                        log, linked_invoices,
@@ -274,17 +274,13 @@
         digits = dp.get_precision('Account')(cr)[1]
         partial = False
 
-        # Disabled splitting transactions for now
-        # TODO allow splitting in the interactive wizard
-        allow_splitting = False
-
         # Search invoice on partner
         if partner_ids:
             candidates = [
                 x for x in move_lines
                 if x.partner_id.id in partner_ids and
-                (str2date(x.date, '%Y-%m-%d') <=
-                 (str2date(trans.execution_date, '%Y-%m-%d') +
+                (convert.str2date(x.date, '%Y-%m-%d') <=
+                 (convert.str2date(trans.execution_date, '%Y-%m-%d') +
                   self.payment_window))
                 and (not _cached(x) or _remaining(x))
                 ]
@@ -305,8 +301,8 @@
             candidates = [
                 x for x in candidates or move_lines 
                 if (x.invoice and has_id_match(x.invoice, ref, msg) and
-                    str2date(x.invoice.date_invoice, '%Y-%m-%d') <=
-                    (str2date(trans.execution_date, '%Y-%m-%d') +
+                    convert.str2date(x.invoice.date_invoice, '%Y-%m-%d') <=
+                    (convert.str2date(trans.execution_date, '%Y-%m-%d') +
                      self.payment_window)
                     and (not _cached(x) or _remaining(x)))
                 ]
@@ -317,9 +313,9 @@
             candidates = [
                     x for x in move_lines 
                     if (is_zero(x.move_id, ((x.debit or 0.0) - (x.credit or 0.0)) -
-                                trans.transferred_amount)
-                        and str2date(x.date, '%Y-%m-%d') <=
-                        (str2date(trans.execution_date, '%Y-%m-%d')  +
+                                trans.statement_line_id.amount)
+                        and convert.str2date(x.date, '%Y-%m-%d') <=
+                        (convert.str2date(trans.execution_date, '%Y-%m-%d')  +
                          self.payment_window)
                         and (not _cached(x) or _remaining(x)))
                     ]
@@ -333,9 +329,9 @@
             # TODO: currency coercing
             best = [x for x in candidates
                     if (is_zero(x.move_id, ((x.debit or 0.0) - (x.credit or 0.0)) -
-                                trans.transferred_amount)
-                        and str2date(x.date, '%Y-%m-%d') <=
-                        (str2date(trans.execution_date, '%Y-%m-%d') +
+                                trans.statement_line_id.amount)
+                        and convert.str2date(x.date, '%Y-%m-%d') <=
+                        (convert.str2date(trans.execution_date, '%Y-%m-%d') +
                          self.payment_window))
                    ]
             if len(best) == 1:
@@ -353,8 +349,8 @@
                 # transfers first
                 paid = [x for x in move_lines 
                         if x.invoice and has_id_match(x.invoice, ref, msg)
-                            and str2date(x.invoice.date_invoice, '%Y-%m-%d')
-                                <= str2date(trans.execution_date, '%Y-%m-%d')
+                            and convert.str2date(x.invoice.date_invoice, '%Y-%m-%d')
+                                <= convert.str2date(trans.execution_date, '%Y-%m-%d')
                             and (_cached(x) and not _remaining(x))
                        ]
                 if paid:
@@ -384,7 +380,7 @@
 
             trans2 = None
             if move_line and partial:
-                found = round(trans.transferred_amount, digits)
+                found = round(trans.statement_line_id.amount, digits)
                 if abs(expected) == abs(found):
                     partial = False
                     # Last partial payment will not flag invoice paid without
@@ -399,24 +395,6 @@
                 elif abs(expected) > abs(found):
                     # Partial payment, reuse invoice
                     _cache(move_line, expected - found)
-                elif abs(expected) < abs(found) and allow_splitting:
-                    # Possible combined payments, need to split transaction to
-                    # verify
-                    _cache(move_line)
-                    trans2 = self.copy(
-                    cr, uid, trans.id, 
-                    dict(
-                            transferred_amount = trans.transferred_amount - expected,
-                            transaction = trans.transaction + 'b',
-                            parent_id = trans.id,
-                            ), context=context)
-                    # update the current record
-                    self.write(cr, uid, trans.id, dict(
-                            transferred_amount = expected,
-                            transaction = trans.transaction + 'a',
-                            ), context)
-                    # rebrowse the current record after writing
-                    trans = self.browse(cr, uid, trans.id, context=context)
             if move_line:
                 account_ids = [
                     x.id for x in bank_account_ids 
@@ -444,7 +422,7 @@
         transaction = self.browse(cr, uid, transaction_id, context)
         if not transaction.move_line_id:
             if transaction.match_type == 'invoice':
-                raise osv.except_osv(
+                raise orm.except_orm(
                     _("Cannot link transaction %s with invoice") %
                     transaction.statement_line_id.name,
                     (transaction.invoice_ids and
@@ -454,7 +432,7 @@
                             transaction.statement_line_id.name
                      )))
             else:
-                raise osv.except_osv(
+                raise orm.except_orm(
                     _("Cannot link transaction %s with accounting entry") %
                     transaction.statement_line_id.name,
                     (transaction.move_line_ids and
@@ -515,7 +493,6 @@
             '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,
             'account_id': account_id,
             'amount': abs(st_line.amount),
             'writeoff_amount': writeoff,
@@ -545,101 +522,6 @@
             {'voucher_id': voucher_id}, context=context)
         transaction.refresh()
 
-    def _confirm_storno(
-        self, cr, uid, transaction_id, context=None):
-        """
-        Creation of the reconciliation has been delegated to
-        *a* direct debit module, to allow for various direct debit styles
-        """
-        payment_line_pool = self.pool.get('payment.line')
-        statement_line_pool = self.pool.get('account.bank.statement.line')
-        transaction = self.browse(cr, uid, transaction_id, context=context)
-        if not transaction.payment_line_id:
-            raise osv.except_osv(
-                _("Cannot link with storno"),
-                _("No direct debit order item"))
-        reconcile_id = payment_line_pool.debit_storno(
-            cr, uid,
-            transaction.payment_line_id.id, 
-            transaction.statement_line_id.amount,
-            transaction.statement_line_id.currency,
-            transaction.storno_retry,
-            context=context)
-        statement_line_pool.write(
-            cr, uid, transaction.statement_line_id.id, 
-            {'reconcile_id': reconcile_id}, context=context)
-        transaction.refresh()
-
-    def _confirm_payment_order(
-        self, cr, uid, transaction_id, context=None):
-        """
-        Creation of the reconciliation has been delegated to
-        *a* direct debit module, to allow for various direct debit styles
-        """
-        payment_order_obj = self.pool.get('payment.order')
-        statement_line_pool = self.pool.get('account.bank.statement.line')
-        transaction = self.browse(cr, uid, transaction_id, context=context)
-        if not transaction.payment_order_id:
-            raise osv.except_osv(
-                _("Cannot reconcile"),
-                _("Cannot reconcile: no direct debit order"))
-        if transaction.payment_order_id.payment_order_type != 'debit':
-            raise osv.except_osv(
-                _("Cannot reconcile"),
-                _("Reconcile payment order not implemented"))
-        reconcile_id = payment_order_obj.debit_reconcile_transfer(
-            cr, uid,
-            transaction.payment_order_id.id,
-            transaction.statement_line_id.amount,
-            transaction.statement_line_id.currency,
-            context=context)
-        statement_line_pool.write(
-            cr, uid, transaction.statement_line_id.id, 
-            {'reconcile_id': reconcile_id}, context=context)
-
-    def _confirm_payment(
-        self, cr, uid, transaction_id, context=None):
-        """
-        Do some housekeeping on the payment line
-        then pass on to _reconcile_move
-        """
-        transaction = self.browse(cr, uid, transaction_id, context=context)
-        payment_line_obj = self.pool.get('payment.line')
-        payment_line_obj.write(
-            cr, uid, transaction.payment_line_id.id, {
-                'export_state': 'done',
-                'date_done': transaction.statement_line_id.date,
-                }
-            )
-        self._confirm_move(cr, uid, transaction_id, context=context)
-        
-    def _cancel_payment(
-        self, cr, uid, transaction_id, context=None):
-        raise osv.except_osv(
-            _("Cannot unreconcile"),
-            _("Cannot unreconcile: this operation is not yet supported for "
-              "match type 'payment'"))
-
-    def _cancel_payment_order(
-        self, cr, uid, transaction_id, context=None):
-        """
-        """
-        payment_order_obj = self.pool.get('payment.order')
-        transaction = self.browse(cr, uid, transaction_id, context=context)
-        if not transaction.payment_order_id:
-            raise osv.except_osv(
-                _("Cannot unreconcile"),
-                _("Cannot unreconcile: no direct debit order"))
-        if transaction.payment_order_id.payment_order_type != 'debit':
-            raise osv.except_osv(
-                _("Cannot unreconcile"),
-                _("Unreconcile payment order not implemented"))
-        return payment_order_obj.debit_unreconcile_transfer(
-            cr, uid, transaction.payment_order_id.id,
-            transaction.statement_line_id.reconcile_id.id,
-            transaction.statement_line_id.amount,
-            transaction.statement_line_id.currency)
-
     def _legacy_do_move_unreconcile(self, cr, uid, move_line_ids, currency, context=None):
         """
         Legacy method. Allow for canceling bank statement lines that 
@@ -687,7 +569,7 @@
     def _legacy_clear_up_writeoff(self, cr, uid, transaction, context=None):
         """
         Legacy method to support upgrades older installations of the
-        interactive wizard branch. To be removed after 6.2
+        interactive wizard branch. To be removed after 7.0
         clear up the writeoff move
         """
         if transaction.writeoff_move_line_id:
@@ -771,70 +653,10 @@
 
         return True
 
-    def _cancel_storno(
-        self, cr, uid, transaction_id, context=None):
-        """
-        TODO: delegate unreconciliation to the direct debit module,
-        to allow for various direct debit styles
-        """
-        payment_line_obj = self.pool.get('payment.line')
-        reconcile_obj = self.pool.get('account.move.reconcile')
-        transaction = self.browse(cr, uid, transaction_id, context=context)
-        
-        if not transaction.payment_line_id:
-            raise osv.except_osv(
-                _("Cannot cancel link with storno"),
-                _("No direct debit order item"))
-        if not transaction.payment_line_id.storno:
-            raise osv.except_osv(
-                _("Cannot cancel link with storno"),
-                _("The direct debit order item is not marked for storno"))
-
-        journal = transaction.statement_line_id.statement_id.journal_id
-        if transaction.statement_line_id.amount >= 0:
-            account_id = journal.default_credit_account_id.id
-        else:
-            account_id = journal.default_debit_account_id.id
-        cancel_line = False
-        move_lines = []
-        for move in transaction.statement_line_id.move_ids:
-            # There should usually be just one move, I think
-            move_lines += move.line_id
-        for line in move_lines:
-            if line.account_id.id != account_id:
-                cancel_line = line
-                break
-        if not cancel_line:
-            raise osv.except_osv(
-                _("Cannot cancel link with storno"),
-                _("Line id not found"))
-        reconcile = cancel_line.reconcile_id or cancel_line.reconcile_partial_id
-        lines_reconcile = reconcile.line_id or reconcile.line_partial_ids
-        if len(lines_reconcile) < 3:
-            # delete the full reconciliation
-            reconcile_obj.unlink(cr, uid, reconcile.id, context)
-        else:
-            # we are left with a partial reconciliation
-            reconcile_obj.write(
-                cr, uid, reconcile.id, 
-                {'line_partial_ids': 
-                 [(6, 0, [x.id for x in lines_reconcile if x.id != cancel_line.id])],
-                 'line_id': [(6, 0, [])],
-                 }, context)
-        # redo the original payment line reconciliation with the invoice
-        payment_line_obj.write(
-            cr, uid, transaction.payment_line_id.id, 
-            {'storno': False}, context)
-        payment_line_obj.debit_reconcile(
-            cr, uid, transaction.payment_line_id.id, context)
-
     cancel_map = {
-        'storno': _cancel_storno,
         'invoice': _cancel_voucher,
         'manual': _cancel_voucher,
         'move': _cancel_voucher,
-        'payment_order': _cancel_payment_order,
-        'payment': _cancel_payment,
         }
 
     def cancel(self, cr, uid, ids, context=None):
@@ -844,7 +666,7 @@
             if not transaction.match_type:
                 continue
             if transaction.match_type not in self.cancel_map:
-                raise osv.except_osv(
+                raise orm.except_orm(
                     _("Cannot cancel type %s" % transaction.match_type),
                     _("No method found to cancel this type"))
             self.cancel_map[transaction.match_type](
@@ -853,11 +675,8 @@
         return True
 
     confirm_map = {
-        'storno': _confirm_storno,
         'invoice': _confirm_move,
         'manual': _confirm_move,
-        'payment_order': _confirm_payment_order,
-        'payment': _confirm_payment,
         'move': _confirm_move,
         }
 
@@ -868,7 +687,7 @@
             if not transaction.match_type:
                 continue
             if transaction.match_type not in self.confirm_map:
-                raise osv.except_osv(
+                raise orm.except_orm(
                     _("Cannot reconcile"),
                     _("Cannot reconcile type %s. No method found to " +
                       "reconcile this type") %
@@ -876,7 +695,7 @@
                     )
             if (transaction.residual and transaction.writeoff_account_id):
                 if transaction.match_type not in ('invoice', 'move', 'manual'):
-                    raise osv.except_osv(
+                    raise orm.except_orm(
                         _("Cannot reconcile"),
                         _("Bank transaction %s: write off not implemented for " +
                           "this match type.") %
@@ -887,74 +706,8 @@
             self.confirm_map[transaction.match_type](
                 self, cr, uid, transaction.id, context)
 
-        """
-        account_ids = [
-        x.id for x in bank_account_ids 
-        if x.partner_id.id == move_line.partner_id.id
-        ][0]
-        """
         return True
    
-    def _match_storno(
-        self, cr, uid, trans, log, context=None):
-        payment_line_obj = self.pool.get('payment.line')
-        line_ids = payment_line_obj.search(
-            cr, uid, [
-                ('order_id.payment_order_type', '=', 'debit'),
-                ('order_id.state', 'in', ['sent', 'done']),
-                ('communication', '=', trans.reference)
-                ], context=context)
-        # stornos MUST have an exact match
-        if len(line_ids) == 1:
-            account_id = payment_line_obj.get_storno_account_id(
-                cr, uid, line_ids[0], trans.transferred_amount,
-                trans.statement_id.currency, context=None)
-            if account_id:
-                return dict(
-                    account_id = account_id,
-                    match_type = 'storno',
-                    payment_line_id = line_ids[0],
-                    move_line_ids=False,
-                    partner_id=False,
-                    partner_bank_id=False,
-                    reference=False,
-                    type='customer',
-                    )
-        # TODO log the reason why there is no result for transfers marked
-        # as storno
-        return False
-
-    def _match_payment(self, cr, uid, trans, payment_lines,
-                      partner_ids, bank_account_ids, log, linked_payments):
-        '''
-        Find the payment order belonging to this reference - if there is one
-        This is the easiest part: when sending payments, the returned bank info
-        should be identical to ours.
-        This also means that we do not allow for multiple candidates.
-        '''
-        # 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')(cr)[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.acc_number_domestic)
-                     ]
-        if len(candidates) == 1:
-            candidate = candidates[0]
-            # Check cache to prevent multiple matching of a single payment
-            if candidate.id not in linked_payments:
-                linked_payments[candidate.id] = True
-                move_info = self._get_move_info(cr, uid, [candidate.move_line_id.id])
-                move_info.update({
-                        'match_type': 'payment',
-                        'payment_line_id': candidate.id,
-                        })
-                return move_info
-
-        return False
-
     signal_duplicate_keys = [
         # does not include float values
         # such as transferred_amount
@@ -980,12 +733,12 @@
             # due to float representation and rounding difficulties
             for trans in self.browse(cr, uid, ids, context=context):
                 if self.pool.get('res.currency').is_zero(
-                    cr, uid, 
+                    cr, uid,
                     trans.statement_id.currency,
                     me['transferred_amount'] - trans.transferred_amount):
                     dupes.append(trans.id)
             if len(dupes) < 1:
-                raise osv.except_osv(_('Cannot check for duplicate'),
+                raise orm.except_orm(_('Cannot check for duplicate'),
                                _("Cannot check for duplicate. "
                                  "I can't find myself."))
             if len(dupes) > 1:
@@ -1045,8 +798,36 @@
 
         if len(move_lines) == 1:
             retval['reference'] = move_lines[0].ref
+<<<<<<< TREE
 
+=======
+        if retval['match_type'] == 'invoice':
+            retval['invoice_ids'] = list(set([x.invoice.id for x in move_lines]))
+            retval['type'] = type_map[move_lines[0].invoice.type]
+>>>>>>> MERGE-SOURCE
         return retval
+
+    def move_info2values(self, move_info):
+        vals = {}
+        vals['match_type'] = move_info['match_type']
+        vals['move_line_ids'] = [(6, 0, move_info.get('move_line_ids') or [])]
+        vals['invoice_ids'] = [(6, 0, move_info.get('invoice_ids') or [])]
+        vals['move_line_id'] = (move_info.get('move_line_ids', False) and
+                                       len(move_info['move_line_ids']) == 1 and
+                                       move_info['move_line_ids'][0]
+                                       )
+        if move_info['match_type'] == 'invoice':
+            vals['invoice_id'] = (move_info.get('invoice_ids', False) and
+                                         len(move_info['invoice_ids']) == 1 and
+                                         move_info['invoice_ids'][0]
+                                         )
+        return vals
+
+    def hook_match_payment(self, cr, uid, transaction, log, context=None):
+        """
+        To override in module 'account_banking_payment'
+        """
+        return False
     
     def match(self, cr, uid, ids, results=None, context=None):
         if not ids:
@@ -1057,9 +838,10 @@
         journal_obj = self.pool.get('account.journal')
         move_line_obj = self.pool.get('account.move.line')
         payment_line_obj = self.pool.get('payment.line')
+        has_payment = bool(
+            payment_line_obj and 'date_done' in payment_line_obj._columns)
         statement_line_obj = self.pool.get('account.bank.statement.line')
         statement_obj = self.pool.get('account.bank.statement')
-        payment_order_obj = self.pool.get('payment.order')
         imported_statement_ids = []
 
         # Results
@@ -1086,14 +868,13 @@
         # communication. Most likely there are much less sent payments
         # than reconciled and open/draft payments.
         # Strangely, payment_orders still do not have company_id
-        cr.execute("SELECT l.id FROM payment_order o, payment_line l "
-                       "WHERE l.order_id = o.id AND "
-                       "o.state = 'sent' AND "
-                       "l.date_done IS NULL"
-                       )
-        payment_line_ids = [x[0] for x in cr.fetchall()]
-        if payment_line_ids:
-            payment_lines = payment_line_obj.browse(cr, uid, payment_line_ids)
+        if has_payment:
+            payment_line_ids = payment_line_obj.search(
+                cr, uid, [
+                ('order_id.state', '=', 'sent'),
+                ('date_done', '=', False)], context=context)
+            payment_lines = payment_line_obj.browse(
+                cr, uid, payment_line_ids)
 
         # Start the loop over the transactions requested to match
         transactions = self.browse(cr, uid, ids, context)
@@ -1109,12 +890,6 @@
             else:
                 transaction = transactions[i]
 
-            if (transaction.statement_line_id and
-                transaction.statement_line_id.state == 'confirmed'):
-                raise osv.except_osv(
-                    _("Cannot perform match"),
-                    _("Cannot perform match on a confirmed transction"))
-            
             if transaction.local_account in error_accounts:
                 results['trans_skipped_cnt'] += 1
                 if not injected:
@@ -1162,7 +937,7 @@
                 account_info = info[transaction.local_account][currency_code]
             else:
                 # Pull account info/currency
-                account_info = get_company_bank_account(
+                account_info = banktools.get_company_bank_account(
                     self.pool, cr, uid, transaction.local_account,
                     transaction.local_currency, company, results['log']
                 )
@@ -1199,6 +974,44 @@
                 else:
                     info[transaction.local_account][currency_code] = account_info
 
+            # Link accounting period
+            period_id = banktools.get_period(
+                self.pool, cr, uid, transaction.effective_date,
+                company, results['log'])
+            if not period_id:
+                results['trans_skipped_cnt'] += 1
+                if not injected:
+                    i += 1
+                continue
+
+            if transaction.statement_line_id:
+                if transaction.statement_line_id.state == 'confirmed':
+                    raise orm.except_orm(
+                        _("Cannot perform match"),
+                        _("Cannot perform match on a confirmed transction"))
+            else:
+                values = {
+                    'name': '%s.%s' % (transaction.statement, transaction.transaction),
+                    'date': transaction.effective_date,
+                    'amount': transaction.transferred_amount,
+                    'statement_id': transaction.statement_id.id,
+                    'note': transaction.message,
+                    'ref': transaction.reference,
+                    'period_id': period_id,
+                    'currency': account_info.currency_id.id,
+                    'import_transaction_id': transaction.id,
+                    'account_id': (
+                        transaction.transferred_amount < 0 and
+                        account_info.default_credit_account_id.id or
+                        account_info.default_debit_account_id.id),
+                    }
+                statement_line_id = statement_line_obj.create(cr, uid, values, context)
+                results['trans_loaded_cnt'] += 1
+                transaction.write({'statement_line_id': statement_line_id})
+                transaction.refresh()
+                if transaction.statement_id.id not in imported_statement_ids:
+                    imported_statement_ids.append(transaction.statement_id.id)
+                
             # Final check: no coercion of currencies!
             if transaction.local_currency \
                and account_info.currency_id.name != transaction.local_currency:
@@ -1208,8 +1021,8 @@
                       ' uses different currency than the defined bank journal.'
                      ) % {
                          'bank_account': transactions.local_account,
-                         'transaction_id': transaction.statement,
-                         'statement_id': transaction.transaction,
+                         'statement_id': transaction.statement,
+                         'transaction_id': transaction.transaction,
                      }
                 )
                 error_accounts[transaction.local_account] = True
@@ -1218,17 +1031,6 @@
                     i += 1
                 continue
 
-            # Link accounting period
-            period_id = get_period(
-                self.pool, cr, uid,
-                str2date(transaction.effective_date,'%Y-%m-%d'), company,
-                results['log'])
-            if not period_id:
-                results['trans_skipped_cnt'] += 1
-                if not injected:
-                    i += 1
-                continue
-
             # When bank costs are part of transaction itself, split it.
             if transaction.type != bt.BANK_COSTS and transaction.provision_costs:
                 # Create new transaction for bank costs
@@ -1260,6 +1062,7 @@
                         ), context=context)
                 # rebrowse the current record after writing
                 transaction = self.browse(cr, uid, transaction.id, context=context)
+<<<<<<< TREE
             # Match full direct debit orders
             if transaction.type == bt.DIRECT_DEBIT:
                 move_info = self._match_debit_order(
@@ -1268,6 +1071,15 @@
                 move_info = self._match_storno(
                     cr, uid, transaction, results['log'], context)
 
+=======
+
+            # Match payment and direct debit orders
+            move_info_payment = self.hook_match_payment(
+                cr, uid, transaction, results['log'], context=context)
+            if move_info_payment:
+                move_info = move_info_payment
+
+>>>>>>> MERGE-SOURCE
             # Allow inclusion of generated bank invoices
             if transaction.type == bt.BANK_COSTS:
                 lines = self._match_costs(
@@ -1281,20 +1093,27 @@
                 partner_ids = [account_info.bank_partner_id.id]
             else:
                 # Link remote partner, import account when needed
-                partner_banks = get_bank_accounts(
+                partner_banks = banktools.get_bank_accounts(
                     self.pool, cr, uid, transaction.remote_account,
                     results['log'], fail=True
                     )
                 if partner_banks:
                     partner_ids = [x.partner_id.id for x in partner_banks]
                 elif transaction.remote_owner:
+<<<<<<< TREE
                     country_id = get_country_id(
                         self.pool, cr, uid, transaction, context=context)
                     partner_id = get_partner(
+=======
+                    country_id = banktools.get_country_id(
+                        self.pool, cr, uid, transaction, context=context)
+                    partner_id = banktools.get_partner(
+>>>>>>> MERGE-SOURCE
                         self.pool, cr, uid, transaction.remote_owner,
                         transaction.remote_owner_address,
                         transaction.remote_owner_postalcode,
                         transaction.remote_owner_city,
+<<<<<<< TREE
                         country_id, results['log'], context=context)
                     if partner_id:
                         partner_ids = [partner_id]
@@ -1310,11 +1129,32 @@
                             partner_banks = partner_bank_obj.browse(
                                 cr, uid, [partner_bank_id]
                                 )
+=======
+                        country_id, results['log'],
+                        context=context)
+                    if partner_id:
+                        partner_ids = [partner_id]
+                        if transaction.remote_account:
+                            partner_bank_id = banktools.create_bank_account(
+                                self.pool, cr, uid, partner_id,
+                                transaction.remote_account,
+                                transaction.remote_owner, 
+                                transaction.remote_owner_address,
+                                transaction.remote_owner_city,
+                                country_id, bic=transaction.remote_bank_bic,
+                                context=context)
+                            partner_banks = partner_bank_obj.browse(
+                                cr, uid, [partner_bank_id], context=context)
+>>>>>>> MERGE-SOURCE
 
             # Credit means payment... isn't it?
             if (not move_info
-                and transaction.transferred_amount < 0 and payment_lines):
+                and transaction.statement_line_id.amount < 0 and payment_lines):
                 # Link open payment - if any
+                # Note that _match_payment is defined in the
+                # account_banking_payment module which should be installed
+                # automatically if account_payment is. And if account_payment
+                # is not installed, then payment_lines will be empty.
                 move_info = self._match_payment(
                     cr, uid, transaction,
                     payment_lines, partner_ids,
@@ -1340,7 +1180,7 @@
                 # settings to overrule this. Note that you need to change
                 # the internal type of these accounts to either 'payable'
                 # or 'receivable' to enable usage like this.
-                if transaction.transferred_amount < 0:
+                if transaction.statement_line_id.amount < 0:
                     if len(partner_banks) == 1:
                         account_id = (
                             partner_banks[0].partner_id.property_account_payable and
@@ -1356,32 +1196,16 @@
                     if len(partner_banks) != 1 or not account_id or account_id == def_rec_account_id:
                         account_id = (account_info.default_debit_account_id and
                                       account_info.default_debit_account_id.id)
-            values = {}
+            values = {'account_id': account_id}
             self_values = {}
             if move_info:
                 results['trans_matched_cnt'] += 1
-                self_values['match_type'] = move_info['match_type']
-                self_values['payment_line_id'] = move_info.get('payment_line_id', False)
-                self_values['move_line_ids'] = [(6, 0, move_info.get('move_line_ids') or [])]
-                self_values['invoice_ids'] = [(6, 0, move_info.get('invoice_ids') or [])]
-                self_values['payment_order_ids'] = [(6, 0, move_info.get('payment_order_ids') or [])]
-                self_values['payment_order_id'] = (move_info.get('payment_order_ids', False) and 
-                                                   len(move_info['payment_order_ids']) == 1 and
-                                                   move_info['payment_order_ids'][0]
-                                                   )
-                self_values['move_line_id'] = (move_info.get('move_line_ids', False) and
-                                               len(move_info['move_line_ids']) == 1 and
-                                               move_info['move_line_ids'][0]
-                                               )
-                if move_info['match_type'] == 'invoice':
-                    self_values['invoice_id'] = (move_info.get('invoice_ids', False) and
-                                                 len(move_info['invoice_ids']) == 1 and
-                                                 move_info['invoice_ids'][0]
-                                                 )
+                self_values.update(
+                    self.move_info2values(move_info))
+                # values['match_type'] = move_info['match_type']
                 values['partner_id'] = move_info['partner_id']
                 values['partner_bank_id'] = move_info['partner_bank_id']
                 values['type'] = move_info['type']
-                # values['match_type'] = move_info['match_type']
             else:
                 values['partner_id'] = values['partner_bank_id'] = False
             if not values['partner_id'] and partner_ids and len(partner_ids) == 1:
@@ -1390,28 +1214,8 @@
                 len(partner_banks) == 1):
                 values['partner_bank_id'] = partner_banks[0].id
 
-            if not transaction.statement_line_id:
-                values.update(dict(
-                        name = '%s.%s' % (transaction.statement, transaction.transaction),
-                        date = transaction.effective_date,
-                        amount = transaction.transferred_amount,
-                        statement_id = transaction.statement_id.id,
-                        note = transaction.message,
-                        ref = transaction.reference,
-                        period_id = period_id,
-                        currency = account_info.currency_id.id,
-                        account_id = account_id,
-                        import_transaction_id = transaction.id,
-                        ))
-
-                statement_line_id = statement_line_obj.create(cr, uid, values, context)
-                results['trans_loaded_cnt'] += 1
-                self_values['statement_line_id'] = statement_line_id
-                if transaction.statement_id.id not in imported_statement_ids:
-                    imported_statement_ids.append(transaction.statement_id.id)
-            else:
-                statement_line_obj.write(
-                    cr, uid, transaction.statement_line_id.id, values, context)
+            statement_line_obj.write(
+                cr, uid, transaction.statement_line_id.id, values, context)
             self.write(cr, uid, transaction.id, self_values, context)
             if not injected:
                 i += 1
@@ -1421,34 +1225,6 @@
             statement_obj.button_dummy(
                 cr, uid, imported_statement_ids, context=context)
 
-        if payment_lines:
-            # As payments lines are treated as individual transactions, the
-            # batch as a whole is only marked as 'done' when all payment lines
-            # have been reconciled.
-            cr.execute(
-                "SELECT DISTINCT o.id "
-                "FROM payment_order o, payment_line l "
-                "WHERE o.state = 'sent' "
-                  "AND o.id = l.order_id "
-                  "AND o.id NOT IN ("
-                    "SELECT DISTINCT order_id AS id "
-                    "FROM payment_line "
-                    "WHERE date_done IS NULL "
-                      "AND id IN (%s)"
-                   ")" % (','.join([str(x) for x in payment_line_ids]))
-            )
-            order_ids = [x[0] for x in cr.fetchall()]
-            if order_ids:
-                # Use workflow logics for the orders. Recode logic from
-                # account_payment, in order to increase efficiency.
-                payment_order_obj.set_done(cr, uid, order_ids,
-                                        {'state': 'done'}
-                                       )
-                wf_service = netsvc.LocalService('workflow')
-                for id in order_ids:
-                    wf_service.trg_validate(
-                        uid, 'payment.order', id, 'done', cr)
-
     def _get_residual(self, cr, uid, ids, name, args, context=None):
         """
         Calculate the residual against the candidate reconciliation.
@@ -1493,10 +1269,6 @@
             elif transaction.match_type == 'invoice':
                 if transaction.invoice_ids and not transaction.invoice_id:
                     res[transaction.id] = True
-            elif transaction.match_type == 'payment_order':
-                if (transaction.payment_order_ids and not
-                    transaction.payment_order_id):
-                    res[transaction.id] = True
         return res
     
     def clear_and_write(self, cr, uid, ids, vals=None, context=None):
@@ -1508,14 +1280,10 @@
                     'match_type',
                     'move_line_id', 
                     'invoice_id', 
-                    'manual_invoice_id', 
-                    'manual_move_line_id',
-                    'payment_line_id',
                     ]] +
                      [(x, [(6, 0, [])]) for x in [
                         'move_line_ids',
                         'invoice_ids',
-                        'payment_order_ids',
                         ]]))
         write_vals.update(vals or {})
         return self.write(cr, uid, ids, write_vals, context=context)
@@ -1561,22 +1329,40 @@
 
         return res
 
-    def unlink(self, cr, uid, ids, context=None):
-        """
-        Unsplit if this if a split transaction
-        """
-        for this in self.browse(cr, uid, ids, context):
-            if this.parent_id:
-                this.parent_id.write(
-                        {'transferred_amount':
-                            this.parent_id.transferred_amount + \
-                                    this.transferred_amount,
-                        })
-                this.parent_id.refresh()
-        return super(banking_import_transaction, self).unlink(
-                cr, uid, ids, context=context)
-
-
+<<<<<<< TREE
+    def unlink(self, cr, uid, ids, context=None):
+        """
+        Unsplit if this if a split transaction
+        """
+        for this in self.browse(cr, uid, ids, context):
+            if this.parent_id:
+                this.parent_id.write(
+                        {'transferred_amount':
+                            this.parent_id.transferred_amount + \
+                                    this.transferred_amount,
+                        })
+                this.parent_id.refresh()
+        return super(banking_import_transaction, self).unlink(
+                cr, uid, ids, context=context)
+
+
+=======
+    def unlink(self, cr, uid, ids, context=None):
+        """
+        Unsplit if this if a split transaction
+        """
+        for this in self.browse(cr, uid, ids, context):
+            if this.parent_id:
+                this.parent_id.write(
+                        {'transferred_amount':
+                            this.parent_id.transferred_amount + \
+                                    this.transferred_amount,
+                        })
+                this.parent_id.refresh()
+        return super(banking_import_transaction, self).unlink(
+                cr, uid, ids, context=context)
+
+>>>>>>> MERGE-SOURCE
     column_map = {
         # used in bank_import.py, converting non-osv transactions
         'statement_id': 'statement',
@@ -1599,9 +1385,9 @@
         'exchange_rate': fields.float('exchange_rate'),
         'transferred_amount': fields.float('transferred_amount'),
         'message': fields.char('message', size=1024),
-        'remote_owner': fields.char('remote_owner', size=24),
-        'remote_owner_address': fields.char('remote_owner_address', size=24),
-        'remote_owner_city': fields.char('remote_owner_city', size=24),
+        'remote_owner': fields.char('remote_owner', size=128),
+        'remote_owner_address': fields.char('remote_owner_address', size=256),
+        'remote_owner_city': fields.char('remote_owner_city', size=128),
         'remote_owner_postalcode': fields.char('remote_owner_postalcode', size=24),
         'remote_owner_country_code': fields.char('remote_owner_country_code', size=24),
         'remote_owner_custno': fields.char('remote_owner_custno', size=24),
@@ -1628,31 +1414,37 @@
         'duplicate': fields.boolean('duplicate'),
         'statement_line_id': fields.many2one(
             'account.bank.statement.line', 'Statement line',
+<<<<<<< TREE
             ondelete='cascade'),
         'statement_id': fields.many2one(
             'account.bank.statement', 'Statement'),
+=======
+            ondelete='cascade'),
+        'statement_id': fields.many2one(
+            'account.bank.statement', 'Statement',
+            ondelete='CASCADE'),
+>>>>>>> MERGE-SOURCE
         'parent_id': fields.many2one(
             'banking.import.transaction', 'Split off from this transaction'),
         # match fields
-        'match_type': fields.selection(
-            [('manual', 'Manual'), ('move','Move'), ('invoice', 'Invoice'),
-             ('payment', 'Payment'), ('payment_order', 'Payment order'),
-             ('storno', 'Storno')],
-            'Match type'),
+        'match_type': fields.selection([
+                ('move','Move'),
+                ('invoice', 'Invoice'),
+                ('payment', 'Payment line'),
+                ('payment_order', 'Payment order'),
+                ('storno', 'Storno'),
+                ('manual', 'Manual'),
+                ('payment_manual', 'Payment line (manual)'),
+                ('payment_order_manual', 'Payment order (manual)'),
+                ], 'Match type'),
         'match_multi': fields.function(
             _get_match_multi, method=True, string='Multi match',
             type='boolean'),
-        'payment_order_ids': fields.many2many(
-            'payment.order', 'banking_transaction_payment_order_rel',
-            'order_id', 'transaction_id', 'Payment orders'),
-        'payment_order_id': fields.many2one(
-            'payment.order', 'Payment order to reconcile'),
         'move_line_ids': fields.many2many(
             'account.move.line', 'banking_transaction_move_line_rel',
             'move_line_id', 'transaction_id', 'Matching entries'),
         'move_line_id': fields.many2one(
             'account.move.line', 'Entry to reconcile'),
-        'payment_line_id': fields.many2one('payment.line', 'Payment line'),
         'invoice_ids': fields.many2many(
             'account.invoice', 'banking_transaction_invoice_rel',
             'invoice_id', 'transaction_id', 'Matching invoices'),
@@ -1676,7 +1468,7 @@
                   "or reconcile it with the payment(s)"),
             ),
         'writeoff_amount': fields.float('Difference Amount'),
-        # Legacy field: to be removed after 6.2
+        # Legacy field: to be removed after 7.0
         'writeoff_move_line_id': fields.many2one(
             'account.move.line', 'Write off move line'),
         'writeoff_analytic_id': fields.many2one(
@@ -1694,7 +1486,8 @@
 
 banking_import_transaction()
 
-class account_bank_statement_line(osv.osv):
+
+class account_bank_statement_line(orm.Model):
     _inherit = 'account.bank.statement.line'
 
     def _get_link_partner_ok(
@@ -1730,19 +1523,33 @@
             string='Possible duplicate import', readonly=True),
         'match_type': fields.related(
             'import_transaction_id', 'match_type', type='selection',
-            selection=[('manual', 'Manual'), ('move','Move'),
-                       ('invoice', 'Invoice'), ('payment', 'Payment'),
-                       ('payment_order', 'Payment order'),
-                       ('storno', 'Storno')], 
+            selection=[
+                ('move','Move'),
+                ('invoice', 'Invoice'),
+                ('payment', 'Payment line'),
+                ('payment_order', 'Payment order'),
+                ('storno', 'Storno'),
+                ('manual', 'Manual'),
+                ('payment_manual', 'Payment line (manual)'),
+                ('payment_order_manual', 'Payment order (manual)'),
+                ], 
             string='Match type', readonly=True,),
         'state': fields.selection(
             [('draft', 'Draft'), ('confirmed', 'Confirmed')], 'State',
             readonly=True, required=True),
-        'link_partner_ok': fields.function(
-            _get_link_partner_ok, type='boolean',
-            string='Can link partner'),
-        'parent_id': fields.many2one('account.bank.statement.line',
-            'Parent'),
+<<<<<<< TREE
+        'link_partner_ok': fields.function(
+            _get_link_partner_ok, type='boolean',
+            string='Can link partner'),
+        'parent_id': fields.many2one('account.bank.statement.line',
+            'Parent'),
+=======
+        'parent_id': fields.many2one('account.bank.statement.line',
+            'Parent'),
+        'link_partner_ok': fields.function(
+            _get_link_partner_ok, type='boolean',
+            string='Can link partner'),
+>>>>>>> MERGE-SOURCE
         }
 
     _defaults = {
@@ -1849,21 +1656,20 @@
         """
         statement_pool = self.pool.get('account.bank.statement')
         obj_seq = self.pool.get('ir.sequence')
-        move_pool = self.pool.get('account.move')
         import_transaction_obj = self.pool.get('banking.import.transaction')
 
         for st_line in self.browse(cr, uid, ids, context):
             if st_line.state != 'draft':
                 continue
             if st_line.duplicate:
-                raise osv.except_osv(
+                raise orm.except_orm(
                     _('Bank transfer flagged as duplicate'),
                     _("You cannot confirm a bank transfer marked as a "
                       "duplicate (%s.%s)") % 
                     (st_line.statement_id.name, st_line.name,))
             if st_line.analytic_account_id:
                 if not st_line.statement_id.journal_id.analytic_journal_id:
-                    raise osv.except_osv(
+                    raise orm.except_orm(
                         _('No Analytic Journal !'),
                         _("You have to define an analytic journal on the '%s' "
                           "journal!") % (st_line.statement_id.journal_id.name,))
@@ -1907,7 +1713,6 @@
             ids = [ids]
         import_transaction_obj = self.pool.get('banking.import.transaction')
         move_pool = self.pool.get('account.move')
-        transaction_cancel_ids = []
         set_draft_ids = []
         move_unlink_ids = []
         # harvest ids for various actions
@@ -1915,7 +1720,7 @@
             if st_line.state != 'confirmed':
                 continue
             if st_line.statement_id.state != 'draft':
-                raise osv.except_osv(
+                raise orm.except_orm(
                     _("Cannot cancel bank transaction"),
                     _("The bank statement that this transaction belongs to has "
                       "already been confirmed"))
@@ -1952,9 +1757,10 @@
             ids = [ids]
         for line in self.browse(cr, uid, ids, context=context):
             if line.state == 'confirmed':
-                raise osv.except_osv(
+                raise orm.except_orm(
                     _('Confirmed Statement Line'),
                     _("You cannot delete a confirmed Statement Line"
+<<<<<<< TREE
                       ": '%s'" % line.name))
             if line.parent_id:
                 line.parent_id.write(
@@ -1962,6 +1768,15 @@
                             'amount': line.parent_id.amount + line.amount,
                         })
                 line.parent_id.refresh()
+=======
+                      ": '%s'") % line.name)
+            if line.parent_id:
+                line.parent_id.write(
+                        {
+                            'amount': line.parent_id.amount + line.amount,
+                        })
+                line.parent_id.refresh()
+>>>>>>> MERGE-SOURCE
         return super(account_bank_statement_line, self).unlink(
             cr, uid, ids, context=context)
 
@@ -2001,6 +1816,7 @@
                         'import_transaction_id': res},
                     context=context)
 
+<<<<<<< TREE
     def split_off(self, cr, uid, ids, amount, context=None):
         """
         Create a child statement line with amount, deduce that from this line,
@@ -2048,16 +1864,64 @@
 account_bank_statement_line()
 
 class account_bank_statement(osv.osv):
+=======
+    def split_off(self, cr, uid, ids, amount, context=None):
+        """
+        Create a child statement line with amount, deduce that from this line,
+        change transactions accordingly
+        """
+        if context is None:
+            context = {}
+
+        transaction_pool = self.pool.get('banking.import.transaction')
+    
+        child_statement_ids = []
+        for this in self.browse(cr, uid, ids, context):
+            transaction_data = transaction_pool.copy_data(
+                    cr, uid, this.import_transaction_id.id)
+            transaction_data['transferred_amount'] = amount
+            transaction_data['message'] = (
+                    (transaction_data['message'] or '') + _(' (split)'))
+            transaction_data['parent_id'] = this.import_transaction_id.id
+            transaction_id = transaction_pool.create(
+                    cr,
+                    uid,
+                    transaction_data,
+                    context=dict(
+                        context, transaction_no_duplicate_search=True))
+
+            statement_line_data = self.copy_data(
+                    cr, uid, this.id)
+            statement_line_data['amount'] = amount
+            statement_line_data['name'] = (
+                    (statement_line_data['name'] or '') + _(' (split)'))
+            statement_line_data['import_transaction_id'] = transaction_id
+            statement_line_data['parent_id'] = this.id
+            statement_line_id = self.create(
+                cr, uid, statement_line_data, context=context)
+
+            child_statement_ids.append(statement_line_id)
+            transaction_pool.write(
+                cr, uid, transaction_id, {
+                    'statement_line_id': statement_line_id,
+                    }, context=context)
+            this.write({'amount': this.amount - amount})
+
+        return child_statement_ids
+
+
+class account_bank_statement(orm.Model):
+>>>>>>> MERGE-SOURCE
     _inherit = 'account.bank.statement'
 
-    def _end_balance(self, cursor, user, ids, name, attr, context=None):
+    def _end_balance(self, cr, uid, ids, name, attr, context=None):
         """
         This method taken from account/account_bank_statement.py and
         altered to take the statement line subflow into account
         """
         res = {}
     
-        statements = self.browse(cursor, user, ids, context=context)
+        statements = self.browse(cr, uid, ids, context=context)
         for statement in statements:
             res[statement.id] = statement.balance_start
 
@@ -2083,19 +1947,21 @@
             self.balance_check(cr, uid, st.id, journal_type=j_type, context=context)
             if (not st.journal_id.default_credit_account_id) \
                     or (not st.journal_id.default_debit_account_id):
-                raise osv.except_osv(_('Configuration Error !'),
+                raise orm.except_orm(_('Configuration Error !'),
                         _('Please verify that an account is defined in the journal.'))
 
             # protect against misguided manual changes
             for line in st.move_line_ids:
                 if line.state != 'valid':
-                    raise osv.except_osv(_('Error !'),
+                    raise orm.except_orm(_('Error !'),
                             _('The account entries lines are not in valid state.'))
 
             line_obj.confirm(cr, uid, [line.id for line in st.line_ids], context)
             st.refresh()
-            self.log(cr, uid, st.id, _('Statement %s is confirmed, journal '
-                                       'items are created.') % (st.name,))
+            self.message_post(
+                cr, uid, [st.id],
+                body=_('Statement %s confirmed, journal items were created.')
+                % (st.name,), context=context)
         return self.write(cr, uid, ids, {'state':'confirm'}, context=context)
 
     def button_cancel(self, cr, uid, ids, context=None):
@@ -2114,8 +1980,12 @@
         for st in self.browse(cr, uid, ids, context=context):
             for line in st.line_ids:
                 if line.state == 'confirmed':
-                    raise osv.except_osv(_('Confirmed Statement Lines'), _("You cannot delete a Statement with confirmed Statement Lines: '%s'" % st.name))
-        return super(account_bank_statement,self).unlink(cr, uid, ids, context=context)
+                    raise orm.except_orm(
+                        _('Confirmed Statement Lines'),
+                        _("You cannot delete a Statement with confirmed "
+                          "Statement Lines: '%s'") % st.name)
+        return super(account_bank_statement, self).unlink(
+            cr, uid, ids, context=context)
 
     _columns = {
         # override this field *only* to replace the 

=== modified file 'account_banking/data/account_banking_data.xml'
--- account_banking/data/account_banking_data.xml	2012-04-14 08:58:58 +0000
+++ account_banking/data/account_banking_data.xml	2013-07-25 08:56:25 +0000
@@ -20,12 +20,5 @@
         <record id="base_iban.bank_swift_field" model="res.partner.bank.type.field">
             <field eval="False" name="required"/>
         </record>
-        <!-- Add manual bank transfer as default payment option -->
-        <record model="payment.mode.type" id="account_banking.manual_bank_tranfer">
-            <field name="name">Manual Bank Transfer</field>
-            <field name="code">BANKMAN</field>
-            <field name="suitable_bank_types"
-                eval="[(6,0,[ref('base.bank_normal'),ref('base_iban.bank_iban'),])]" />
-        </record>
     </data>
 </openerp>

=== modified file 'account_banking/i18n/nl.po'
--- account_banking/i18n/nl.po	2013-05-24 06:40:45 +0000
+++ account_banking/i18n/nl.po	2013-07-25 08:56:25 +0000
@@ -1771,3 +1771,13 @@
 #: constraint:account.move.line:0
 msgid "You can not create move line on view account."
 msgstr "U kunt geen boekingsregel creëren op een zichtrekening"
+
+#. module: account_banking_payment
+#: field:banking.transaction.wizard,manual_payment_line_id:0
+msgid "Match this payment line"
+msgstr "Match deze betaling lijn"
+
+#. module: account_banking_payment
+#: field:banking.transaction.wizard,manual_payment_order_id:0
+msgid "Match this payment order"
+msgstr "Match deze betalingsopdracht"

=== modified file 'account_banking/migrations/0.1.81/post-set-statement-line-state.py'
--- account_banking/migrations/0.1.81/post-set-statement-line-state.py	2011-12-27 12:00:52 +0000
+++ account_banking/migrations/0.1.81/post-set-statement-line-state.py	2013-07-25 08:56:25 +0000
@@ -4,16 +4,16 @@
 #    Copyright (C) 2011 Therp BV (<http://therp.nl>)
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking/parsers/__init__.py'
--- account_banking/parsers/__init__.py	2010-01-26 20:55:24 +0000
+++ account_banking/parsers/__init__.py	2013-07-25 08:56:25 +0000
@@ -5,16 +5,16 @@
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking/parsers/convert.py'
--- account_banking/parsers/convert.py	2011-03-09 12:26:49 +0000
+++ account_banking/parsers/convert.py	2013-07-25 08:56:25 +0000
@@ -1,20 +1,20 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
 ##############################################################################
 #
 #    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking/parsers/models.py'
--- account_banking/parsers/models.py	2012-01-17 08:48:10 +0000
+++ account_banking/parsers/models.py	2013-07-25 08:56:25 +0000
@@ -5,16 +5,16 @@
 #  All Rights Reserved
 #
 #  This program is free software: you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
+#  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,
 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
+#  GNU Affero General Public License for more details.
 #
-#  You should have received a copy of the GNU General Public License
+#  You should have received a copy of the GNU Affero General Public License
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking/record.py'
--- account_banking/record.py	2011-03-10 21:54:37 +0000
+++ account_banking/record.py	2013-07-25 08:56:25 +0000
@@ -5,16 +5,16 @@
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking/security/ir.model.access.csv'
--- account_banking/security/ir.model.access.csv	2011-12-21 15:49:58 +0000
+++ account_banking/security/ir.model.access.csv	2013-07-25 08:56:25 +0000
@@ -2,6 +2,5 @@
 "access_account_banking_settings","account.banking.account.settings","model_account_banking_account_settings","account.group_account_manager",1,1,1,1
 "access_account_banking_settings_user","account.banking.account.settings user","model_account_banking_account_settings","account.group_account_user",1,0,0,0
 "access_account_banking_import","account.bankimport","model_account_banking_imported_file","account.group_account_user",1,1,1,1
-"access_payment_mode_type","payment.mode.type","model_payment_mode_type","account_payment.group_account_payment",1,1,1,1
 "access_banking_import_transaction","Banking addons - Bank import transaction","model_banking_import_transaction","account.group_account_user",1,1,1,1
 "access_banking_transaction_wizard","Banking addons - Transaction wizard","model_banking_transaction_wizard","account.group_account_user",1,1,1,1

=== modified file 'account_banking/sepa/__init__.py'
--- account_banking/sepa/__init__.py	2010-06-29 14:58:52 +0000
+++ account_banking/sepa/__init__.py	2013-07-25 08:56:25 +0000
@@ -5,16 +5,16 @@
 #  All Rights Reserved
 #
 #  This program is free software: you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
+#  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,
 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
+#  GNU Affero General Public License for more details.
 #
-#  You should have received a copy of the GNU General Public License
+#  You should have received a copy of the GNU Affero General Public License
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking/sepa/iban.py'
--- account_banking/sepa/iban.py	2012-05-03 09:58:01 +0000
+++ account_banking/sepa/iban.py	2013-07-25 08:56:25 +0000
@@ -5,16 +5,16 @@
 #  All Rights Reserved
 #
 #  This program is free software: you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
+#  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,
 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
+#  GNU Affero General Public License for more details.
 #
-#  You should have received a copy of the GNU General Public License
+#  You should have received a copy of the GNU Affero General Public License
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking/sepa/online.py'
--- account_banking/sepa/online.py	2012-01-12 09:50:06 +0000
+++ account_banking/sepa/online.py	2013-07-25 08:56:25 +0000
@@ -5,16 +5,16 @@
 #  All Rights Reserved
 #
 #  This program is free software: you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
+#  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,
 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
+#  GNU Affero General Public License for more details.
 #
-#  You should have received a copy of the GNU General Public License
+#  You should have received a copy of the GNU Affero General Public License
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking/sepa/postalcode.py'
--- account_banking/sepa/postalcode.py	2012-05-03 10:28:10 +0000
+++ account_banking/sepa/postalcode.py	2013-07-25 08:56:25 +0000
@@ -5,16 +5,16 @@
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking/sepa/urlagent.py'
--- account_banking/sepa/urlagent.py	2010-02-25 23:18:37 +0000
+++ account_banking/sepa/urlagent.py	2013-07-25 08:56:25 +0000
@@ -5,16 +5,16 @@
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking/static/src/js/account_banking.js'
--- account_banking/static/src/js/account_banking.js	2013-04-24 09:21:01 +0000
+++ account_banking/static/src/js/account_banking.js	2013-07-25 08:56:25 +0000
@@ -1,3 +1,4 @@
+<<<<<<< TREE
 /*############################################################################
 #
 #    Copyright (C) 2013 Therp BV (<http://therp.nl>).
@@ -49,3 +50,56 @@
         },
     });
 }
+=======
+/*############################################################################
+#
+#    Copyright (C) 2013 Therp BV (<http://therp.nl>).
+#            
+#    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 (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+############################################################################*/
+
+openerp.account_banking = function(instance)
+{
+    var _t = instance.web._t;
+    instance.web.Dialog.include(
+    {
+        close: function()
+        {
+            this._super.apply(this, arguments);
+            if (this.dialog_title == _t("Match transaction"))
+            {   
+                // The match wizard can create or unlink a statement line
+                // Force a reload of the view so that the correct lines
+                // are shown.
+                var parent = this.getParent()
+                if (parent)
+                {
+                    var child = this.getParent().getChildren()[0];
+                    if (child.views) {
+                        _.each(child.views, function(view)
+                               {
+                                   if (view && view.controller)
+                                   {
+                                       view.controller.reload();
+                                   }
+                               }
+                              );
+                    }
+                }
+            }
+        },
+    });
+}
+>>>>>>> MERGE-SOURCE

=== modified file 'account_banking/struct.py'
--- account_banking/struct.py	2010-02-03 23:36:03 +0000
+++ account_banking/struct.py	2013-07-25 08:56:25 +0000
@@ -5,16 +5,16 @@
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking/wizard/__init__.py'
--- account_banking/wizard/__init__.py	2013-04-25 12:49:02 +0000
+++ account_banking/wizard/__init__.py	2013-07-25 08:56:25 +0000
@@ -5,22 +5,20 @@
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
 import bank_import
-import bank_payment_manual
-import account_payment_order
 import banking_transaction_wizard
 import link_partner
 

=== modified file 'account_banking/wizard/bank_import.py'
--- account_banking/wizard/bank_import.py	2012-07-11 10:37:31 +0000
+++ account_banking/wizard/bank_import.py	2013-07-25 08:56:25 +0000
@@ -5,16 +5,16 @@
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
@@ -28,19 +28,15 @@
 The parsing is done in the parser modules. Every parser module is required to
 use parser.models as a mean of communication with the business logic.
 '''
-from osv import osv, fields
-import time
-import netsvc
 import base64
 import datetime
-from tools import config
-from tools.translate import _
-from account_banking.parsers import models
-from account_banking.parsers.convert import *
-from account_banking.struct import struct
-from account_banking import sepa
-from banktools import *
-import decimal_precision as dp
+from openerp.osv import orm, fields
+from openerp.tools.translate import _
+from openerp.addons.account_banking.parsers import models
+from openerp.addons.account_banking.parsers import convert
+from openerp.addons.account_banking.struct import struct
+from openerp.addons.account_banking.wizard import banktools
+from openerp.addons.decimal_precision import decimal_precision as dp
 
 bt = models.mem_bank_transaction
 
@@ -54,7 +50,8 @@
     '''
     return models.parser_type.get_parser_types()
 
-class banking_import_line(osv.osv_memory):
+
+class banking_import_line(orm.TransientModel):
     _name = 'banking.import.line'
     _description = 'Bank import lines'
     _columns = {
@@ -85,32 +82,28 @@
         'invoice_ids': fields.many2many(
             'account.invoice', 'banking_import_line_invoice_rel',
             'line_id', 'invoice_id'),
-        'payment_order_id': fields.many2one('payment.order', 'Payment order'),
         'partner_bank_id': fields.many2one('res.partner.bank', 'Bank Account'),
         'transaction_type': fields.selection([
                 # TODO: payment terminal etc...
                 ('invoice', 'Invoice payment'),
-                ('payment_order_line', 'Payment from a payment order'),
-                ('payment_order', 'Aggregate payment order'),
                 ('storno', 'Canceled debit order'),
                 ('bank_costs', 'Bank costs'),
                 ('unknown', 'Unknown'),
                 ], 'Transaction type'),
         'duplicate': fields.boolean('Duplicate'),
         }
-banking_import_line()
-    
-
-class banking_import(osv.osv_memory):
+
+
+class banking_import(orm.TransientModel):
     _name = 'account.banking.bank.import'
 
-    def import_statements_file(self, cursor, uid, ids, context):
+    def import_statements_file(self, cr, uid, ids, context):
         '''
         Import bank statements / bank transactions file.
         This method is a wrapper for the business logic on the transaction.
         The parser modules represent the decoding logic.
         '''
-        banking_import = self.browse(cursor, uid, ids, context)[0]
+        banking_import = self.browse(cr, uid, ids, context)[0]
         statements_file = banking_import.file
         data = base64.decodestring(statements_file)
 
@@ -124,7 +117,7 @@
         parser_code = banking_import.parser
         parser = models.create_parser(parser_code)
         if not parser:
-            raise osv.except_osv(
+            raise orm.except_orm(
                 _('ERROR!'),
                 _('Unable to import parser %(parser)s. Parser class not found.') %
                 {'parser': parser_code}
@@ -132,19 +125,19 @@
 
         # Get the company
         company = (banking_import.company or
-                   user_obj.browse(cursor, uid, uid, context).company_id)
+                   user_obj.browse(cr, uid, uid, context).company_id)
 
         # Parse the file
-        statements = parser.parse(cursor, data)
+        statements = parser.parse(cr, data)
 
         if any([x for x in statements if not x.is_valid()]):
-            raise osv.except_osv(
+            raise orm.except_orm(
                 _('ERROR!'),
                 _('The imported statements appear to be invalid! Check your file.')
             )
 
         # Create the file now, as the statements need to be linked to it
-        import_id = statement_file_obj.create(cursor, uid, dict(
+        import_id = statement_file_obj.create(cr, uid, dict(
             company_id = company.id,
             file = statements_file,
             state = 'unfinished',
@@ -190,8 +183,8 @@
 
             else:
                 # Pull account info/currency
-                account_info = get_company_bank_account(
-                    self.pool, cursor, uid, statement.local_account,
+                account_info = banktools.get_company_bank_account(
+                    self.pool, cr, uid, statement.local_account,
                     statement.local_currency, company, results.log
                 )
                 if not account_info:
@@ -228,7 +221,7 @@
                and account_info.currency_id.name != statement.local_currency:
                 # TODO: convert currencies?
                 results.log.append(
-                    _('Statement %(statement_id)s for account %(bank_account)s' 
+                    _('Statement %(statement_id)s for account %(bank_account)s'
                       ' uses different currency than the defined bank journal.'
                      ) % {
                          'bank_account': statement.local_account,
@@ -240,14 +233,14 @@
                 continue
 
             # Check existence of previous statement
-            # Less well defined formats can resort to a 
+            # Less well defined formats can resort to a
             # dynamically generated statement identification
             # (e.g. a datetime string of the moment of import)
-            # and have potential duplicates flagged by the 
+            # and have potential duplicates flagged by the
             # matching procedure
-            statement_ids = statement_obj.search(cursor, uid, [
+            statement_ids = statement_obj.search(cr, uid, [
                 ('name', '=', statement.id),
-                ('date', '=', date2str(statement.date)),
+                ('date', '=', convert.date2str(statement.date)),
             ])
             if statement_ids:
                 results.log.append(
@@ -258,10 +251,13 @@
                 continue
 
             # Get the period for the statement (as bank statement object checks this)
-            period_ids = period_obj.search(cursor, uid, [('company_id','=',company.id),
-                                                         ('date_start','<=',statement.date),
-                                                         ('date_stop','>=',statement.date),
-                                                         ('special', '=', False)])
+            period_ids = period_obj.search(
+                cr, uid, [
+                    ('company_id', '=', company.id),
+                    ('date_start', '<=', statement.date),
+                    ('date_stop', '>=', statement.date),
+                    ('special', '=', False),
+                    ], context=context)
 
             if not period_ids:
                 results.log.append(
@@ -274,10 +270,10 @@
                 continue
 
             # Create the bank statement record
-            statement_id = statement_obj.create(cursor, uid, dict(
+            statement_id = statement_obj.create(cr, uid, dict(
                 name = statement.id,
                 journal_id = account_info.journal_id.id,
-                date = date2str(statement.date),
+                date = convert.date2str(statement.date),
                 balance_start = statement.start_balance,
                 balance_end_real = statement.end_balance,
                 balance_end = statement.end_balance,
@@ -305,24 +301,22 @@
                 values['local_account'] = statement.local_account
                 values['local_currency'] = statement.local_currency
 
-                transaction_id = import_transaction_obj.create(cursor, uid, values, context=context)
-                if transaction_id:
-                    transaction_ids.append(transaction_id)
-                else:
-                    osv.except_osv('Failed to create an import transaction resource','')
-            
+                transaction_id = import_transaction_obj.create(
+                    cr, uid, values, context=context)
+                transaction_ids.append(transaction_id)
+
             results.stat_loaded_cnt += 1
 
-        import_transaction_obj.match(cursor, uid, transaction_ids, results=results, context=context)
-            
+        import_transaction_obj.match(cr, uid, transaction_ids, results=results, context=context)
+
         #recompute statement end_balance for validation
         statement_obj.button_dummy(
-            cursor, uid, imported_statement_ids, context=context)
+            cr, uid, imported_statement_ids, context=context)
 
 
             # Original code. Didn't take workflow logistics into account...
             #
-            #cursor.execute(
+            #cr.execute(
             #    "UPDATE payment_order o "
             #    "SET state = 'done', "
             #        "date_done = '%s' "
@@ -359,18 +353,18 @@
             '%s: %s' % (_('Number of bank costs invoices created'),
                         results.bank_costs_invoice_cnt),
             '',
-            '%s:' % ('Error report'),
+            '%s:' % (_('Error report')),
             '',
         ]
         text_log = '\n'.join(report + results.log)
         state = results.error_cnt and 'error' or 'ready'
-        statement_file_obj.write(cursor, uid, import_id, dict(
+        statement_file_obj.write(cr, uid, import_id, dict(
             state = state, log = text_log,
             ), context)
         if not imported_statement_ids or not results.trans_loaded_cnt:
             # file state can be 'ready' while import state is 'error'
             state = 'error'
-        self.write(cursor, uid, [ids[0]], dict(
+        self.write(cr, uid, [ids[0]], dict(
                 import_id = import_id, log = text_log, state = state,
                 statement_ids = [(6, 0, imported_statement_ids)],
                 ), context)
@@ -388,6 +382,12 @@
             'res_id': ids[0] or False,
         }
 
+    def _get_file_name(self, cr, uid, ids, name, args, context={}):
+        ret_val = {}
+        for rec_id in ids:
+            ret_val[rec_id] = "{0}_{1}.txt".format(self._table, rec_id)
+        return ret_val
+
     _columns = {
         'company': fields.many2one(
             'res.company', 'Company', required=True,
@@ -425,13 +425,15 @@
             'State', readonly=True),
         'import_id': fields.many2one(
             'account.banking.imported.file', 'Import File'),
-        # osv_memory does not seem to support one2many
         'statement_ids': fields.many2many(
             'account.bank.statement', 'rel_wiz_statements', 'wizard_id',
             'statement_id', 'Imported Bank Statements'),
         'line_ids': fields.one2many(
             'banking.import.line', 'banking_import_id', 'Transactions',
             ),
+        'file_name': fields.function(_get_file_name, method=True,
+                     string="File Name", type="char",
+                     size=256),
         }
 
     def _default_parser_type(self, cr, uid, context=None):
@@ -445,7 +447,3 @@
             cr, uid, 'bank.import.transaction', context=c),
         'parser': _default_parser_type,
         }
-
-banking_import()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'account_banking/wizard/bank_import_view.xml'
--- account_banking/wizard/bank_import_view.xml	2012-05-02 15:09:49 +0000
+++ account_banking/wizard/bank_import_view.xml	2013-07-25 08:56:25 +0000
@@ -4,66 +4,66 @@
         <record id="view_banking_import" model="ir.ui.view">
             <field name="name">account.banking.bank.import</field>
             <field name="model">account.banking.bank.import</field>
-            <field name="type">form</field>
             <field name="arch" type="xml">
-		<form string="Import Bank Transactions File">
-		    <group colspan="4" states="init,ready,error">
-			<separator colspan="4" string="Select the processing details:"/>
-			<field name="company" colspan="1"/>
-			<field name="file"/>
-			<newline />
-			<field name="parser"/>
-			<field name="state" invisible="1"/>
-		    </group>
-                    <notebook colspan="4">
-                        <page attrs="{'invisible': [('state', '!=', 'review')]}" string="Transactions">
-                            <field name="line_ids" colspan="4" nolabel="1">
-                                <tree string="Transaction" colors="red:duplicate;blue:reconcile_id">
-                                    <field name="date"/>
-                                    <field name="amount"/>
-                                    <field name="ref"/>
-                                    <field name="partner_bank_id"/>
-                                    <field name="partner_id"/>
-                                    <field name="account_id"/>
-                                    <field name="reconcile_id"/>
-                                    <field name="duplicate"/>
-                                </tree>
-                            </field>
-                        </page>
-                        <page attrs="{'invisible': [('state', '=', 'init')]}" string="Log">
-                            <field name="log" colspan="4" nolabel="1" width="500"/>
-                        </page>
-                        <page attrs="{'invisible': [('state', '!=', 'ready')]}" string="Statements">
-                            <field name="statement_ids" colspan="4" nolabel="1"
-                                   attrs="{'invisible': [('state', '!=', 'ready')]}" />
-                        </page>
-                    </notebook>
-		    <group colspan="2" >
-			<button icon="gtk-cancel"
-				special="cancel"
-                                states="init"
-				string="Cancel"/>
-			<button icon="gtk-ok"
-				string="Import"
-                                states="init" 
-				name="import_statements_file"
-				type="object"/>
-                        <button icon="gtk-close"
-                                special="cancel"
-                                string="Close"
-                                states="ready,error"/>
-                        <button icon="gtk-close"
-                                name="cancel_statement_lines"
-                                type="object" 
-                                string="Cancel"
-                                states="review"/>
-                        <button icon="gtk-ok"
-                                name="create_statement_lines"
-                                type="object" 
-                                string="Confirm"
-                                states="review"/>
-		    </group>
-		</form>
+		    <form string="Import Bank Transactions File" version="7.0">
+		        <group colspan="4" states="init,ready,error">
+			        <separator colspan="4" string="Select the processing details:"/>
+			        <field name="company" colspan="1"/>
+			        <field name="file_name" invisible="1"/>
+			        <field name="file" filename="file_name"/>
+			        <newline />
+			        <field name="parser"/>
+			        <field name="state" invisible="1"/>
+		        </group>
+                <notebook colspan="4">
+                    <page attrs="{'invisible': [('state', '!=', 'review')]}" string="Transactions">
+                        <field name="line_ids" colspan="4" nolabel="1">
+                            <tree string="Transaction" colors="red:duplicate;blue:reconcile_id">
+                                <field name="date"/>
+                                <field name="amount"/>
+                                <field name="ref"/>
+                                <field name="partner_bank_id"/>
+                                <field name="partner_id"/>
+                                <field name="account_id"/>
+                                <field name="reconcile_id"/>
+                                <field name="duplicate"/>
+                            </tree>
+                        </field>
+                    </page>
+                    <page attrs="{'invisible': [('state', '=', 'init')]}" string="Log">
+                        <field name="log" colspan="4" nolabel="1" width="500"/>
+                    </page>
+                    <page attrs="{'invisible': [('state', '!=', 'ready')]}" string="Statements">
+                        <field name="statement_ids" colspan="4" nolabel="1"
+                               attrs="{'invisible': [('state', '!=', 'ready')]}" />
+                    </page>
+                </notebook>
+		        <footer>
+                    <div attrs="{'invisible': [('state', '!=', 'init')]}">
+                        <button string="Import" class="oe_highlight"
+                            states="init" name="import_statements_file"
+				            type="object"/>
+				         or
+			            <button class="oe_link" special="cancel"
+                            states="init" string="Cancel"/>
+                    </div>
+                    
+                    <button icon="gtk-close"
+                            special="cancel"
+                            string="Close"
+                            states="ready,error"/>
+                    <button icon="gtk-close"
+                            name="cancel_statement_lines"
+                            type="object" 
+                            string="Cancel"
+                            states="review"/>
+                    <button icon="gtk-ok"
+                            name="create_statement_lines"
+                            type="object" 
+                            string="Confirm"
+                                    states="review"/>
+		        </footer>
+		    </form>
 	    </field>
         </record>
 

=== modified file 'account_banking/wizard/banking_transaction_wizard.py'
--- account_banking/wizard/banking_transaction_wizard.py	2013-06-10 10:19:50 +0000
+++ account_banking/wizard/banking_transaction_wizard.py	2013-07-25 08:56:25 +0000
@@ -2,25 +2,26 @@
 ##############################################################################
 #
 #    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
-#              (C) 2011 Therp BV (<http://therp.nl>).
+#              (C) 2011 - 2013 Therp BV (<http://therp.nl>).
 #              (C) 2011 Smile (<http://smile.fr>).
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
-from osv import osv, fields
+
+from osv import orm, fields
 from openerp.tools.translate import _
 
 """
@@ -31,7 +32,8 @@
 
 """
 
-class banking_transaction_wizard(osv.osv_memory):
+
+class banking_transaction_wizard(orm.TransientModel):
     _name = 'banking.transaction.wizard'
     _description = 'Match transaction'
 
@@ -78,7 +80,7 @@
             cr, uid, ids[0], ['import_transaction_id'],
             context=context)['import_transaction_id'][0] # many2one tuple
         import_transaction_obj.match(cr, uid, [trans_id], context=context)
-        return True
+        return self.create_act_window(cr, uid, ids, context=None)
     
     def write(self, cr, uid, ids, vals, context=None):
         """
@@ -88,12 +90,15 @@
         statement_line_obj = self.pool.get('account.bank.statement.line')
         transaction_obj = self.pool.get('banking.import.transaction')
 
-        if not vals:
+        if not vals or not ids:
             return True
 
+        wiz = self.browse(cr, uid, ids[0], context=context)
+
         # The following fields get never written
         # they are just triggers for manual matching
         # which populates regular fields on the transaction
+<<<<<<< TREE
         manual_invoice_ids = vals.pop('manual_invoice_ids', [])
         manual_move_line_ids = vals.pop('manual_move_line_ids', [])
 
@@ -121,23 +126,27 @@
                     transaction_vals, context=context)
 
         # write other fields to the wizard model
+=======
+        manual_invoice_ids = vals.pop('manual_invoice_ids', [])
+        manual_move_line_ids = vals.pop('manual_move_line_ids', [])
+
+>>>>>>> MERGE-SOURCE
         res = super(banking_transaction_wizard, self).write(
-            cr, uid, ids, wizard_vals, context=context)
+            cr, uid, ids, vals, context=context)
+        wiz.refresh()
 
-        # End of workaround for lp:915975
-        
-        """ Process the logic of the written values """
+        # Process the logic of the written values
 
         # An invoice is selected from multiple candidates
         if vals and 'invoice_id' in vals:
-            for wiz in self.browse(cr, uid, ids, context=context):
-                if (wiz.import_transaction_id.match_type == 'invoice' and
+            if (wiz.import_transaction_id.match_type == 'invoice' and
                     wiz.import_transaction_id.invoice_id):
-                    # the current value might apply
-                    if (wiz.move_line_id and wiz.move_line_id.invoice and
-                        wiz.move_line_id.invoice.id == wiz.invoice_id.id):
-                        found = True
-                        continue
+                found = False
+                # the current value might apply
+                if (wiz.move_line_id and wiz.move_line_id.invoice and
+                        wiz.move_line_id.invoice == wiz.invoice_id):
+                    found = True
+                else:
                     # Otherwise, retrieve the move line for this invoice
                     # Given the arity of the relation, there is are always
                     # multiple possibilities but the move lines here are
@@ -145,8 +154,8 @@
                     # and the regular invoice workflow should only come up with 
                     # one of those only.
                     for move_line in wiz.import_transaction_id.move_line_ids:
-                        if (move_line.invoice.id ==
-                            wiz.import_transaction_id.invoice_id.id):
+                        if (move_line.invoice ==
+                                wiz.import_transaction_id.invoice_id):
                             transaction_obj.write(
                                 cr, uid, wiz.import_transaction_id.id,
                                 { 'move_line_id': move_line.id, }, context=context)
@@ -157,20 +166,18 @@
                                   }, context=context)
                             found = True
                             break
-                    # Cannot match the invoice 
-                    if not found:
-                        # transaction_obj.write(
-                        #   cr, uid, wiz.import_transaction_id.id,
-                        #   { 'invoice_id': False, }, context=context)
-                        osv.except_osv(
-                            _("No entry found for the selected invoice"),
-                            _("No entry found for the selected invoice. " +
-                              "Try manual reconciliation."))
+                # Cannot match the invoice 
+                if not found:
+                    orm.except_orm(
+                        _("No entry found for the selected invoice"),
+                        _("No entry found for the selected invoice. " +
+                          "Try manual reconciliation."))
 
         if manual_move_line_ids or manual_invoice_ids:
             move_line_obj = self.pool.get('account.move.line')
             invoice_obj = self.pool.get('account.invoice')
             statement_line_obj = self.pool.get('account.bank.statement.line')
+<<<<<<< TREE
             manual_invoice_ids = (
                     [i[1] for i in manual_invoice_ids if i[0]==4] +
                     [j for i in manual_invoice_ids if i[0]==6 for j in i[2]])
@@ -190,14 +197,43 @@
                 for invoice in invoice_obj.browse(
                         cr, uid, manual_invoice_ids, context=context):
                     found_move_line = False
+=======
+            # Rewrite *2many directive notation
+            if manual_invoice_ids:
+                manual_invoice_ids = (
+                    [i[1] for i in manual_invoice_ids if i[0]==4] +
+                    [j for i in manual_invoice_ids if i[0]==6 for j in i[2]])
+            if manual_move_line_ids:
+                manual_move_line_ids = (
+                    [i[1] for i in manual_move_line_ids if i[0]==4] +
+                    [j for i in manual_move_line_ids if i[0]==6 for j in i[2]])
+            for wiz in self.browse(cr, uid, ids, context=context):
+                #write can be called multiple times for the same values
+                #that doesn't hurt above, but it does here
+                if wiz.match_type and (
+                        len(manual_move_line_ids) > 1 or
+                        len(manual_invoice_ids) > 1):
+                    continue
+
+                todo = []
+
+                for invoice in invoice_obj.browse(
+                        cr, uid, manual_invoice_ids, context=context):
+                    found_move_line = False
+>>>>>>> MERGE-SOURCE
                     if invoice.move_id:
                         for line in invoice.move_id.line_id:
                             if line.account_id.type in ('receivable', 'payable'):
                                 todo.append((invoice.id, line.id))
                                 found_move_line = True
                                 break
+<<<<<<< TREE
                     if not found_move_line:
                         raise osv.except_osv(
+=======
+                    if not found_move_line:
+                        raise orm.except_orm(
+>>>>>>> MERGE-SOURCE
                             _("Cannot select for reconcilion"),
                             _("No entry found for the selected invoice. "))
                 for move_line_id in manual_move_line_ids:
@@ -260,7 +296,7 @@
         """
         Just a button that triggers a write.
         """
-        return True
+        return self.create_act_window(cr, uid, ids, context=None)
 
     def disable_match(self, cr, uid, ids, context=None):
         """
@@ -285,6 +321,7 @@
                     account_id = setting.default_debit_account_id and setting.default_debit_account_id.id
                 statement_pool.write(cr, uid, wiz.statement_line_id.id, {'account_id':account_id})
             
+<<<<<<< TREE
             # Restore partner id from the bank account or else reset
             partner_id = False
             if (wiz.statement_line_id.partner_bank_id and
@@ -306,6 +343,28 @@
 
             
         return True
+=======
+            # Restore partner id from the bank account or else reset
+            partner_id = False
+            if (wiz.statement_line_id.partner_bank_id and
+                    wiz.statement_line_id.partner_bank_id.partner_id):
+                partner_id = wiz.statement_line_id.partner_bank_id.partner_id.id
+            wiz.write({'partner_id': partner_id})
+
+            if wiz.statement_line_id:
+                #delete splits causing an unsplit if this is a split
+                #transaction
+                statement_pool.unlink(cr, uid,
+                        statement_pool.search(cr, uid,
+                            [('parent_id', '=', wiz.statement_line_id.id)],
+                            context=context),
+                        context=context)
+
+            if wiz.import_transaction_id:
+                wiz.import_transaction_id.clear_and_write()
+
+        return self.create_act_window(cr, uid, ids, context=None)
+>>>>>>> MERGE-SOURCE
 
     def reverse_duplicate(self, cr, uid, ids, context=None):
         if isinstance(ids, (int, long)):
@@ -317,25 +376,18 @@
             transaction_obj.write(
                 cr, uid, wiz['import_transaction_id'][0], 
                 {'duplicate': not wiz['duplicate']}, context=context)
-        return True
-
-    def _get_default_match_type(self, cr, uid, context=None):
-        """
-        Take initial value for the match type from the statement line
-        """
-        res = False
-        if context and 'statement_line_id' in context:
-            res = self.pool.get('account.bank.statement.line').read(
-                cr, uid, context['statement_line_id'],
-                ['match_type'], context=context)['match_type']
-        return res
+        return self.create_act_window(cr, uid, ids, context=None)
 
     def button_done(self, cr, uid, ids, context=None):
+<<<<<<< TREE
         return {'type': 'ir.actions.act_window_close'}        
 
     _defaults = {
 #        'match_type': _get_default_match_type,
         }
+=======
+        return {'type': 'ir.actions.act_window_close'}        
+>>>>>>> MERGE-SOURCE
 
     _columns = {
         'name': fields.char('Name', size=64),
@@ -351,6 +403,10 @@
         'ref': fields.related(
             'statement_line_id', 'ref', type='char', size=32,
             string="Reference", readonly=True),
+        'message': fields.related(
+            'statement_line_id', 'import_transaction_id', 'message',
+            type='char', size=1024,
+            string="Message", readonly=True),
         'partner_id': fields.related(
             'statement_line_id', 'partner_id',
             type='many2one', relation='res.partner',
@@ -369,19 +425,6 @@
             'import_transaction_id', 'writeoff_account_id',
             type='many2one', relation='account.account',
             string='Write-off account'),
-        'writeoff_journal_id': fields.related(
-            'import_transaction_id', 'writeoff_journal_id',
-            type='many2one', relation='account.journal',
-            string='Write-off journal'),
-        'payment_line_id': fields.related(
-            'import_transaction_id', 'payment_line_id', string="Matching payment or storno", 
-            type='many2one', relation='payment.line', readonly=True),
-        'payment_order_ids': fields.related(
-            'import_transaction_id', 'payment_order_ids', string="Matching payment orders", 
-            type='many2many', relation='payment.order'),
-        'payment_order_id': fields.related(
-            'import_transaction_id', 'payment_order_id', string="Payment order to reconcile", 
-            type='many2one', relation='payment.order'),
         'invoice_ids': fields.related(
             'import_transaction_id', 'invoice_ids', string="Matching invoices", 
             type='many2many', relation='account.invoice'),
@@ -400,7 +443,13 @@
         'match_multi': fields.related(
             'import_transaction_id', 'match_multi', 
             type="boolean", string='Multiple matches'),
+        'manual_invoice_ids': fields.many2many(
+            'account.invoice',
+            'banking_transaction_wizard_account_invoice_rel',
+            'wizard_id', 'invoice_id', string='Match one or more invoices',
+            domain=[('reconciled', '=', False)]),
         'match_type': fields.related(
+<<<<<<< TREE
             'import_transaction_id', 'match_type', 
             type="char", size=16, string='Match type', readonly=True),
         'manual_invoice_ids': fields.many2many(
@@ -412,6 +461,24 @@
             'account.move.line',
             'banking_transaction_wizard_account_move_line_rel',
             'wizard_id', 'move_line_id', string='Or match one or more entries',
+=======
+            'import_transaction_id', 'match_type', type='selection',
+            selection=[
+                ('move','Move'),
+                ('invoice', 'Invoice'),
+                ('payment', 'Payment line'),
+                ('payment_order', 'Payment order'),
+                ('storno', 'Storno'),
+                ('manual', 'Manual'),
+                ('payment_manual', 'Payment line (manual)'),
+                ('payment_order_manual', 'Payment order (manual)'),
+                ], 
+            string='Match type', readonly=True),
+        'manual_move_line_ids': fields.many2many(
+            'account.move.line',
+            'banking_transaction_wizard_account_move_line_rel',
+            'wizard_id', 'move_line_id', string='Or match one or more entries',
+>>>>>>> MERGE-SOURCE
             domain=[('account_id.reconcile', '=', True),
                     ('reconcile_id', '=', False)]),
         'payment_option': fields.related('import_transaction_id','payment_option', string='Payment Difference', type='selection', required=True,
@@ -426,8 +493,6 @@
             string="Analytic Account"),
         'move_currency_amount': fields.related('import_transaction_id','move_currency_amount',
             type='float', string='Match Currency Amount', readonly=True),
-        #'manual_payment_order_id': fields.many2one(
-        #    'payment.order', "Payment order to reconcile"),
         }
 
 banking_transaction_wizard()

=== modified file 'account_banking/wizard/banking_transaction_wizard.xml'
--- account_banking/wizard/banking_transaction_wizard.xml	2013-05-02 15:13:33 +0000
+++ account_banking/wizard/banking_transaction_wizard.xml	2013-07-25 08:56:25 +0000
@@ -3,29 +3,46 @@
     <data>
         <record model="ir.ui.view" id="transaction_wizard_first">
             <field name="name">transaction.wizard.first</field>
-            <field name="type">form</field>
             <field name="model">banking.transaction.wizard</field>
             <field name="arch" type="xml">
-                <form string="Match transaction">
+                <form string="Match transaction" version="7.0">
+                    
                     <!-- fields used for form logic -->
+<<<<<<< TREE
                     <field name="payment_order_ids" invisible="True"/>
                     <field name="statement_line_parent_id" invisible="True"/>
+=======
+                    <field name="statement_line_parent_id" invisible="True"/>
+>>>>>>> MERGE-SOURCE
                     <field name="invoice_ids" invisible="True"/>
                     <field name="move_line_ids" invisible="True"/>
                     <field name="match_multi" invisible="True"/>
                     <field name="duplicate" invisible="True"/>
+                    <separator string="Transaction data" colspan="4"/>
+                    <group colspan="4" col="6">
+                        
+                        <field name="partner_id"/>
+                        <field name="date"/>
+                        <button colspan="2"
+                            name="trigger_match"
+                            type="object"
+                            help="You can let the system try to match this bank statement line again after you have made any changes in the database (for instance, add an invoice or a bank account)."
+                            class="oe_highlight"
+                            string="Match again"/>
+                        <field name="amount"/>
+                        <field name="ref"/>
+                        <button colspan="2"
+                            name="reverse_duplicate"
+                            type="object"
+                            help="This bank transfer was marked as a duplicate. You can either confirm that this is not the case, or remove the bank transfer from the system."
+                            string="Remove duplicate flag"/>
+                        
+                    </group>
+                    <group col="4" colspan="4">
+                        <field name="message" colspan="4"/>
+                    </group>
+                    
                     <group colspan="2" col="2">
-                        <group colspan="2" col="4">
-                            <separator string="Transaction data" colspan="4"/>
-                            <field name="partner_id"/>
-                            <field name="date"/>
-                            <field name="ref"/>
-                            <field name="amount"/>
-                        </group>
-                        
-                        <!-- (semi-) automatic matching and selection -->
-                        
-                        <group colspan="2" col="4">
 
                             <separator string="Current match" colspan="4"/>
                             <field name="match_type"/>
@@ -37,52 +54,56 @@
                                 <separator string="Multiple matches" colspan="2"/>
                                 <label colspan="2" string="Multiple matches were found for this bank transfer. You must pick one of the matches or select a match manually below." />
                             </group>
-                            <field name='payment_line_id'
-                                   attrs="{'invisible': [('match_type', '!=', 'storno'),('match_type', '!=', 'payment')]}"
-                                   />
-                            <group attrs="{'readonly': [('match_multi', '!=', True)]}" col="8">
                                 <!-- show if we have an invoice type match (but the user may need to select from multiple options)
                                      or whenever there is an invoice_id (e.g. in case of a manual match) 
                                 -->
                                 <field name='invoice_id'
                                        attrs="{'readonly': [('match_multi', '=', False)], 'invisible': [('match_type', '!=', 'invoice'),('invoice_id', '=', False)]}"
-                                       domain="[('id', 'in', invoice_ids[0][2])]"
+                                       domain="[('id', 'in', invoice_ids[0][2])]" colspan="2"
                                        />
                                 <!-- show if we have a move type match or a manual match without an invoice_id
                                 -->
-                                <field name='move_line_id'
+                                <field name='move_line_id'  colspan="2"
                                        attrs="{'readonly': [('match_multi', '=', False)], 'invisible': [('match_type', '!=', 'move'),('invoice_id', '=', False)]}"
                                        domain="[('id', 'in', move_line_ids[0][2])]"
                                        />
-                                <field name='payment_order_id'
-                                       attrs="{'readonly': [('match_multi', '=', False)], 'invisible': [('match_type', '!=', 'payment_order')]}"
-                                       domain="[('id', 'in', payment_order_ids[0][2])]"
-                                       />
-                                <field name='analytic_account_id' />
-                            </group>
-                            <button colspan="1"
-                                    name="trigger_write"
-                                    type="object"
-                                    attrs="{'invisible': [('match_multi', '=', False)]}"
-                                    string="Select"/>
-                            <newline/>
+                                <field name='analytic_account_id' colspan="2"  style="width: 50%%"/>
+                        <footer>
+                            <button name="trigger_write"
+                                type="object"
+                                class="oe_highlight"
+                                string="Match" />
+                            or
+                            <button string="Close" special="cancel" class="oe_link"/>
+                        </footer>
+                    </group>
+                    
+                        <button colspan="1"
+                                name="trigger_write"
+                                type="object"
+                                attrs="{'invisible': [('match_multi', '=', False)]}"
+                                string="Select"/>
+                        <newline/>
 
                             <!-- residual and write off -->
                             
+                        <group colspan="4" col="4">
+                            <separator string="Match one or more invoices" colspan="4"/>
+
+                            <field name="manual_invoice_ids" colspan="4"
+                                           context="{'search_default_partner_id': partner_id}"
+                                           nolabel="1"
+                                           />
+                            <separator string="Or match one or more entries" colspan="4"/>              
+                            <field name="manual_move_line_ids" colspan="4"
+                                   context="{'search_default_partner_id': partner_id}"
+                                   nolabel="1"
+                                   />
+                        
                         </group>
                         <notebook>
-                            <!-- Duplicate flagging -->
-                            <page string="Duplicate" attrs="{'invisible': [('duplicate', '=', False)]}">
-                                <group  colspan="2" col="2">
-                                    <label colspan="2" string="This bank transfer was marked as a duplicate. You can either confirm that this is not the case, or remove the bank transfer from the system."/>
-                                    <newline/>
-                                    <button colspan="1"
-                                            name="reverse_duplicate"
-                                            type="object"
-                                            string="Remove duplicate flag"/>
-                                </group>
-                            </page>
                             <!-- Redo automatic match -->
+<<<<<<< TREE
                             <page string="Match again">
                                 <label string="You can let the system try to match this bank statement line again after you have made any changes in the database (for instance, add an invoice or a bank account)."  colspan="2"/>
                                 <newline/>                           
@@ -103,6 +124,8 @@
                                         type="object"
                                         string="Match" />
                             </page>
+=======
+>>>>>>> MERGE-SOURCE
                             <page string="Write-Off" attrs="{'invisible': [('match_type', '=', False)]}">
                                 <group colspan="2" col="2">
                                     <label string="Choose what you want to do with the eventual difference between the paid amount and the sum of allocated amounts. You can either choose to keep open this difference on the partner's account, or reconcile it with the payment."  colspan="2"/>
@@ -126,11 +149,14 @@
                                 </group>
                             </page>
                         </notebook>
+<<<<<<< TREE
                         <group colspan="2">
                             <separator/>
                             <button icon="gtk-ok" string="Close" special="cancel"/>
                         </group>
                     </group>
+=======
+>>>>>>> MERGE-SOURCE
                 </form>
             </field>
         </record>

=== modified file 'account_banking/wizard/banktools.py'
--- account_banking/wizard/banktools.py	2013-04-25 12:49:02 +0000
+++ account_banking/wizard/banktools.py	2013-07-25 08:56:25 +0000
@@ -1,29 +1,35 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
 ##############################################################################
 #
 #    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
 
+<<<<<<< TREE
 import datetime
 from tools.translate import _
 from account_banking.parsers import convert
 from account_banking import sepa
 from account_banking.struct import struct
+=======
+from openerp.tools.translate import _
+from openerp.addons.account_banking import sepa
+from openerp.addons.account_banking.struct import struct
+>>>>>>> MERGE-SOURCE
 
 __all__ = [
     'get_period', 
@@ -34,57 +40,26 @@
     'create_bank_account',
 ]
 
-def get_period(pool, cursor, uid, date, company, log):
-    '''
-    Get a suitable period for the given date range and the given company.
-    '''
-    fiscalyear_obj = pool.get('account.fiscalyear')
-    period_obj = pool.get('account.period')
-    if not date:
-        date = convert.date2str(datetime.datetime.today())
-
-    search_date = convert.date2str(date)
-    fiscalyear_ids = fiscalyear_obj.search(cursor, uid, [
-        ('date_start','<=', search_date), ('date_stop','>=', search_date),
-        ('state','=','draft'), ('company_id','=',company.id)
-    ])
-    if not fiscalyear_ids:
-        fiscalyear_ids = fiscalyear_obj.search(cursor, uid, [
-            ('date_start','<=',search_date), ('date_stop','>=',search_date),
-            ('state','=','draft'), ('company_id','=',None)
-        ])
-    if not fiscalyear_ids:
-        log.append(
-            _('No suitable fiscal year found for date %(date)s and company %(company_name)s')
-            % dict(company_name=company.name, date=date)
-        )
-        return False
-    elif len(fiscalyear_ids) > 1:
-        log.append(
-            _('Multiple overlapping fiscal years found for date %(date)s and company %(company_name)s')
-            % dict(company_name=company.name, date=date)
-        )
-        return False
-
-    fiscalyear_id = fiscalyear_ids[0]
-    period_ids = period_obj.search(cursor, uid, [
-        ('date_start','<=',search_date), ('date_stop','>=',search_date),
-        ('fiscalyear_id','=',fiscalyear_id), ('state','=','draft'),
-        ('special', '=', False),
-    ])
-    if not period_ids:
-        log.append(_('No suitable period found for date %(date)s and company %(company_name)s')
-                   % dict(company_name=company.name, date=date)
-        )
-        return False
-    if len(period_ids) != 1:
-        log.append(_('Multiple overlapping periods for date %(date)s and company %(company_name)s')
-                   % dict(company_name=company.name, date=date)
-        )
-        return False
+def get_period(pool, cr, uid, date, company, log=None):
+    '''
+    Wrapper over account_period.find() to log exceptions of
+    missing periods instead of raising.
+    '''
+    context = {'account_period_prefer_normal': True}
+    if company:
+        context['company_id'] = company.id
+    try:
+        period_ids = pool.get('account.period').find(
+            cr, uid, dt=date, context=context)
+    except Exception, e:
+        if log is None:
+            raise
+        else:
+            log.append(e)
+            return False
     return period_ids[0]
 
-def get_bank_accounts(pool, cursor, uid, account_number, log, fail=False):
+def get_bank_accounts(pool, cr, uid, account_number, log, fail=False):
     '''
     Get the bank account with account number account_number
     '''
@@ -93,13 +68,13 @@
         return []
 
     partner_bank_obj = pool.get('res.partner.bank')
-    bank_account_ids = partner_bank_obj.search(cursor, uid, [
+    bank_account_ids = partner_bank_obj.search(cr, uid, [
         ('acc_number', '=', account_number)
     ])
     if not bank_account_ids:
         # SR 2012-02-19 does the search() override in res_partner_bank
         # provides this result on the previous query?
-        bank_account_ids = partner_bank_obj.search(cursor, uid, [
+        bank_account_ids = partner_bank_obj.search(cr, uid, [
             ('acc_number_domestic', '=', account_number)
         ])
     if not bank_account_ids:
@@ -108,8 +83,13 @@
                 _('Bank account %(account_no)s was not found in the database')
                 % dict(account_no=account_number)
             )
+<<<<<<< TREE
         return []
     return partner_bank_obj.browse(cursor, uid, bank_account_ids)
+=======
+        return []
+    return partner_bank_obj.browse(cr, uid, bank_account_ids)
+>>>>>>> MERGE-SOURCE
 
 def _has_attr(obj, attr):
     # Needed for dangling addresses and a weird exception scheme in
@@ -134,12 +114,23 @@
                                      context=context)
     if not partner_ids:
         # Try brute search on address and then match reverse
+<<<<<<< TREE
         criteria = []
         if country_id:
             criteria.append(('address.country_id', '=', country_id))
+=======
+        criteria = []
+        if country_id:
+            criteria.append(('country_id', '=', country_id))
+>>>>>>> MERGE-SOURCE
         if city:
+<<<<<<< TREE
             criteria.append(('address.city', 'ilike', city))
+=======
+            criteria.append(('city', 'ilike', city))
+>>>>>>> MERGE-SOURCE
         if postal_code:
+<<<<<<< TREE
             criteria.append(('address.zip', 'ilike', postal_code))
         partner_search_ids = partner_obj.search(
             cr, uid, criteria, context=context)
@@ -148,7 +139,18 @@
             criteria[0] = ('address.country_id', '=', False)
             partner_search_ids = partner_obj.search(
                 cr, uid, criteria, context=context)
+=======
+            criteria.append(('zip', 'ilike', postal_code))
+        partner_search_ids = partner_obj.search(
+            cr, uid, criteria, context=context)
+        if (not partner_search_ids and country_id):
+            # Try again with country_id = False
+            criteria[0] = ('country_id', '=', False)
+            partner_search_ids = partner_obj.search(
+                cr, uid, criteria, context=context)
+>>>>>>> MERGE-SOURCE
         key = name.lower()
+<<<<<<< TREE
         partners = []
         for partner in partner_obj.read(
             cr, uid, partner_search_ids, ['name'], context=context):
@@ -163,13 +165,29 @@
     return partner_ids and partner_ids[0] or False
 
 def get_company_bank_account(pool, cursor, uid, account_number, currency,
+=======
+        partners = []
+        for partner in partner_obj.read(
+            cr, uid, partner_search_ids, ['name'], context=context):
+            if (len(partner['name']) > 3 and partner['name'].lower() in key):
+                partners.append(partner)
+        partners.sort(key=lambda x: len(x['name']), reverse=True)
+        partner_ids = [x['id'] for x in partners]
+    if len(partner_ids) > 1:
+        log.append(
+            _('More than one possible match found for partner with '
+              'name %(name)s') % {'name': name})
+    return partner_ids and partner_ids[0] or False
+
+def get_company_bank_account(pool, cr, uid, account_number, currency,
+>>>>>>> MERGE-SOURCE
                              company, log):
     '''
     Get the matching bank account for this company. Currency is the ISO code
     for the requested currency.
     '''
     results = struct()
-    bank_accounts = get_bank_accounts(pool, cursor, uid, account_number, log,
+    bank_accounts = get_bank_accounts(pool, cr, uid, account_number, log,
                                       fail=True)
     if not bank_accounts:
         return False
@@ -192,12 +210,12 @@
 
     # Find matching journal for currency
     journal_obj = pool.get('account.journal')
-    journal_ids = journal_obj.search(cursor, uid, [
+    journal_ids = journal_obj.search(cr, uid, [
         ('type', '=', 'bank'),
         ('currency.name', '=', currency or company.currency_id.name)
     ])
     if currency == company.currency_id.name:
-        journal_ids_no_curr = journal_obj.search(cursor, uid, [
+        journal_ids_no_curr = journal_obj.search(cr, uid, [
             ('type', '=', 'bank'), ('currency', '=', False)
         ])
         journal_ids.extend(journal_ids_no_curr)
@@ -205,9 +223,9 @@
         criteria.append(('journal_id', 'in', journal_ids))
 
     # Find bank account settings
-    bank_settings_ids = bank_settings_obj.search(cursor, uid, criteria)
+    bank_settings_ids = bank_settings_obj.search(cr, uid, criteria)
     if bank_settings_ids:
-        settings = bank_settings_obj.browse(cursor, uid, bank_settings_ids)[0]
+        settings = bank_settings_obj.browse(cr, uid, bank_settings_ids)[0]
         results.company_id = company
         results.journal_id = settings.journal_id
 
@@ -225,7 +243,7 @@
 
     return results
 
-def get_or_create_bank(pool, cursor, uid, bic, online=False, code=None,
+def get_or_create_bank(pool, cr, uid, bic, online=False, code=None,
                        name=None):
     '''
     Find or create the bank with the provided BIC code.
@@ -241,27 +259,27 @@
     if len(bic) < 8:
         # search key
         bank_ids = bank_obj.search(
-            cursor, uid, [
+            cr, uid, [
                 ('bic', '=', bic[:6])
             ])
         if not bank_ids:
             bank_ids = bank_obj.search(
-                cursor, uid, [
+                cr, uid, [
                     ('bic', 'ilike', bic + '%')
                 ])
     else:
         bank_ids = bank_obj.search(
-            cursor, uid, [
+            cr, uid, [
                 ('bic', '=', bic)
             ])
 
     if bank_ids and len(bank_ids) == 1:
-        banks = bank_obj.browse(cursor, uid, bank_ids)
+        banks = bank_obj.browse(cr, uid, bank_ids)
         return banks[0].id, banks[0].country.id
 
     country_obj = pool.get('res.country')
     country_ids = country_obj.search(
-        cursor, uid, [('code', '=', bic[4:6])]
+        cr, uid, [('code', '=', bic[4:6])]
     )
     country_id = country_ids and country_ids[0] or False
     bank_id = False
@@ -269,7 +287,7 @@
     if online:
         info, address = sepa.online.bank_info(bic)
         if info:
-            bank_id = bank_obj.create(cursor, uid, dict(
+            bank_id = bank_obj.create(cr, uid, dict(
                 code = info.code,
                 name = info.name,
                 street = address.street,
@@ -283,7 +301,7 @@
         info = struct(name=name, code=code)
 
     if not online or not bank_id:
-        bank_id = bank_obj.create(cursor, uid, dict(
+        bank_id = bank_obj.create(cr, uid, dict(
             code = info.code or 'UNKNOW',
             name = info.name or _('Unknown Bank'),
             country = country_id,

=== modified file 'account_banking/wizard/link_partner.py'
--- account_banking/wizard/link_partner.py	2013-04-29 08:21:54 +0000
+++ account_banking/wizard/link_partner.py	2013-07-25 08:56:25 +0000
@@ -1,3 +1,4 @@
+<<<<<<< TREE
 # -*- coding: utf-8 -*-
 ##############################################################################
 #
@@ -155,3 +156,209 @@
             }
 
 
+=======
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2013 Therp BV (<http://therp.nl>).
+#    All Rights Reserved
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU 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,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import orm, fields
+from openerp.tools.translate import _
+from openerp.addons.account_banking.wizard import banktools
+import ast
+
+class link_partner(orm.TransientModel):
+    _name = 'banking.link_partner'
+    _description = 'Link partner'
+
+    _columns = {
+        'name': fields.char(
+            'Create partner with name', size=128, required=True),
+        'supplier': fields.boolean('Supplier'),
+        'customer': fields.boolean('Customer'),
+        'partner_id': fields.many2one(
+            'res.partner', 'or link existing partner'),
+        'statement_line_id': fields.many2one(
+            'account.bank.statement.line',
+            'Statement line', required=True),
+        'amount': fields.related(
+            'statement_line_id', 'amount', type='float',
+            string="Amount", readonly=True),
+        'ref': fields.related(
+            'statement_line_id', 'ref', type='char', size=32,
+            string="Reference", readonly=True),
+        'message': fields.related(
+            'statement_line_id', 'import_transaction_id', 'message',
+            type='char', size=1024,
+            string="Message", readonly=True),
+        'remote_account': fields.char(
+            'Account number', size=24, readonly=True),
+        # Partner values
+        'street': fields.char('Street', size=128),
+        'street2': fields.char('Street2', size=128),
+        'zip': fields.char('Zip', change_default=True, size=24),
+        'city': fields.char('City', size=128),
+        'state_id': fields.many2one("res.country.state", 'State'),
+        'country_id': fields.many2one('res.country', 'Country'),
+        'email': fields.char('Email', size=240),
+        'phone': fields.char('Phone', size=64),
+        'fax': fields.char('Fax', size=64),
+        'mobile': fields.char('Mobile', size=64),
+        'is_company': fields.boolean('Is a Company'),
+        }
+    
+    _defaults = {
+        'is_company': True,
+        }
+    
+    def create(self, cr, uid, vals, context=None):
+        """
+        Get default values from the transaction data 
+        on the statement line
+        """
+        if vals and vals.get('statement_line_id'):
+            statement_line_obj = self.pool.get('account.bank.statement.line')
+            statement_line = statement_line_obj.browse(
+                cr, uid, vals['statement_line_id'], context=context)
+            transaction = statement_line.import_transaction_id
+
+            if statement_line.partner_bank_id:
+                raise orm.except_orm(
+                    _('Error'),
+                    _('Statement line is already linked to a bank account '))
+            
+            if not(transaction and transaction.remote_owner
+                   and transaction.remote_account):
+                raise orm.except_orm(
+                    _('Error'),
+                    _('No transaction data on statement line'))
+
+            if 'supplier' not in vals and statement_line.amount < 0:
+                vals['supplier'] = True
+            if 'customer' not in vals and statement_line.amount > 0:
+                vals['customer'] = True
+
+            address_list = []
+            try:
+                address_list = ast.literal_eval(
+                    transaction.remote_owner_address or [])
+            except ValueError:
+                pass
+            if address_list and not vals.get('street'):
+                vals['street'] = address_list.pop(0)
+            if address_list and not vals.get('street2'):
+                vals['street2'] = address_list.pop(0)
+            if transaction.remote_owner_postalcode and not vals.get('zip'):
+                vals['zip'] = transaction.remote_owner_postalcode
+            if transaction.remote_owner_city and not vals.get('city'):
+                vals['city'] = transaction.remote_owner_city
+            if not vals.get('country_id'):
+                vals['country_id'] = banktools.get_country_id(
+                    self.pool, cr, uid, transaction, context=context)
+            if not vals.get('name'):
+                vals['name'] = transaction.remote_owner
+            if not vals.get('remote_account'):
+                vals['remote_account'] = transaction.remote_account
+
+        return super(link_partner, self).create(
+            cr, uid, vals, context=context)
+            
+    def update_partner_values(self, cr, uid, wizard, values, context=None):
+        """
+        Updates the new partner values with the values from the wizard
+        
+        :param wizard: read record of wizard (with load='_classic_write')
+        :param values: the dictionary of partner values that will be updated
+        """
+        for field in ['is_company',
+                      'name',
+                      'street', 
+                      'street2',
+                      'zip',
+                      'city',
+                      'country_id',
+                      'state_id',
+                      'phone',
+                      'fax',
+                      'mobile',
+                      'email'
+                      ]:
+            if wizard[field]:
+                values[field] = wizard[field]
+        return True
+    
+    def link_partner(self, cr, uid, ids, context=None):
+        statement_line_obj = self.pool.get(
+            'account.bank.statement.line')
+        wiz = self.browse(cr, uid, ids[0], context=context)
+
+        if wiz.partner_id:
+            partner_id = wiz.partner_id.id
+        else:
+            wiz_read = self.read(
+                cr, uid, ids[0], context=context, load='_classic_write')
+            partner_vals = {
+                    'type': 'default',
+                    }
+            self.update_partner_values(
+                cr, uid, wiz_read, partner_vals, context=context)
+            partner_id = self.pool.get('res.partner').create(
+                cr, uid, partner_vals, context=context)
+            
+        partner_bank_id = banktools.create_bank_account(
+            self.pool, cr, uid, partner_id,
+            wiz.remote_account, wiz.name,
+            wiz.street, wiz.city,
+            wiz.country_id and wiz.country_id.id or False,
+            bic=wiz.statement_line_id.import_transaction_id.remote_bank_bic,
+            context=context)
+
+        statement_line_ids = statement_line_obj.search(
+            cr, uid,
+            [('import_transaction_id.remote_account', '=', wiz.remote_account),
+             ('partner_bank_id', '=', False),
+             ('state', '=', 'draft')], context=context)
+        statement_line_obj.write(
+            cr, uid, statement_line_ids,
+            {'partner_bank_id': partner_bank_id,
+             'partner_id': partner_id}, context=context)
+
+        return {'type': 'ir.actions.act_window_close'}        
+
+    def create_act_window(self, cr, uid, ids, nodestroy=True, context=None):
+        """ 
+        Return a popup window for this model
+        """
+        if isinstance(ids, (int, long)):
+            ids = [ids]
+        return {
+            'name': self._description,
+            'view_type': 'form',
+            'view_mode': 'form',
+            'res_model': self._name,
+            'domain': [],
+            'context': context,
+            'type': 'ir.actions.act_window',
+            'target': 'new',
+            'res_id': ids[0],
+            'nodestroy': nodestroy,
+            }
+
+
+>>>>>>> MERGE-SOURCE

=== modified file 'account_banking/wizard/link_partner.xml'
--- account_banking/wizard/link_partner.xml	2013-04-25 12:49:02 +0000
+++ account_banking/wizard/link_partner.xml	2013-07-25 08:56:25 +0000
@@ -1,3 +1,4 @@
+<<<<<<< TREE
 <?xml version="1.0" encoding="utf-8"?>
 <openerp>
     <data>
@@ -45,3 +46,68 @@
         </record>
     </data>
 </openerp>
+=======
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record model="ir.ui.view" id="link_partner_view">
+            <field name="name">Link partner wizard view</field>
+            <field name="type">form</field>
+            <field name="model">banking.link_partner</field>
+            <field name="arch" type="xml">
+                <form string="Link partner" version="7.0" >
+                    <group colspan="4" col="6" string="Transaction data">
+                        <field name="ref" />
+                        <field name="amount" />
+                        <field name="remote_account" />
+                        <field name="message" colspan="6"/>
+                    </group>
+                    <group colspan="4" col="4" string="Create or link partner">
+                        <field name="name"
+                               attrs="{'readonly': [('partner_id', '!=', False)]}" />
+                        <field name="partner_id"/>
+                    </group>
+                    <group colspan="2">
+                        <field name="is_company" />
+                    </group>
+                    <group colspan="4"
+                           string="Address"
+                           attrs="{'invisible': [('partner_id', '!=', False)]}"
+                           col="4">
+                        <group colspan="2" col="2">
+                            <field name="street"/>
+                            <field name="street2"/>
+                            <field name="zip"/>
+                            <field name="city"/>
+                            <field name="country_id"/>
+                            <field name="state_id"/>
+                        </group>
+                        <group colspan="2" col="2">
+                            <field name="phone"/>
+                            <field name="fax"/>
+                            <field name="mobile"/>
+                            <field name="email" widget="email"/>
+                        </group>
+                    </group>
+                    <footer>
+                    <button string="Create partner"
+                            name="link_partner" type="object"
+                            class="oe_highlight"
+                            attrs="{'invisible': [('partner_id', '!=', False)]}"
+                            />
+                    <button string="Link existing partner"
+                            class="oe_highlight"
+                            name="link_partner" type="object"
+                            attrs="{'invisible': [('partner_id', '==', False)]}"
+                            />
+                     or
+                    <button class="oe_link" string="Cancel" special="cancel" />
+                    
+                    
+                    </footer>
+                </form>
+            </field>
+        </record>
+    </data>
+</openerp>
+>>>>>>> MERGE-SOURCE

=== modified file 'account_banking_fi_patu/__init__.py'
--- account_banking_fi_patu/__init__.py	2010-06-30 07:11:08 +0000
+++ account_banking_fi_patu/__init__.py	2013-07-25 08:56:25 +0000
@@ -12,16 +12,16 @@
 #    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 General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== renamed file 'account_banking_fi_patu/__terp__.py' => 'account_banking_fi_patu/__openerp__.py'
--- account_banking_fi_patu/__terp__.py	2011-05-05 10:29:28 +0000
+++ account_banking_fi_patu/__openerp__.py	2013-07-25 08:56:25 +0000
@@ -11,23 +11,23 @@
 #    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 General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
 {
     'name': 'Account Banking PATU module',
     'version': '0.62',
-    'license': 'GPL-3',
+    'license': 'AGPL-3',
     'author': 'Sami Haahtinen',
     'website': 'http://ressukka.net',
     'category': 'Account Banking',

=== modified file 'account_banking_fi_patu/patu.py'
--- account_banking_fi_patu/patu.py	2012-01-17 08:48:10 +0000
+++ account_banking_fi_patu/patu.py	2013-07-25 08:56:25 +0000
@@ -6,16 +6,16 @@
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking_nl_abnamro/__init__.py'
--- account_banking_nl_abnamro/__init__.py	2011-04-26 21:00:12 +0000
+++ account_banking_nl_abnamro/__init__.py	2013-07-25 08:56:25 +0000
@@ -1,31 +1,2 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-#    Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
-#                              and Therp BV (<http://therp.nl>)
-#    All Rights Reserved
-#
-#    WARNING: This program as such is intended to be used by professional
-#    programmers who take the whole responsability of assessing all potential
-#    consequences resulting from its eventual inadequacies and bugs
-#    End users who are looking for a ready-to-use solution with commercial
-#    garantees and support are strongly adviced to contract EduSense BV
-#    or Therp BV
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU 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,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
+# -*- coding: utf-8 -*-
 import abnamro
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'account_banking_nl_abnamro/__openerp__.py'
--- account_banking_nl_abnamro/__openerp__.py	2011-04-26 21:00:12 +0000
+++ account_banking_nl_abnamro/__openerp__.py	2013-07-25 08:56:25 +0000
@@ -1,43 +1,33 @@
+# -*- coding: utf-8 -*-
 ##############################################################################
 #
 #    Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
 #                              and Therp BV (<http://therp.nl>)
 #    All Rights Reserved
 #
-#    WARNING: This program as such is intended to be used by professional
-#    programmers who take the whole responsability of assessing all potential
-#    consequences resulting from its eventual inadequacies and bugs
-#    End users who are looking for a ready-to-use solution with commercial
-#    garantees and support are strongly adviced to contract EduSense BV
-#    or Therp BV
-#
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
+
 {
     'name': 'abnamro (NL) Bank Statements Import',
     'version': '0.1',
-    'license': 'GPL-3',
-    'author': 'Therp BV / EduSense BV',
-    'website': 'https://launchpad.net/account-banking',
-    'category': 'Account Banking',
+    'license': 'AGPL-3',
+    'author': ['Therp BV', 'EduSense BV'],
+    'website': 'https://launchpad.net/banking-addons',
+    'category': 'Banking addons',
     'depends': ['account_banking'],
-    'init_xml': [],
-    'update_xml': [
-        #'security/ir.model.access.csv',
-    ],
-    'demo_xml': [],
     'description': '''
 Import filter for abnamro (NL) bank transaction files (txt/tab format).
 
@@ -48,6 +38,5 @@
 Imported bank transfers are organized in statements covering periods of one week,
 even if the imported files cover a different period.
     ''',
-    'active': False,
     'installable': True,
 }

=== removed file 'account_banking_nl_abnamro/__terp__.py'
--- account_banking_nl_abnamro/__terp__.py	2011-05-05 10:29:28 +0000
+++ account_banking_nl_abnamro/__terp__.py	1970-01-01 00:00:00 +0000
@@ -1,53 +0,0 @@
-##############################################################################
-#
-#    Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
-#                              and Therp BV (<http://therp.nl>)
-#    All Rights Reserved
-#
-#    WARNING: This program as such is intended to be used by professional
-#    programmers who take the whole responsability of assessing all potential
-#    consequences resulting from its eventual inadequacies and bugs
-#    End users who are looking for a ready-to-use solution with commercial
-#    garantees and support are strongly adviced to contract EduSense BV
-#    or Therp BV
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU 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,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
-{
-    'name': 'abnamro (NL) Bank Statements Import',
-    'version': '0.62',
-    'license': 'GPL-3',
-    'author': 'Therp BV / EduSense BV',
-    'website': 'https://launchpad.net/account-banking',
-    'category': 'Account Banking',
-    'depends': ['account_banking'],
-    'init_xml': [],
-    'update_xml': [
-        #'security/ir.model.access.csv',
-    ],
-    'demo_xml': [],
-    'description': '''
-Import filter for abnamro (NL) bank transaction files (txt/tab format).
-
-No formal specifications of the file layout are released by abnamro. You can
-help improve the performance of this import filter on
-https://launchpad.net/account-banking.
-
-Imported bank transfers are organized in statements covering periods of one week,
-even if the imported files cover a different period.
-    ''',
-    'active': False,
-    'installable': True,
-}

=== modified file 'account_banking_nl_abnamro/abnamro.py'
--- account_banking_nl_abnamro/abnamro.py	2013-06-04 14:35:21 +0000
+++ account_banking_nl_abnamro/abnamro.py	2013-07-25 08:56:25 +0000
@@ -1,21 +1,22 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
 ##############################################################################
 #
 #    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>)
 #                  2011 Therp BV (<http://therp.nl>)
+#
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
@@ -28,11 +29,11 @@
 Every transaction is bound to a Bank Statement. As such, this module generates
 Bank Statements along with Bank Transactions.
 '''
-from account_banking.parsers import models
-from account_banking.parsers.convert import str2date
-from account_banking.sepa import postalcode
-from tools.translate import _
-from osv import osv
+from openerp.addons.account_banking.parsers import models
+from openerp.addons.account_banking.parsers.convert import str2date
+from openerp.addons.account_banking.sepa import postalcode
+from openerp.tools.translate import _
+from openerp.osv import orm
 
 import re
 import csv
@@ -121,7 +122,7 @@
                 self.error_message = _('No remote account for transaction type '
                                        '%s') % self.transfer_type
         if self.error_message:
-            raise osv.except_osv(_('Error !'), _(self.error_message))
+            raise orm.except_orm(_('Error !'), _(self.error_message))
         return not self.error_message
 
     def parse_message(self):
@@ -224,7 +225,7 @@
                     remote_account = account_match.group(1).zfill(10)
                     remote_owner = account_match.group(2).strip() or ''
                 else:
-                    raise osv.except_osv(
+                    raise orm.except_orm(
                         _('Error !'),
                         _('unable to parse GIRO string: %s') % field)
             elif field.startswith('BEA '):

=== modified file 'account_banking_nl_clieop/__init__.py'
--- account_banking_nl_clieop/__init__.py	2010-01-26 20:55:24 +0000
+++ account_banking_nl_clieop/__init__.py	2013-07-25 08:56:25 +0000
@@ -11,16 +11,16 @@
 #    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 General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== renamed file 'account_banking_nl_clieop/__terp__.py' => 'account_banking_nl_clieop/__openerp__.py'
--- account_banking_nl_clieop/__terp__.py	2011-12-27 12:00:52 +0000
+++ account_banking_nl_clieop/__openerp__.py	2013-07-25 08:56:25 +0000
@@ -3,48 +3,39 @@
 #    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
 #    All Rights Reserved
 #
-#    WARNING: This program as such is intended to be used by professional
-#    programmers who take the whole responsability of assessing all potential
-#    consequences resulting from its eventual inadequacies and bugs
-#    End users who are looking for a ready-to-use solution with commercial
-#    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 General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
 {
     'name': 'Account Banking NL ClieOp',
     'version': '0.92',
-    'license': 'GPL-3',
+    'license': 'AGPL-3',
     'author': 'EduSense BV',
     'website': 'http://www.edusense.nl',
     'category': 'Account Banking',
-    'depends': ['account_banking'],
-    'init_xml': [],
-    'update_xml': [
+    'depends': ['account_banking_payment'],
+    'data': [
         'account_banking_nl_clieop.xml',
         'wizard/export_clieop_view.xml',
         'data/banking_export_clieop.xml',
         'security/ir.model.access.csv',
     ],
-    'demo_xml': [],
     'description': '''
     Module to export payment orders in ClieOp format.
 
     ClieOp format is used by Dutch banks to batch national bank transfers.
     This module uses the account_banking logic.
     ''',
-    'active': False,
     'installable': True,
 }

=== modified file 'account_banking_nl_clieop/account_banking_nl_clieop.py'
--- account_banking_nl_clieop/account_banking_nl_clieop.py	2012-12-30 10:55:49 +0000
+++ account_banking_nl_clieop/account_banking_nl_clieop.py	2013-07-25 08:56:25 +0000
@@ -1,28 +1,30 @@
 ##############################################################################
 #
 #    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
+#              (C) 2011 - 2013 Therp BV (<http://therp.nl>).
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
 
-from osv import osv, fields
 from datetime import date
-from tools.translate import _
-
-class clieop_export(osv.osv):
+from openerp.osv import orm, fields
+from openerp.tools.translate import _
+
+
+class clieop_export(orm.Model):
     '''ClieOp3 Export'''
     _name = 'banking.export.clieop'
     _description = __doc__
@@ -80,7 +82,7 @@
         last = 1
         last_ids = self.search(cr, uid, [
                 ('date_generated', '=', 
-                 fields.date.context_today(cr,uid,context))
+                 fields.date.context_today(self, cr,uid,context))
                 ], context=context)
         if last_ids:
             last = 1 + max([x['daynumber'] for x in self.read(
@@ -94,6 +96,3 @@
         'state': 'draft',
         'daynumber': get_daynr,
     }
-clieop_export()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'account_banking_nl_clieop/account_banking_nl_clieop.xml'
--- account_banking_nl_clieop/account_banking_nl_clieop.xml	2013-01-02 15:14:53 +0000
+++ account_banking_nl_clieop/account_banking_nl_clieop.xml	2013-07-25 08:56:25 +0000
@@ -11,7 +11,6 @@
         <record id="view_banking_export_clieop_form" model="ir.ui.view">
             <field name="name">account.banking.export.clieop.form</field>
             <field name="model">banking.export.clieop</field>
-            <field name="type">form</field>
             <field name="arch" type="xml">
                 <form string="Client Opdrachten Export">
                     <notebook>
@@ -48,7 +47,6 @@
         <record id="view_banking_export_clieop_tree" model="ir.ui.view">
             <field name="name">account.banking.export.clieop.tree</field>
             <field name="model">banking.export.clieop</field>
-            <field name="type">tree</field>
             <field name="arch" type="xml">
                 <tree string="Client Opdrachten Export">
                     <field name="filetype" />

=== modified file 'account_banking_nl_clieop/migrations/0.63/post-fill-ir_model_id.py'
--- account_banking_nl_clieop/migrations/0.63/post-fill-ir_model_id.py	2011-07-24 18:58:32 +0000
+++ account_banking_nl_clieop/migrations/0.63/post-fill-ir_model_id.py	2013-07-25 08:56:25 +0000
@@ -4,16 +4,16 @@
 #    Copyright (C) 2011 Therp BV (<http://therp.nl>)
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking_nl_clieop/migrations/0.64/post-set-payment-order-type.py'
--- account_banking_nl_clieop/migrations/0.64/post-set-payment-order-type.py	2011-12-27 12:00:52 +0000
+++ account_banking_nl_clieop/migrations/0.64/post-set-payment-order-type.py	2013-07-25 08:56:25 +0000
@@ -4,16 +4,16 @@
 #    Copyright (C) 2011 Therp BV (<http://therp.nl>)
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking_nl_clieop/wizard/__init__.py'
--- account_banking_nl_clieop/wizard/__init__.py	2010-01-26 20:55:24 +0000
+++ account_banking_nl_clieop/wizard/__init__.py	2013-07-25 08:56:25 +0000
@@ -5,16 +5,16 @@
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking_nl_clieop/wizard/clieop.py'
--- account_banking_nl_clieop/wizard/clieop.py	2013-03-21 13:27:19 +0000
+++ account_banking_nl_clieop/wizard/clieop.py	2013-07-25 08:56:25 +0000
@@ -5,16 +5,16 @@
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking_nl_clieop/wizard/export_clieop.py'
--- account_banking_nl_clieop/wizard/export_clieop.py	2013-01-02 15:14:53 +0000
+++ account_banking_nl_clieop/wizard/export_clieop.py	2013-07-25 08:56:25 +0000
@@ -2,40 +2,42 @@
 ##############################################################################
 #
 #    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
+#                  2011 - 2013 Therp BV (<http://therp.nl>).
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
 
 import base64
 from datetime import datetime, date, timedelta
-from osv import osv, fields
-from tools.translate import _
-import netsvc
-from account_banking import sepa
-import clieop
-
-def strpdate(arg, format='%Y-%m-%d'):
-    '''shortcut'''
-    return datetime.strptime(arg, format).date()
-
-def strfdate(arg, format='%Y-%m-%d'):
-    '''shortcut'''
-    return arg.strftime(format)
-
-class banking_export_clieop_wizard(osv.osv_memory):
+from openerp.osv import orm, fields
+from openerp.tools.translate import _
+from openerp import netsvc
+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'
     _columns = {
@@ -151,21 +153,17 @@
             ),
         }
 
-    _defaults = {
-        'test': True,
-        }
-
-    def create(self, cursor, uid, vals, context=None):
+    def create(self, cr, uid, vals, context=None):
         '''
         Retrieve a sane set of default values based on the payment orders
         from the context.
         '''
         if 'batchtype' not in vals:
-            self.check_orders(cursor, uid, vals, context)
+            self.check_orders(cr, uid, vals, context)
         return super(banking_export_clieop_wizard, self).create(
-            cursor, uid, vals, context)
+            cr, uid, vals, context)
 
-    def check_orders(self, cursor, uid, vals, context):
+    def check_orders(self, cr, uid, vals, context):
         '''
         Check payment type for all orders.
 
@@ -177,14 +175,14 @@
         Also mind that rates for batches are way higher than those for
         transactions. It pays to limit the number of batches.
         '''
-        today = date.today()
+        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
         payment_order_ids = context.get('active_ids', [])
         runs = {}
         # Only orders of same type can be combined
-        payment_orders = payment_order_obj.browse(cursor, uid, payment_order_ids)
+        payment_orders = payment_order_obj.browse(cr, uid, payment_order_ids)
         for payment_order in payment_orders:
 
             payment_type = payment_order.mode.type.code
@@ -194,8 +192,8 @@
                 runs[payment_type] = [payment_order]
 
             if payment_order.date_prefered == 'fixed':
-                if payment_order.date_planned:
-                    execution_date = strpdate(payment_order.date_planned)
+                if payment_order.date_scheduled:
+                    execution_date = strpdate(payment_order.date_scheduled)
                 else:
                     execution_date = today
             elif payment_order.date_prefered == 'now':
@@ -212,12 +210,12 @@
                     else:
                         execution_date = today
                 if execution_date and execution_date >= max_date:
-                    raise osv.except_osv(
+                    raise orm.except_orm(
                         _('Error'),
                         _('You can\'t create ClieOp orders more than 30 days in advance.')
                     )
         if len(runs) != 1:
-            raise osv.except_osv(
+            raise orm.except_orm(
                 _('Error'),
                 _('You can only combine payment orders of the same type')
             )
@@ -231,12 +229,12 @@
             'state': 'create',
             })
 
-    def create_clieop(self, cursor, uid, ids, context):
+    def create_clieop(self, cr, uid, ids, context):
         '''
         Wizard to actually create the ClieOp3 file
         '''
         payment_order_obj = self.pool.get('payment.order')
-        clieop_export = self.browse(cursor, uid, ids, context)[0]
+        clieop_export = self.browse(cr, uid, ids, context)[0]
         clieopfile = None
         for payment_order in clieop_export.payment_order_ids:
             if not clieopfile:
@@ -253,7 +251,7 @@
                 else:
                     our_account_nr = payment_order.mode.bank_id.acc_number
                 if not our_account_nr:
-                    raise osv.except_osv(
+                    raise orm.except_orm(
                         _('Error'),
                         _('Your bank account has to have a valid account number')
                     )
@@ -267,7 +265,7 @@
                                  accountno_sender = our_account_nr,
                                  seqno = self.pool.get(
                                      'banking.export.clieop').get_daynr(
-                                     cursor, uid, context=context),
+                                     cr, uid, context=context),
                                  test = clieop_export['test']
                              )
 
@@ -291,7 +289,7 @@
             for line in payment_order.line_ids:
                 # Check on missing partner of bank account (this can happen!)
                 if not line.bank_id or not line.bank_id.partner_id:
-                    raise osv.except_osv(
+                    raise orm.except_orm(
                         _('Error'),
                         _('There is insufficient information.\r\n'
                           'Both destination address and account '
@@ -314,7 +312,7 @@
                 # Is this an IBAN account?
                 if iban.valid:
                     if iban.countrycode != 'NL':
-                        raise osv.except_osv(
+                        raise orm.except_orm(
                             _('Error'),
                             _('You cannot send international bank transfers '
                               'through ClieOp3!')
@@ -331,7 +329,7 @@
         # Generate the specifics of this clieopfile
         order = clieopfile.order
         file_id = self.pool.get('banking.export.clieop').create(
-            cursor, uid, dict(
+            cr, uid, dict(
                 filetype = order.name_transactioncode,
                 identification = order.identification,
                 prefered_date = strfdate(order.preferred_execution_date),
@@ -346,7 +344,7 @@
                     [6, 0, [x.id for x in clieop_export['payment_order_ids']]]
                      ],
                     ), context)
-        self.write(cursor, uid, [ids[0]], dict(
+        self.write(cr, uid, [ids[0]], dict(
                 filetype = order.name_transactioncode,
                 testcode = order.testcode,
                 file_id = file_id,
@@ -364,31 +362,27 @@
             'res_id': ids[0] or False,
         }
 
-    def cancel_clieop(self, cursor, uid, ids, context):
+    def cancel_clieop(self, cr, uid, ids, context):
         '''
         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'][0])
+        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])
         return {'type': 'ir.actions.act_window_close'}
 
-    def save_clieop(self, cursor, uid, ids, context):
+    def save_clieop(self, cr, uid, ids, context):
         '''
         Save the ClieOp: mark all payments in the file as 'sent', if not a test
         '''
         clieop_export = self.browse(
-            cursor, uid, ids, context)[0]
+            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(
-                cursor, uid, clieop_export['file_id'].id, {'state': 'sent'}
+                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', cursor)
+                wf_service.trg_validate(uid, 'payment.order', order.id, 'sent', cr)
         return {'type': 'ir.actions.act_window_close'}
-
-banking_export_clieop_wizard()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'account_banking_nl_clieop/wizard/export_clieop_view.xml'
--- account_banking_nl_clieop/wizard/export_clieop_view.xml	2013-01-02 15:14:53 +0000
+++ account_banking_nl_clieop/wizard/export_clieop_view.xml	2013-07-25 08:56:25 +0000
@@ -4,7 +4,6 @@
         <record id="banking_export_clieop_wizard_view" model="ir.ui.view">
             <field name="name">banking.export.clieop.wizard.view</field>
             <field name="model">banking.export.clieop.wizard</field>
-            <field name="type">form</field>
             <field name="arch" type="xml">
                 <form string="Client Opdrachten Export">
                     <field name="state" invisible="True"/>

=== modified file 'account_banking_nl_girotel/__init__.py'
--- account_banking_nl_girotel/__init__.py	2010-07-16 15:28:32 +0000
+++ account_banking_nl_girotel/__init__.py	2013-07-25 08:56:25 +0000
@@ -11,16 +11,16 @@
 #    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 General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== renamed file 'account_banking_nl_girotel/__terp__.py' => 'account_banking_nl_girotel/__openerp__.py'
--- account_banking_nl_girotel/__terp__.py	2011-05-05 10:29:28 +0000
+++ account_banking_nl_girotel/__openerp__.py	2013-07-25 08:56:25 +0000
@@ -3,44 +3,35 @@
 #    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
 #    All Rights Reserved
 #
-#    WARNING: This program as such is intended to be used by professional
-#    programmers who take the whole responsability of assessing all potential
-#    consequences resulting from its eventual inadequacies and bugs
-#    End users who are looking for a ready-to-use solution with commercial
-#    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 General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
 {
     'name': 'Account Banking - Girotel',
     'version': '0.62',
-    'license': 'GPL-3',
+    'license': 'AGPL-3',
     'author': 'EduSense BV',
     'website': 'http://www.edusense.nl',
     'category': 'Account Banking',
     'depends': ['account_banking'],
-    'init_xml': [],
-    'update_xml': [
+    'data': [
         #'security/ir.model.access.csv',
     ],
-    'demo_xml': [],
     'description': '''
     Module to import Dutch Girotel format transation files.
 
     This modules contains no logic, just an import filter for account_banking.
     ''',
-    'active': False,
     'installable': True,
 }

=== modified file 'account_banking_nl_girotel/girotel.py'
--- account_banking_nl_girotel/girotel.py	2013-06-10 13:47:38 +0000
+++ account_banking_nl_girotel/girotel.py	2013-07-25 08:56:25 +0000
@@ -5,16 +5,16 @@
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
@@ -45,6 +45,7 @@
 from account_banking.parsers import models
 from account_banking.parsers.convert import str2date, to_swift
 from tools.translate import _
+import re
 import csv
 import re
 
@@ -106,6 +107,13 @@
         self.date = str2date(self.date, '%Y%m%d')
         if self.direction == 'A':
             self.transferred_amount = -float(self.transferred_amount)
+            if (self.transfer_type == 'VZ'
+                    and (not self.remote_account or self.remote_account == '0')
+                    and (not self.message or re.match('^\s*$', self.message))
+                    and self.remote_owner.startswith('TOTAAL ')):
+                self.transfer_type = 'PB'
+                self.message = self.remote_owner
+                self.remove_owner = False
         else:
             self.transferred_amount = float(self.transferred_amount)
         self.local_account = self.local_account.zfill(10)
@@ -141,7 +149,8 @@
         'GT': bt.ORDER,
         'IC': bt.DIRECT_DEBIT,
         'OV': bt.ORDER,
-        'VZ': bt.PAYMENT_BATCH,
+        'VZ': bt.ORDER,
+        'PB': bt.PAYMENT_BATCH,
     }
 
     structured_description_regex = re.compile(
@@ -176,11 +185,14 @@
         4. Cash withdrawals from banks are too not seen as a transfer between
         two accounts - the cash exits the banking system. These withdrawals
         have their transfer_type set to 'GM'.
+        5. Aggregated payment batches. These transactions have transfer type
+        'VZ' natively but are changed to 'PB' while parsing. These transactions
+        have no remote account.
         '''
         return bool(self.transferred_amount and self.execution_date and (
                     self.remote_account or
                     self.transfer_type in [
-                        'DV', 'BT', 'BA', 'GM',
+                        'DV', 'PB', 'BT', 'BA', 'GM',
                     ]))
 
     def refold_message(self, message):

=== modified file 'account_banking_nl_ing/__init__.py'
--- account_banking_nl_ing/__init__.py	2011-12-11 16:09:20 +0000
+++ account_banking_nl_ing/__init__.py	2013-07-25 08:56:25 +0000
@@ -1,4 +1,2 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
 import ing
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'account_banking_nl_ing/__openerp__.py'
--- account_banking_nl_ing/__openerp__.py	2012-10-04 08:56:19 +0000
+++ account_banking_nl_ing/__openerp__.py	2013-07-25 08:56:25 +0000
@@ -8,39 +8,29 @@
 #                              
 #    All Rights Reserved
 #
-#    WARNING: This program as such is intended to be used by professional
-#    programmers who take the whole responsability of assessing all potential
-#    consequences resulting from its eventual inadequacies and bugs
-#    End users who are looking for a ready-to-use solution with commercial
-#    garantees and support are strongly adviced to contract EduSense BV
-#    or Therp BV
-#
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
+
 {
     'name': 'ING (NL) Bank Statements Import',
     'version': '0.1.140',
-    'license': 'GPL-3',
+    'license': 'AGPL-3',
     'author': ['Smile', 'Therp BV', 'EduSense BV'],
     'website': 'https://launchpad.net/banking-addons',
     'category': 'Banking addons',
     'depends': ['account_banking'],
-    'init_xml': [],
-    'update_xml': [
-    ],
-    'demo_xml': [],
     'description': '''
 Module to import Dutch ING bank format transaction files. The format covered
 is the CSV format with either 'dd-mm-yyyy' or 'yyyymmdd' date syntax.
@@ -57,6 +47,5 @@
 
 This modules contains no logic, just an import filter for account_banking.
     ''',
-    'active': False,
     'installable': True,
 }

=== removed file 'account_banking_nl_ing/__terp__.py'
--- account_banking_nl_ing/__terp__.py	2011-12-21 11:26:36 +0000
+++ account_banking_nl_ing/__terp__.py	1970-01-01 00:00:00 +0000
@@ -1,58 +0,0 @@
-##############################################################################
-#
-#    Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
-#                              and Therp BV (<http://therp.nl>)
-#    All Rights Reserved
-#
-#    WARNING: This program as such is intended to be used by professional
-#    programmers who take the whole responsability of assessing all potential
-#    consequences resulting from its eventual inadequacies and bugs
-#    End users who are looking for a ready-to-use solution with commercial
-#    garantees and support are strongly adviced to contract EduSense BV
-#    or Therp BV
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU 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,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
-{
-    'name': 'ING (NL) Bank Statements Import',
-    'version': '0.1.89',
-    'license': 'GPL-3',
-    'author': 'Smile / Therp BV / EduSense BV',
-    'website': 'https://launchpad.net/banking-addons',
-    'category': 'Banking addons',
-    'depends': ['account_banking'],
-    'init_xml': [],
-    'update_xml': [
-    ],
-    'demo_xml': [],
-    'description': '''
-
-Module to import Dutch ING bank format transation files (CSV format).
-
-As the ING bank does not provide detailed specification concerning possible
-values and their meaning for the fields in the CSV file format, the statements
-are parsed according to an educated guess based on incomplete information.
-You can contact the banking-addons developers through their launchpad page and
-help improve the performance of this import filter on
-https://launchpad.net/banking-addons.
-
-Note that imported bank transfers are organized in statements covering periods
-of one week, even if the imported files cover a different period.
-
-This modules contains no logic, just an import filter for account_banking.
-    ''',
-    'active': False,
-    'installable': True,
-}

=== modified file 'account_banking_nl_ing/ing.py'
--- account_banking_nl_ing/ing.py	2012-10-04 08:56:19 +0000
+++ account_banking_nl_ing/ing.py	2013-07-25 08:56:25 +0000
@@ -1,4 +1,4 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
 ##############################################################################
 #
 #    Copyright (C) 2011 Smile (<http://smile.fr>).
@@ -10,25 +10,25 @@
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
 
 from datetime import datetime
-from account_banking.parsers import models
-from account_banking.parsers.convert import str2date
-from account_banking.sepa import postalcode
-from tools.translate import _
+from openerp.addons.account_banking.parsers import models
+from openerp.addons.account_banking.parsers.convert import str2date
+from openerp.addons.account_banking.sepa import postalcode
+from openerp.tools.translate import _
 
 import re
 import csv
@@ -77,6 +77,7 @@
         # Normalize basic account numbers
         self.remote_account = self.remote_account.replace('.', '').zfill(10)
         self.local_account = self.local_account.replace('.', '').zfill(10)             
+        
 
 class transaction(models.mem_bank_transaction):
     '''
@@ -114,6 +115,8 @@
 
     # global expression for matching storno references
     ref_expr = re.compile('REF[\*:]([0-9A-Z-z_-]+)')
+    # match references for Acceptgiro's through Internet banking
+    kn_expr = re.compile('KN: ([^ ]+)')
 
     def __init__(self, line, *args, **kwargs):
         '''
@@ -149,6 +152,58 @@
                     self.reference = res.group(1)
                     self.storno_retry = True
             self.remote_owner = False
+        if self.transfer_type == 'GT':
+            res = self.kn_expr.search(self.message)
+            if res:
+                self.reference = res.group(1)
+        if self.transfer_type == 'AC':
+            self.parse_acceptgiro()
+        if self.message and not self.reference:
+            self.reference = self.message
+
+    def parse_acceptgiro(self):
+        """
+        Entries of type 'Acceptgiro' can contain the reference
+        in the 'name' column, as well as full address information
+        in the 'message' column'
+        """
+        reference = ''
+        street = False
+        zipcode = False
+        street = False
+        before = False
+        if self.remote_owner.startswith('KN: '):
+            self.reference = self.remote_owner[4:]
+            self.remote_owner = ''
+        if 'KN: ' in self.message:
+            index = self.message.index('KN: ')
+            before = self.message[:index]
+            self.message = self.message[index:]
+        expression = (
+            "^\s*(KN:\s*(?P<kn>[^\s]+))?(\s*)"
+            "(?P<navr>NAVR:\s*[^\s]+)?(\s*)(?P<after>.*?)$")
+        msg_match = re.match(expression, self.message)
+        after = msg_match.group('after')
+        kn = msg_match.group('kn')
+        navr = msg_match.group('navr')
+        if kn:
+            self.reference = kn[4:]
+        self.message = 'Acceptgiro %s' % (navr or '')
+        if after:
+            parts = [after[i:i+33] for i in range(0, len(after), 33)]
+            if parts and not self.remote_owner:
+                self.remote_owner = parts.pop(0).strip()
+            if parts:
+                self.remote_owner_address = [parts.pop(0).strip()]
+            if parts:
+                zip_city = parts.pop(0).strip()
+                zip_match = re.match(
+                    "^(?P<zipcode>[^ ]{6})\s+(?P<city>.*?)$", zip_city)
+                if zip_match:
+                    self.remote_owner_postalcode = zip_match.group('zipcode')
+                    self.remote_owner_city = zip_match.group('city')
+        if before and not self.remote_owner_city:
+            self.remote_owner_city = before.strip()
 
     def is_valid(self):
         if not self.error_message:

=== modified file 'account_banking_nl_multibank/__init__.py'
--- account_banking_nl_multibank/__init__.py	2010-01-26 20:55:24 +0000
+++ account_banking_nl_multibank/__init__.py	2013-07-25 08:56:25 +0000
@@ -11,16 +11,16 @@
 #    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 General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== renamed file 'account_banking_nl_multibank/__terp__.py' => 'account_banking_nl_multibank/__openerp__.py'
--- account_banking_nl_multibank/__terp__.py	2011-05-05 10:29:28 +0000
+++ account_banking_nl_multibank/__openerp__.py	2013-07-25 08:56:25 +0000
@@ -1,46 +1,36 @@
+# -*- coding: utf-8 -*-
 ##############################################################################
 #
 #    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
 #    All Rights Reserved
 #
-#    WARNING: This program as such is intended to be used by professional
-#    programmers who take the whole responsability of assessing all potential
-#    consequences resulting from its eventual inadequacies and bugs
-#    End users who are looking for a ready-to-use solution with commercial
-#    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 General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
+
 {
     'name': 'Account Banking',
     'version': '0.62',
-    'license': 'GPL-3',
+    'license': 'AGPL-3',
     'author': 'EduSense BV',
     'website': 'http://www.edusense.nl',
     'category': 'Account Banking',
     'depends': ['account_banking'],
-    'init_xml': [],
-    'update_xml': [
-        #'security/ir.model.access.csv',
-    ],
-    'demo_xml': [],
     'description': '''
     Module to import Dutch Multibank format transation files.
 
     This modules contains no logic, just an import filter for account_banking.
     ''',
-    'active': False,
     'installable': True,
 }

=== modified file 'account_banking_nl_multibank/multibank.py'
--- account_banking_nl_multibank/multibank.py	2012-01-17 08:48:10 +0000
+++ account_banking_nl_multibank/multibank.py	2013-07-25 08:56:25 +0000
@@ -5,16 +5,16 @@
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking_nl_triodos/__init__.py'
--- account_banking_nl_triodos/__init__.py	2011-04-26 21:00:12 +0000
+++ account_banking_nl_triodos/__init__.py	2013-07-25 08:56:25 +0000
@@ -13,16 +13,16 @@
 #    or Therp BV
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking_nl_triodos/__openerp__.py'
--- account_banking_nl_triodos/__openerp__.py	2013-05-19 20:32:36 +0000
+++ account_banking_nl_triodos/__openerp__.py	2013-07-25 08:56:25 +0000
@@ -4,40 +4,34 @@
 #                              and Therp BV (<http://therp.nl>)
 #    All Rights Reserved
 #
-#    WARNING: This program as such is intended to be used by professional
-#    programmers who take the whole responsability of assessing all potential
-#    consequences resulting from its eventual inadequacies and bugs
-#    End users who are looking for a ready-to-use solution with commercial
-#    garantees and support are strongly adviced to contract EduSense BV
-#    or Therp BV
-#
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
 {
     'name': 'Triodos (NL) Bank Statements Import',
+<<<<<<< TREE
     'version': '0.168',
     'license': 'GPL-3',
     'author': 'Therp BV / EduSense BV',
+=======
+    'version': '0.92',
+    'license': 'AGPL-3',
+    'author': ['Therp BV', 'EduSense BV'],
+>>>>>>> MERGE-SOURCE
     'website': 'https://launchpad.net/account-banking',
     'category': 'Account Banking',
     'depends': ['account_banking'],
-    'init_xml': [],
-    'update_xml': [
-        #'security/ir.model.access.csv',
-    ],
-    'demo_xml': [],
     'description': '''
 Module to import Dutch Triodos bank format transation files (CSV format).
 
@@ -53,6 +47,5 @@
 
 This modules contains no logic, just an import filter for account_banking.
     ''',
-    'active': False,
     'installable': True,
 }

=== removed file 'account_banking_nl_triodos/__terp__.py'
--- account_banking_nl_triodos/__terp__.py	2011-05-05 10:29:28 +0000
+++ account_banking_nl_triodos/__terp__.py	1970-01-01 00:00:00 +0000
@@ -1,58 +0,0 @@
-##############################################################################
-#
-#    Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
-#                              and Therp BV (<http://therp.nl>)
-#    All Rights Reserved
-#
-#    WARNING: This program as such is intended to be used by professional
-#    programmers who take the whole responsability of assessing all potential
-#    consequences resulting from its eventual inadequacies and bugs
-#    End users who are looking for a ready-to-use solution with commercial
-#    garantees and support are strongly adviced to contract EduSense BV
-#    or Therp BV
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU 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,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
-{
-    'name': 'Triodos (NL) Bank Statements Import',
-    'version': '0.62',
-    'license': 'GPL-3',
-    'author': 'Therp BV / EduSense BV',
-    'website': 'https://launchpad.net/account-banking',
-    'category': 'Account Banking',
-    'depends': ['account_banking'],
-    'init_xml': [],
-    'update_xml': [
-        #'security/ir.model.access.csv',
-    ],
-    'demo_xml': [],
-    'description': '''
-Module to import Dutch Triodos bank format transation files (CSV format).
-
-As the Triodos bank does not provide detailed specification concerning possible
-values and their meaning for the fields in the CSV file format, the statements
-are parsed according to an educated guess based on incomplete information.
-You can contact the account-banking developers through their launchpad page and
-help improve the performance of this import filter on
-https://launchpad.net/account-banking.
-
-Note that imported bank transfers are organized in statements covering periods
-of one week, even if the imported files cover a different period.
-
-This modules contains no logic, just an import filter for account_banking.
-    ''',
-    'active': False,
-    'installable': True,
-}

=== modified file 'account_banking_nl_triodos/triodos.py'
--- account_banking_nl_triodos/triodos.py	2013-05-19 20:32:36 +0000
+++ account_banking_nl_triodos/triodos.py	2013-07-25 08:56:25 +0000
@@ -6,16 +6,16 @@
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== added directory 'account_banking_payment'
=== added file 'account_banking_payment/__init__.py'
--- account_banking_payment/__init__.py	1970-01-01 00:00:00 +0000
+++ account_banking_payment/__init__.py	2013-07-25 08:56:25 +0000
@@ -0,0 +1,1 @@
+import model

=== added file 'account_banking_payment/__openerp__.py'
--- account_banking_payment/__openerp__.py	1970-01-01 00:00:00 +0000
+++ account_banking_payment/__openerp__.py	2013-07-25 08:56:25 +0000
@@ -0,0 +1,58 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
+#              (C) 2011 - 2013 Therp BV (<http://therp.nl>).
+#            
+#    All other contributions are (C) by their respective contributors
+#
+#    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 (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+{
+    'name': 'Account Banking - Payments',
+    'version': '0.1.164',
+    'license': 'AGPL-3',
+    'author': 'Banking addons community',
+    'website': 'https://launchpad.net/banking-addons',
+    'category': 'Banking addons',
+    'depends': [
+        'account_banking',
+        'account_payment',
+        ],
+    'data': [
+        'view/account_payment.xml',
+        'view/banking_transaction_wizard.xml',
+        'view/payment_mode.xml',
+        'view/payment_mode_type.xml',
+        'view/bank_payment_manual.xml',
+        'data/payment_mode_type.xml',
+        'workflow/account_payment.xml',
+        'security/ir.model.access.csv',
+    ],
+    'description': '''
+    This addon adds payment infrastructure to the Banking Addons.
+
+    * Extends payments for digital banking:
+      + Adapted workflow in payments to reflect banking operations
+      + Relies on account_payment mechanics to extend with export generators.
+      - ClieOp3 (NL) payment and direct debit orders files available as
+        account_banking_nl_clieop
+    ''',
+    'auto_install': True,
+    'installable': True,
+}

=== added directory 'account_banking_payment/data'
=== added file 'account_banking_payment/data/payment_mode_type.xml'
--- account_banking_payment/data/payment_mode_type.xml	1970-01-01 00:00:00 +0000
+++ account_banking_payment/data/payment_mode_type.xml	2013-07-25 08:56:25 +0000
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <!-- Add manual bank transfer as default payment option -->
+        <record model="payment.mode.type" id="account_banking.manual_bank_tranfer">
+            <field name="name">Manual Bank Transfer</field>
+            <field name="code">BANKMAN</field>
+            <field name="suitable_bank_types"
+                eval="[(6,0,[ref('base.bank_normal'),ref('base_iban.bank_iban'),])]" />
+            <field name="ir_model_id"
+                   ref="account_banking_payment.model_payment_manual"/>
+        </record>
+    </data>
+</openerp>

=== added directory 'account_banking_payment/model'
=== added file 'account_banking_payment/model/__init__.py'
--- account_banking_payment/model/__init__.py	1970-01-01 00:00:00 +0000
+++ account_banking_payment/model/__init__.py	2013-07-25 08:56:25 +0000
@@ -0,0 +1,9 @@
+import account_payment
+import payment_line
+import payment_mode
+import payment_mode_type
+import payment_order_create
+import banking_import_transaction
+import banking_transaction_wizard
+import bank_payment_manual
+import banking_import_line

=== added file 'account_banking_payment/model/account_payment.py'
--- account_banking_payment/model/account_payment.py	1970-01-01 00:00:00 +0000
+++ account_banking_payment/model/account_payment.py	2013-07-25 08:56:25 +0000
@@ -0,0 +1,360 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
+#              (C) 2011 - 2013 Therp BV (<http://therp.nl>).
+#            
+#    All other contributions are (C) by their respective contributors
+#
+#    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 (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import orm, fields
+from openerp.tools.translate import _
+from openerp import netsvc
+
+
+class payment_order(orm.Model):
+    '''
+    Enable extra states for payment exports
+    '''
+    _inherit = 'payment.order'
+
+    _columns = {
+        'date_scheduled': fields.date(
+            'Scheduled date if fixed',
+            states={
+                'sent': [('readonly', True)],
+                'rejected': [('readonly', True)],
+                'done': [('readonly', True)]
+            },
+            help='Select a date if you have chosen Preferred Date to be fixed.'
+        ),
+        'reference': fields.char(
+            'Reference', size=128, required=True,
+            states={
+                'sent': [('readonly', True)],
+                'rejected': [('readonly', True)],
+                'done': [('readonly', True)]
+            },
+        ),
+        'mode': fields.many2one(
+            'payment.mode', 'Payment mode', select=True, required=True,
+            states={
+                'sent': [('readonly', True)],
+                'rejected': [('readonly', True)],
+                'done': [('readonly', True)]
+            },
+            help='Select the Payment Mode to be applied.',
+        ),
+        'state': fields.selection([
+            ('draft', 'Draft'),
+            ('open','Confirmed'),
+            ('cancel','Cancelled'),
+            ('sent', 'Sent'),
+            ('rejected', 'Rejected'),
+            ('done','Done'),
+            ], 'State', select=True
+        ),
+        'line_ids': fields.one2many(
+            'payment.line', 'order_id', 'Payment lines',
+            states={
+                'open': [('readonly', True)],
+                'cancel': [('readonly', True)],
+                'sent': [('readonly', True)],
+                'rejected': [('readonly', True)],
+                'done': [('readonly', True)]
+            },
+        ),
+        'user_id': fields.many2one(
+            'res.users','User', required=True,
+            states={
+                'sent': [('readonly', True)],
+                'rejected': [('readonly', True)],
+                'done': [('readonly', True)]
+            },
+        ),
+        'date_prefered': fields.selection([
+            ('now', 'Directly'),
+            ('due', 'Due date'),
+            ('fixed', 'Fixed date')
+            ], "Preferred date", change_default=True, required=True,
+            states={
+                'sent': [('readonly', True)],
+                'rejected': [('readonly', True)],
+                'done': [('readonly', True)]
+            },
+            help=("Choose an option for the Payment Order:'Fixed' stands for a "
+                  "date specified by you.'Directly' stands for the direct "
+                  "execution.'Due date' stands for the scheduled date of "
+                  "execution."
+                 )
+            ),
+        'payment_order_type': fields.selection(
+            [('payment', 'Payment'),('debit', 'Direct debit')],
+            'Payment order type', required=True,
+            ),
+        'date_sent': fields.date('Send date', readonly=True),
+    }
+
+    _defaults = {
+        'payment_order_type': 'payment',
+        }
+
+    def launch_wizard(self, cr, uid, ids, context=None):
+        """
+        Search for a wizard to launch according to the type.
+        If type is manual. just confirm the order.
+        Previously (pre-v6) in account_payment/wizard/wizard_pay.py
+        """
+        if context == None:
+            context = {}
+        result = {}
+        orders = self.browse(cr, uid, ids, context)
+        order = orders[0]
+        # check if a wizard is defined for the first order
+        if order.mode.type and order.mode.type.ir_model_id:
+            context['active_ids'] = ids
+            wizard_model = order.mode.type.ir_model_id.model
+            wizard_obj = self.pool.get(wizard_model)
+            wizard_id = wizard_obj.create(cr, uid, {}, context)
+            result = {
+                'name': wizard_obj._description or _('Payment Order Export'),
+                'view_type': 'form',
+                'view_mode': 'form',
+                'res_model': wizard_model,
+                'domain': [],
+                'context': context,
+                'type': 'ir.actions.act_window',
+                'target': 'new',
+                'res_id': wizard_id,
+                'nodestroy': True,
+                }
+        else:
+            # should all be manual orders without type or wizard model
+            for order in orders[1:]:
+                if order.mode.type and order.mode.type.ir_model_id:
+                    raise orm.except_orm(
+                        _('Error'),
+                        _('You can only combine payment orders of the same type')
+                        )
+            # process manual payments
+            wf_service = netsvc.LocalService('workflow')
+            for order_id in ids:
+                wf_service.trg_validate(uid, 'payment.order', order_id, 'sent', cr)
+        return result
+
+    def _write_payment_lines(self, cr, uid, ids, **kwargs):
+        '''
+        ORM method for setting attributes of corresponding payment.line objects.
+        Note that while this is ORM compliant, it is also very ineffecient due
+        to the absence of filters on writes and hence the requirement to
+        filter on the client(=OpenERP server) side.
+        '''
+        if not hasattr(ids, '__iter__'):
+            ids = [ids]
+        payment_line_obj = self.pool.get('payment.line')
+        line_ids = payment_line_obj.search(
+            cr, uid, [
+                ('order_id', 'in', ids)
+            ])
+        payment_line_obj.write(cr, uid, line_ids, kwargs)
+
+    def action_rejected(self, cr, uid, ids, *args):
+        '''
+        Set both self and payment lines to state 'rejected'.
+        '''
+        wf_service = netsvc.LocalService('workflow')
+        for id in ids:
+            wf_service.trg_validate(uid, 'payment.order', id, 'rejected', cr)
+        return True
+
+    def set_done(self, cr, uid, ids, *args):
+        '''
+        Extend standard transition to update children as well.
+        '''
+        self._write_payment_lines(
+            cr, uid, ids,
+            date_done=fields.date.context_today(self, cr, uid))
+        return super(payment_order, self).set_done(
+            cr, uid, ids, *args
+        )
+
+    def debit_reconcile_transfer(self, cr, uid, payment_order_id, 
+                                 amount, currency, context=None):
+        """
+        During import of bank statements, create the reconcile on the transfer
+        account containing all the open move lines on the transfer account.
+        """
+        move_line_obj = self.pool.get('account.move.line')
+        order = self.browse(cr, uid, payment_order_id, context)
+        line_ids = []
+        reconcile_id = False
+        if not order.line_ids[0].transit_move_line_id:
+            wf_service = netsvc.LocalService('workflow')
+            wf_service.trg_validate(
+                uid, 'payment.order', payment_order_id, 'done', cr)
+            return False
+        for order_line in order.line_ids:
+            for line in order_line.transit_move_line_id.move_id.line_id:
+                if line.account_id.type == 'other' and not line.reconcile_id:
+                    line_ids.append(line.id)
+        if self.pool.get('res.currency').is_zero(
+            cr, uid, currency,
+            move_line_obj.get_balance(cr, uid, line_ids) - amount):
+            reconcile_id = self.pool.get('account.move.reconcile').create(
+                cr, uid, 
+                {'type': 'auto', 'line_id': [(6, 0, line_ids)]},
+                context)
+            # set direct debit order to finished state
+            wf_service = netsvc.LocalService('workflow')
+            wf_service.trg_validate(
+                uid, 'payment.order', payment_order_id, 'done', cr)
+        return reconcile_id
+
+    def debit_unreconcile_transfer(self, cr, uid, payment_order_id, reconcile_id,
+                                 amount, currency, context=None):
+        """
+        Due to a cancelled bank statements import, unreconcile the move on
+        the transfer account. Delegate the conditions to the workflow.
+        Raise on failure for rollback.
+
+        Workflow appears to return False even on success so we just check
+        the order's state that we know to be set to 'sent' in that case.
+        """
+        self.pool.get('account.move.reconcile').unlink(
+            cr, uid, [reconcile_id], context=context)
+        netsvc.LocalService('workflow').trg_validate(
+            uid, 'payment.order', payment_order_id, 'undo_done', cr)
+        state = self.pool.get('payment.order').read(
+            cr, uid, payment_order_id, ['state'], context=context)['state']
+        if state != 'sent':
+            raise orm.except_orm(
+                _("Cannot unreconcile"),
+                _("Cannot unreconcile payment order: "+
+                  "Workflow will not allow it."))
+        return True
+
+    def test_undo_done(self, cr, uid, ids, context=None):
+        """ 
+        Called from the workflow. Used to unset done state on
+        payment orders that were reconciled with bank transfers
+        which are being cancelled.
+
+        Test if the payment order has not been reconciled. Depends
+        on the restriction that transit move lines should use an
+        account of type 'other', and on the restriction of payment
+        and debit orders that they only take moves on accounts
+        payable/receivable.
+        """
+        for order in self.browse(cr, uid, ids, context=context):
+            for order_line in order.line_ids:
+                if order_line.transit_move_line_id.move_id:
+                    for line in order_line.transit_move_line_id.move_id.line_id:
+                        if (line.account_id.type == 'other' and
+                                line.reconcile_id):
+                            return False
+        return True
+        
+    def action_sent(self, cr, uid, ids, context=None):
+        """ 
+        Create the moves that pay off the move lines from
+        the debit order. This happens when the debit order file is
+        generated.
+        """
+        account_move_obj = self.pool.get('account.move')
+        account_move_line_obj = self.pool.get('account.move.line')
+        payment_line_obj = self.pool.get('payment.line')
+        labels = {
+            'payment': _('Payment order'),
+            'debit': _('Direct debit order'),
+            }
+        for order in self.browse(cr, uid, ids, context=context):
+            for line in order.line_ids:
+                # basic checks
+                if not line.move_line_id:
+                    raise orm.except_orm(
+                        _('Error'),
+                        _('No move line provided for line %s') % line.name)
+                if line.move_line_id.reconcile_id:
+                    raise orm.except_orm(
+                        _('Error'),
+                        _('Move line %s has already been paid/reconciled') % 
+                        line.move_line_id.name
+                        )
+
+                move_id = account_move_obj.create(cr, uid, {
+                        'journal_id': order.mode.transfer_journal_id.id,
+                        'name': '%s %s' % (labels[order.payment_order_type], 
+                                           line.move_line_id.move_id.name),
+                        'reference': '%s%s' % (order.payment_order_type[:3].upper(),
+                                               line.move_line_id.move_id.name),
+                        }, context=context)
+
+                # TODO: take multicurrency into account
+                
+                # create the debit move line on the transfer account
+                vals = {
+                    'name': _('%s for %s') % (
+                        labels[order.payment_order_type],
+                        line.move_line_id.invoice and 
+                        line.move_line_id.invoice.number or 
+                        line.move_line_id.name),
+                    'move_id': move_id,
+                    'partner_id': line.partner_id.id,
+                    'account_id': order.mode.transfer_account_id.id,
+                    'credit': (order.payment_order_type == 'payment'
+                               and line.amount or 0.0),
+                    'debit': (order.payment_order_type == 'debit'
+                              and line.amount or 0.0),
+                    'date': fields.date.context_today(
+                        self, cr, uid, context=context),
+                    }
+                transfer_move_line_id = account_move_line_obj.create(
+                    cr, uid, vals, context=context)
+
+                # create the debit move line on the receivable account
+                vals.update({
+                        'account_id': line.move_line_id.account_id.id,
+                        'credit': (order.payment_order_type == 'debit'
+                                   and line.amount or 0.0),
+                        'debit': (order.payment_order_type == 'payment'
+                                   and line.amount or 0.0),
+                        })               
+                reconcile_move_line_id = account_move_line_obj.create(
+                    cr, uid, vals, context=context)
+                
+                # register the debit move line on the payment line
+                # and call reconciliation on it
+                payment_line_obj.write(
+                    cr, uid, line.id,
+                    {'transit_move_line_id': reconcile_move_line_id},
+                    context=context)
+
+                payment_line_obj.debit_reconcile(
+                    cr, uid, line.id, context=context)
+                account_move_obj.post(cr, uid, [move_id], context=context)
+
+        # State field is written by act_sent_wait
+        self.write(cr, uid, ids, {
+                'date_sent': fields.date.context_today(
+                    self, cr, uid, context=context),
+                }, context=context)
+
+        return True
+
+

=== renamed file 'account_banking/wizard/bank_payment_manual.py' => 'account_banking_payment/model/bank_payment_manual.py'
--- account_banking/wizard/bank_payment_manual.py	2010-12-20 10:58:51 +0000
+++ account_banking_payment/model/bank_payment_manual.py	2013-07-25 08:56:25 +0000
@@ -1,20 +1,24 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
 ##############################################################################
 #
 #    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
+#              (C) 2011 - 2013 Therp BV (<http://therp.nl>).
+#            
+#    All other contributions are (C) by their respective contributors
+#
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
@@ -24,30 +28,26 @@
 bank transfers.
 '''
 
-import wizard
-import pooler
-
-class payment_manual(wizard.interface):
-    def _action_set_state_sent(self, cursor, uid, data, context):
-        '''
-        Set the payment order in state 'sent' to reflect money in transfer.
-        '''
-        payment_order_obj = pooler.get_pool(cursor.dbname)\
-                .get('payment.order')
-        payment_order_obj.action_sent(cursor, uid, [data['id']], context)
-        return {}
-        
-    states= {
-        'init' : {
-            'actions': [],
-            'result': {
-                'type':'action',
-                'action': _action_set_state_sent,
-                'state': 'end'
-            }
+from openerp.osv import orm, fields
+from openerp import netsvc
+
+
+class payment_manual(orm.TransientModel):
+    _name = 'payment.manual'
+    _description = 'Set payment orders to \'sent\' manually'
+
+    def default_get(self, cr, uid, fields_list, context=None):
+        if context and context.get('active_ids'):
+            payment_order_obj = self.pool.get('payment.order')
+            wf_service = netsvc.LocalService('workflow')
+            for order_id in context['active_ids']:
+                wf_service.trg_validate(
+                    uid, 'payment.order', order_id, 'sent', cr)
+        return super(payment_manual, self).default_get(
+            cr, uid, fields_list, context=None)
+
+    _columns = {
+        # dummy field, to trigger a call to default_get
+        'name': fields.char('Name', size=1),
         }
-    }
-
-payment_manual('account_banking.payment_manual')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+

=== added file 'account_banking_payment/model/banking_import_line.py'
--- account_banking_payment/model/banking_import_line.py	1970-01-01 00:00:00 +0000
+++ account_banking_payment/model/banking_import_line.py	2013-07-25 08:56:25 +0000
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
+#              (C) 2011 - 2013 Therp BV (<http://therp.nl>).
+#            
+#    All other contributions are (C) by their respective contributors
+#
+#    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 (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import orm, fields
+
+
+class banking_import_line(orm.TransientModel):
+    _inherit = 'banking.import.line'
+    _columns = {
+        'payment_order_id': fields.many2one(
+            'payment.order', 'Payment order'),
+        'transaction_type': fields.selection([
+                # Add payment order related transaction types
+                ('invoice', 'Invoice payment'),
+                ('payment_order_line', 'Payment from a payment order'),
+                ('payment_order', 'Aggregate payment order'),
+                ('storno', 'Canceled debit order'),
+                ('bank_costs', 'Bank costs'),
+                ('unknown', 'Unknown'),
+                ], 'Transaction type'),
+        }
+
+

=== added file 'account_banking_payment/model/banking_import_transaction.py'
--- account_banking_payment/model/banking_import_transaction.py	1970-01-01 00:00:00 +0000
+++ account_banking_payment/model/banking_import_transaction.py	2013-07-25 08:56:25 +0000
@@ -0,0 +1,392 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
+#              (C) 2011 - 2013 Therp BV (<http://therp.nl>).
+#            
+#    All other contributions are (C) by their respective contributors
+#
+#    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 (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import orm, fields
+from openerp import netsvc
+from openerp.tools.translate import _
+from openerp.addons.decimal_precision import decimal_precision as dp
+from openerp.addons.account_banking.parsers.models import mem_bank_transaction as bt
+
+
+class banking_import_transaction(orm.Model):
+    _inherit = 'banking.import.transaction'
+
+    def _match_payment_order(
+        self, cr, uid, trans, log, order_type='payment', context=None):
+
+        def equals_order_amount(payment_order, transferred_amount):
+            if (not hasattr(payment_order, 'payment_order_type')
+                    or payment_order.payment_order_type == 'payment'):
+                sign = 1
+            else:
+                sign = -1
+            total = payment_order.total + sign * transferred_amount
+            return self.pool.get('res.currency').is_zero(
+                cr, uid, trans.statement_line_id.statement_id.currency, total)
+
+        payment_order_obj = self.pool.get('payment.order')
+
+        order_ids = payment_order_obj.search(
+            cr, uid, [('payment_order_type', '=', order_type),
+                      ('state', '=', 'sent'),
+                      ('date_sent', '<=', trans.execution_date),
+                      ],
+            limit=0, context=context)
+        orders = payment_order_obj.browse(cr, uid, order_ids, context)
+        candidates = [x for x in orders if
+                      equals_order_amount(x, trans.statement_line_id.amount)]
+        if len(candidates) > 0:
+            # retrieve the common account_id, if any
+            account_id = False
+            if (candidates[0].line_ids[0].transit_move_line_id):
+                for line in candidates[0].line_ids[0].transit_move_line_id.move_id.line_id:
+                    if line.account_id.type == 'other':
+                        account_id = line.account_id.id
+                        break
+            return dict(
+                move_line_ids = False,
+                match_type = 'payment_order',
+                payment_order_ids = [x.id for x in candidates],
+                account_id = account_id,
+                partner_id = False,
+                partner_bank_id = False,
+                reference = False,
+                type='general',
+                )
+        return False
+
+    def _match_storno(
+        self, cr, uid, trans, log, context=None):
+        payment_line_obj = self.pool.get('payment.line')
+        line_ids = payment_line_obj.search(
+            cr, uid, [
+                ('order_id.payment_order_type', '=', 'debit'),
+                ('order_id.state', 'in', ['sent', 'done']),
+                ('communication', '=', trans.reference)
+                ], context=context)
+        # stornos MUST have an exact match
+        if len(line_ids) == 1:
+            account_id = payment_line_obj.get_storno_account_id(
+                cr, uid, line_ids[0], trans.statement_line_id.amount,
+                trans.statement_id.currency, context=None)
+            if account_id:
+                return dict(
+                    account_id = account_id,
+                    match_type = 'storno',
+                    payment_line_id = line_ids[0],
+                    move_line_ids=False,
+                    partner_id=False,
+                    partner_bank_id=False,
+                    reference=False,
+                    type='customer',
+                    )
+        # TODO log the reason why there is no result for transfers marked
+        # as storno
+        return False
+
+    def _match_payment(self, cr, uid, trans, payment_lines,
+                      partner_ids, bank_account_ids, log, linked_payments):
+        '''
+        Find the payment order belonging to this reference - if there is one
+        This is the easiest part: when sending payments, the returned bank info
+        should be identical to ours.
+        This also means that we do not allow for multiple candidates.
+        '''
+        # 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')(cr)[1]
+        candidates = [
+            x for x in payment_lines
+            if x.communication == trans.reference 
+            and round(x.amount, digits) == -round(
+                trans.statement_line_id.amount, digits)
+            and trans.remote_account in (x.bank_id.acc_number,
+                                         x.bank_id.acc_number_domestic)
+            ]
+        if len(candidates) == 1:
+            candidate = candidates[0]
+            # Check cache to prevent multiple matching of a single payment
+            if candidate.id not in linked_payments:
+                linked_payments[candidate.id] = True
+                move_info = self._get_move_info(
+                    cr, uid, [candidate.move_line_id.id])
+                move_info.update({
+                        'match_type': 'payment',
+                        'payment_line_id': candidate.id,
+                        })
+                return move_info
+
+        return False
+
+    def _confirm_storno(
+        self, cr, uid, transaction_id, context=None):
+        """
+        Creation of the reconciliation has been delegated to
+        *a* direct debit module, to allow for various direct debit styles
+        """
+        payment_line_pool = self.pool.get('payment.line')
+        statement_line_pool = self.pool.get('account.bank.statement.line')
+        transaction = self.browse(cr, uid, transaction_id, context=context)
+        if not transaction.payment_line_id:
+            raise orm.except_orm(
+                _("Cannot link with storno"),
+                _("No direct debit order item"))
+        reconcile_id = payment_line_pool.debit_storno(
+            cr, uid,
+            transaction.payment_line_id.id, 
+            transaction.statement_line_id.amount,
+            transaction.statement_line_id.currency,
+            transaction.storno_retry,
+            context=context)
+        statement_line_pool.write(
+            cr, uid, transaction.statement_line_id.id, 
+            {'reconcile_id': reconcile_id}, context=context)
+        transaction.refresh()
+
+    def _confirm_payment_order(
+        self, cr, uid, transaction_id, context=None):
+        """
+        Creation of the reconciliation has been delegated to
+        *a* direct debit module, to allow for various direct debit styles
+        """
+        payment_order_obj = self.pool.get('payment.order')
+        statement_line_pool = self.pool.get('account.bank.statement.line')
+        transaction = self.browse(cr, uid, transaction_id, context=context)
+        if not transaction.payment_order_id:
+            raise orm.except_orm(
+                _("Cannot reconcile"),
+                _("Cannot reconcile: no direct debit order"))
+        reconcile_id = payment_order_obj.debit_reconcile_transfer(
+            cr, uid,
+            transaction.payment_order_id.id,
+            transaction.statement_line_id.amount,
+            transaction.statement_line_id.currency,
+            context=context)
+        statement_line_pool.write(
+            cr, uid, transaction.statement_line_id.id, 
+            {'reconcile_id': reconcile_id}, context=context)
+
+    def _confirm_payment(
+        self, cr, uid, transaction_id, context=None):
+        """
+        Do some housekeeping on the payment line
+        then pass on to _reconcile_move
+        """
+        transaction = self.browse(cr, uid, transaction_id, context=context)
+        payment_line_obj = self.pool.get('payment.line')
+        payment_line_obj.write(
+            cr, uid, transaction.payment_line_id.id, {
+                'date_done': transaction.statement_line_id.date,
+                }
+            )
+        self._confirm_move(cr, uid, transaction_id, context=context)
+        # Check if the payment order is 'done'
+        order_id = transaction.payment_line_id.order_id.id
+        other_lines = payment_line_obj.search(
+            cr, uid, [
+                ('order_id', '=', order_id),
+                ('date_done', '=', False),
+                ], context=context)
+        if not other_lines:
+            wf_service = netsvc.LocalService('workflow')
+            wf_service.trg_validate(
+                uid, 'payment.order', order_id, 'done', cr)
+
+    def _cancel_payment(
+        self, cr, uid, transaction_id, context=None):
+        """
+        Do not support cancelling individual lines yet, because the workflow
+        of the payment order does not support reopening.
+        """
+        raise orm.except_orm(
+            _("Cannot unreconcile"),
+            _("Cannot unreconcile: this operation is not yet supported for "
+              "match type 'payment'"))
+
+    def _cancel_payment_order(
+        self, cr, uid, transaction_id, context=None):
+        """
+        """
+        payment_order_obj = self.pool.get('payment.order')
+        transaction = self.browse(cr, uid, transaction_id, context=context)
+        if not transaction.payment_order_id:
+            raise orm.except_orm(
+                _("Cannot unreconcile"),
+                _("Cannot unreconcile: no payment or direct debit order"))
+        if not transaction.statement_line_id.reconcile_id:
+            raise orm.except_orm(
+                _("Cannot unreconcile"),
+                _("Payment orders without transfer move lines cannot be "
+                  "unreconciled this way"))
+        return payment_order_obj.debit_unreconcile_transfer(
+            cr, uid, transaction.payment_order_id.id,
+            transaction.statement_line_id.reconcile_id.id,
+            transaction.statement_line_id.amount,
+            transaction.statement_line_id.currency)
+
+    def _cancel_storno(
+        self, cr, uid, transaction_id, context=None):
+        """
+        TODO: delegate unreconciliation to the direct debit module,
+        to allow for various direct debit styles
+        """
+        payment_line_obj = self.pool.get('payment.line')
+        reconcile_obj = self.pool.get('account.move.reconcile')
+        transaction = self.browse(cr, uid, transaction_id, context=context)
+        
+        if not transaction.payment_line_id:
+            raise orm.except_orm(
+                _("Cannot cancel link with storno"),
+                _("No direct debit order item"))
+        if not transaction.payment_line_id.storno:
+            raise orm.except_orm(
+                _("Cannot cancel link with storno"),
+                _("The direct debit order item is not marked for storno"))
+
+        journal = transaction.statement_line_id.statement_id.journal_id
+        if transaction.statement_line_id.amount >= 0:
+            account_id = journal.default_credit_account_id.id
+        else:
+            account_id = journal.default_debit_account_id.id
+        cancel_line = False
+        move_lines = []
+        for move in transaction.statement_line_id.move_ids:
+            # There should usually be just one move, I think
+            move_lines += move.line_id
+        for line in move_lines:
+            if line.account_id.id != account_id:
+                cancel_line = line
+                break
+        if not cancel_line:
+            raise orm.except_orm(
+                _("Cannot cancel link with storno"),
+                _("Line id not found"))
+        reconcile = cancel_line.reconcile_id or cancel_line.reconcile_partial_id
+        lines_reconcile = reconcile.line_id or reconcile.line_partial_ids
+        if len(lines_reconcile) < 3:
+            # delete the full reconciliation
+            reconcile_obj.unlink(cr, uid, reconcile.id, context)
+        else:
+            # we are left with a partial reconciliation
+            reconcile_obj.write(
+                cr, uid, reconcile.id, 
+                {'line_partial_ids': 
+                 [(6, 0, [x.id for x in lines_reconcile
+                          if x.id != cancel_line.id])],
+                 'line_id': [(6, 0, [])],
+                 }, context)
+        # redo the original payment line reconciliation with the invoice
+        payment_line_obj.write(
+            cr, uid, transaction.payment_line_id.id, 
+            {'storno': False}, context)
+        payment_line_obj.debit_reconcile(
+            cr, uid, transaction.payment_line_id.id, context)
+
+    _columns = {
+        'payment_order_ids': fields.many2many(
+            'payment.order', 'banking_transaction_payment_order_rel',
+            'order_id', 'transaction_id', 'Payment orders'),
+        'payment_order_id': fields.many2one(
+            'payment.order', 'Payment order to reconcile'),
+        'payment_line_id': fields.many2one('payment.line', 'Payment line'),
+        }
+
+    def _get_match_multi(self, cr, uid, ids, name, args, context=None):
+        if not ids:
+            return {}
+        res = super(banking_import_transaction, self)._get_match_multi(
+            cr, uid, ids, name, args, context=context)
+        for transaction in self.browse(cr, uid, ids, context):
+            if transaction.match_type == 'payment_order':
+                if (transaction.payment_order_ids and not
+                    transaction.payment_order_id):
+                    res[transaction.id] = True
+        return res
+
+    def clear_and_write(self, cr, uid, ids, vals=None, context=None):
+        write_vals = {
+            'payment_line_id': False,
+            'payment_order_id': False,
+            'payment_order_ids': [(6, 0, [])],
+            }
+        write_vals.update(vals or {})
+        return super(banking_import_transaction, self).clear_and_write(
+            cr, uid, ids, vals=vals, context=context)
+
+    def move_info2values(self, move_info):
+        vals = super(banking_import_transaction, self).move_info2values(
+            move_info)
+        vals['payment_line_id'] = move_info.get('payment_line_id', False)
+        vals['payment_order_ids'] = [
+            (6, 0, move_info.get('payment_order_ids') or [])]
+        vals['payment_order_id'] = (
+            move_info.get('payment_order_ids', False) and 
+            len(move_info['payment_order_ids']) == 1 and
+            move_info['payment_order_ids'][0]
+            )
+        return vals
+
+    def hook_match_payment(self, cr, uid, transaction, log, context=None):
+        """
+        Called from match() in the core module.
+        Match payment batches, direct debit orders and stornos
+        """
+        move_info = False
+        if transaction.type == bt.PAYMENT_BATCH:
+            move_info = self._match_payment_order(
+                cr, uid, transaction, log,
+                order_type='payment', context=context)
+        elif transaction.type == bt.DIRECT_DEBIT:
+            move_info = self._match_payment_order(
+                cr, uid, transaction, log,
+                order_type='debit', context=context)
+        elif transaction.type == bt.STORNO:
+            move_info = self._match_storno(
+                cr, uid, transaction, log,
+                context=context)
+        return move_info
+
+    def __init__(self, pool, cr):
+        """
+        Updating the function maps to handle the match types that this
+        module adds.
+        """
+        super(banking_import_transaction, self).__init__(pool, cr)
+
+        self.confirm_map.update({
+                'storno': banking_import_transaction._confirm_storno,
+                'payment_order': banking_import_transaction._confirm_payment_order,
+                'payment': banking_import_transaction._confirm_payment,
+                'payment_order_manual': banking_import_transaction._confirm_payment_order,
+                'payment_manual': banking_import_transaction._confirm_payment,
+                })
+
+        self.cancel_map.update({
+                'storno': banking_import_transaction._cancel_storno,
+                'payment_order': banking_import_transaction._cancel_payment_order,
+                'payment': banking_import_transaction._cancel_payment,
+                'payment_order_manual': banking_import_transaction._cancel_payment_order,
+                'payment_manual': banking_import_transaction._cancel_payment,
+                })

=== added file 'account_banking_payment/model/banking_transaction_wizard.py'
--- account_banking_payment/model/banking_transaction_wizard.py	1970-01-01 00:00:00 +0000
+++ account_banking_payment/model/banking_transaction_wizard.py	2013-07-25 08:56:25 +0000
@@ -0,0 +1,103 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
+#              (C) 2011 - 2013 Therp BV (<http://therp.nl>).
+#            
+#    All other contributions are (C) by their respective contributors
+#
+#    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 (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import orm, fields
+from openerp.tools.translate import _
+
+
+class banking_transaction_wizard(orm.TransientModel):
+    _inherit = 'banking.transaction.wizard'
+
+    def write(self, cr, uid, ids, vals, context=None):
+        """
+        Check for manual payment orders or lines
+        """
+        if not vals or not ids:
+            return True
+        manual_payment_order_id = vals.pop('manual_payment_order_id', False)
+        manual_payment_line_id = vals.pop('manual_payment_line_id', False)
+        res = super(banking_transaction_wizard, self).write(
+            cr, uid, ids, vals, context=context)
+        if manual_payment_order_id or manual_payment_line_id:
+            transaction_id = self.browse(
+                cr, uid, ids[0],
+                context=context).import_transaction_id
+            write_vals = {}
+            if manual_payment_order_id:
+                payment_order = self.pool.get('payment.order').browse(
+                    cr, uid, manual_payment_order_id,
+                    context=context)
+                if payment_order.payment_order_type == 'payment':
+                    sign = 1
+                else:
+                    sign = -1
+                total = (payment_order.total + sign * 
+                         transaction_id.statement_line_id.amount)
+                if not self.pool.get('res.currency').is_zero(
+                    cr, uid, transaction_id.statement_line_id.statement_id.currency, total):
+                    raise orm.except_orm(
+                        _('Error'),
+                        _('When matching a payment order, the amounts have to '
+                          'match exactly'))
+                
+                if payment_order.mode and payment_order.mode.transfer_account_id:
+                    transaction_id.statement_line_id.write({
+                        'account_id': payment_order.mode.transfer_account_id.id,
+                        })
+                write_vals.update(
+                    {'payment_order_id': manual_payment_order_id,
+                     'match_type': 'payment_order_manual'})
+            else:
+                write_vals.update(
+                    {'payment_line_id': manual_payment_line_id,
+                     'match_type': 'payment_manual'})
+            self.pool.get('banking.import.transaction').clear_and_write(
+                cr, uid, transaction_id.id, write_vals, context=context)
+        return res
+
+    _columns = {
+        'payment_line_id': fields.related(
+            'import_transaction_id', 'payment_line_id',
+            string="Matching payment or storno", 
+            type='many2one', relation='payment.line',
+            readonly=True),
+        'payment_order_ids': fields.related(
+            'import_transaction_id', 'payment_order_ids',
+            string="Matching payment orders", 
+            type='many2many', relation='payment.order'),
+        'payment_order_id': fields.related(
+            'import_transaction_id', 'payment_order_id',
+            string="Payment order to reconcile", 
+            type='many2one', relation='payment.order'),
+        'manual_payment_order_id': fields.many2one(
+            'payment.order', 'Match this payment order',
+            domain=[('state', '=', 'sent')]),
+        'manual_payment_line_id': fields.many2one(
+            'payment.line', 'Match this payment line',
+            domain=[
+                ('order_id.state', '=', 'sent'),
+                ('date_done', '=', False),
+                ]),
+        }

=== added file 'account_banking_payment/model/payment_line.py'
--- account_banking_payment/model/payment_line.py	1970-01-01 00:00:00 +0000
+++ account_banking_payment/model/payment_line.py	2013-07-25 08:56:25 +0000
@@ -0,0 +1,180 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
+#              (C) 2011 - 2013 Therp BV (<http://therp.nl>).
+#            
+#    All other contributions are (C) by their respective contributors
+#
+#    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 (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import orm, fields
+from openerp import netsvc
+from openerp.tools.translate import _
+
+class payment_line(orm.Model):
+    '''
+    Add some fields; make destination bank account
+    mandatory, as it makes no sense to send payments into thin air.
+    Edit: Payments can be by cash too, which is prohibited by mandatory bank
+    accounts.
+    '''
+    _inherit = 'payment.line'
+    _columns = {
+        # New fields
+        'msg': fields.char('Message', size=255, required=False, readonly=True),
+        'date_done': fields.date(
+            'Date Confirmed', select=True, readonly=True),
+        # Communication: required is dependend on the mode
+        'communication': fields.char(
+            'Communication', size=64, required=False, 
+            help=("Used as the message between ordering customer and current "
+                  "company. Depicts 'What do you want to say to the recipient"
+                  " about this order ?'"
+                 ),
+        ),
+        # Communication2: enlarge to 128
+        'communication2': fields.char(
+            'Communication 2', size=128,
+            help='The successor message of Communication.',
+        ),
+        'transit_move_line_id': fields.many2one(
+            # this line is part of the credit side of move 2a 
+            # from the documentation
+            'account.move.line', 'Debit move line',
+            readonly=True,
+            help="Move line through which the debit order pays the invoice",
+            ),
+        }
+
+    _defaults = {
+        'msg': '',
+        }
+
+    """
+    Hooks for processing direct debit orders, such as implemented in
+    account_direct_debit module.
+    """
+    def get_storno_account_id(self, cr, uid, payment_line_id, amount,
+                     currency_id, context=None):
+        """
+        Hook for verifying a match of the payment line with the amount.
+        Return the account associated with the storno.
+        Used in account_banking interactive mode
+        :param payment_line_id: the single payment line id
+        :param amount: the (signed) amount debited from the bank account
+        :param currency: the bank account's currency *browse object*
+        :return: an account if there is a full match, False otherwise
+        :rtype: database id of an account.account resource.
+        """
+
+        return False
+
+    def debit_storno(self, cr, uid, payment_line_id, amount,
+                     currency_id, storno_retry=True, context=None):
+        """
+        Hook for handling a canceled item of a direct debit order.
+        Presumably called from a bank statement import routine.
+
+        Decide on the direction that the invoice's workflow needs to take.
+        You may optionally return an incomplete reconcile for the caller
+        to reconcile the now void payment.
+
+        :param payment_line_id: the single payment line id
+        :param amount: the (negative) amount debited from the bank account
+        :param currency: the bank account's currency *browse object*
+        :param boolean storno_retry: whether the storno is considered fatal \
+        or not.
+        :return: an incomplete reconcile for the caller to fill
+        :rtype: database id of an account.move.reconcile resource.
+        """
+
+        return False
+
+    def debit_reconcile(self, cr, uid, payment_line_id, context=None):
+        """
+        Reconcile a debit order's payment line with the the move line
+        that it is based on. Called from payment_order.action_sent().
+        As the amount is derived directly from the counterpart move line,
+        we do not expect a write off. Take partially reconcilions into
+        account though.
+
+        :param payment_line_id: the single id of the canceled payment line
+        """
+
+        if isinstance(payment_line_id, (list, tuple)):
+            payment_line_id = payment_line_id[0]
+        reconcile_obj = self.pool.get('account.move.reconcile')
+        move_line_obj = self.pool.get('account.move.line')
+        payment_line = self.browse(cr, uid, payment_line_id, context=context)
+
+        transit_move_line = payment_line.transit_move_line_id
+        torec_move_line = payment_line.move_line_id
+
+        if (not transit_move_line or not torec_move_line):
+            raise orm.except_orm(
+                _('Can not reconcile'),
+                _('No move line for line %s') % payment_line.name)     
+        if torec_move_line.reconcile_id: # torec_move_line.reconcile_partial_id:
+            raise orm.except_orm(
+                _('Error'),
+                _('Move line %s has already been reconciled') % 
+                torec_move_line.name
+                )
+        if transit_move_line.reconcile_id or transit_move_line.reconcile_partial_id:
+            raise orm.except_orm(
+                _('Error'),
+                _('Move line %s has already been reconciled') % 
+                transit_move_line.name
+                )
+
+        def is_zero(total):
+            return self.pool.get('res.currency').is_zero(
+                cr, uid, transit_move_line.company_id.currency_id, total)
+
+        line_ids = [transit_move_line.id, torec_move_line.id]
+        if torec_move_line.reconcile_partial_id:
+            line_ids = [
+                x.id for x in 
+                transit_move_line.reconcile_partial_id.line_partial_ids
+                ] + [torec_move_line.id]
+
+        total = move_line_obj.get_balance(cr, uid, line_ids)
+        vals = {
+            'type': 'auto',
+            'line_id': is_zero(total) and [(6, 0, line_ids)] or [(6, 0, [])],
+            'line_partial_ids': is_zero(total) and [(6, 0, [])] or [(6, 0, line_ids)],
+            }
+
+        if torec_move_line.reconcile_partial_id:
+            reconcile_obj.write(
+                cr, uid, transit_move_line.reconcile_partial_id.id,
+                vals, context=context)
+        else:
+            reconcile_obj.create(
+                cr, uid, vals, context=context)
+        for line_id in line_ids:
+            netsvc.LocalService("workflow").trg_trigger(
+                uid, 'account.move.line', line_id, cr)
+
+        # If a bank transaction of a storno was first confirmed
+        # and now canceled (the invoice is now in state 'debit_denied'
+        if torec_move_line.invoice:
+            netsvc.LocalService("workflow").trg_validate(
+                uid, 'account.invoice', torec_move_line.invoice.id,
+                'undo_debit_denied', cr)

=== added file 'account_banking_payment/model/payment_mode.py'
--- account_banking_payment/model/payment_mode.py	1970-01-01 00:00:00 +0000
+++ account_banking_payment/model/payment_mode.py	2013-07-25 08:56:25 +0000
@@ -0,0 +1,72 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
+#              (C) 2011 - 2013 Therp BV (<http://therp.nl>).
+#            
+#    All other contributions are (C) by their respective contributors
+#
+#    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 (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import orm, fields
+
+
+class payment_mode(orm.Model):
+    ''' Restoring the payment type from version 5,
+    used to select the export wizard (if any) '''
+    _inherit = "payment.mode"
+
+    def suitable_bank_types(self, cr, uid, payment_mode_id=None, context=None):
+        """ Reinstates functional code for suitable bank type filtering.
+        Current code in account_payment is disfunctional.
+        """
+        res = []
+        payment_mode = self.browse(
+            cr, uid, payment_mode_id, context)
+        if (payment_mode and payment_mode.type and
+            payment_mode.type.suitable_bank_types):
+            res = [type.code for type in payment_mode.type.suitable_bank_types]
+        return res
+
+    _columns = {
+        'type': fields.many2one(
+            'payment.mode.type', 'Payment type',
+            required=True,
+            help='Select the Payment Type for the Payment Mode.'
+            ),
+        'transfer_account_id': fields.many2one(
+            'account.account', 'Transfer account',
+            domain=[('type', '=', 'other'),
+                    ('reconcile', '=', True)],
+            help=('Pay off lines in sent orders with a '
+                  'move on this account. For debit type modes only. '
+                  'You can only select accounts of type regular that '
+                  'are marked for reconciliation'),
+            ),
+        'transfer_journal_id': fields.many2one(
+            'account.journal', 'Transfer journal',
+            help=('Journal to write payment entries when confirming '
+                  'a debit order of this mode'),
+            ),
+        'payment_term_ids': fields.many2many(
+            'account.payment.term', 'account_payment_order_terms_rel', 
+            'mode_id', 'term_id', 'Payment terms',
+            help=('Limit selected invoices to invoices with these payment '
+                  'terms')
+            ),
+        }

=== added file 'account_banking_payment/model/payment_mode_type.py'
--- account_banking_payment/model/payment_mode_type.py	1970-01-01 00:00:00 +0000
+++ account_banking_payment/model/payment_mode_type.py	2013-07-25 08:56:25 +0000
@@ -0,0 +1,62 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
+#              (C) 2011 - 2013 Therp BV (<http://therp.nl>).
+#            
+#    All other contributions are (C) by their respective contributors
+#
+#    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 (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import orm, fields
+
+
+class payment_mode_type(orm.Model):
+    _name = 'payment.mode.type'
+    _description = 'Payment Mode Type'
+    _columns = {
+        'name': fields.char(
+            'Name', size=64, required=True,
+            help='Payment Type'
+            ),
+        'code': fields.char(
+            'Code', size=64, required=True,
+            help='Specify the Code for Payment Type'
+            ),
+        # Setting suitable_bank_types to required pending
+        # https://bugs.launchpad.net/openobject-addons/+bug/786845
+        'suitable_bank_types': fields.many2many(
+            'res.partner.bank.type',
+            'bank_type_payment_type_rel',
+            'pay_type_id','bank_type_id',
+            'Suitable bank types', required=True),
+        'ir_model_id': fields.many2one(
+            'ir.model', 'Payment wizard',
+            help=('Select the Payment Wizard for payments of this type. '
+                  'Leave empty for manual processing'),
+            domain=[('osv_memory', '=', True)],
+            ),
+        'payment_order_type': fields.selection(
+            [('payment', 'Payment'),('debit', 'Direct debit')],
+            'Payment order type', required=True,
+            ),
+    }
+
+    _defaults = {
+        'payment_order_type': 'payment',
+        }

=== renamed file 'account_banking/wizard/account_payment_order.py' => 'account_banking_payment/model/payment_order_create.py'
--- account_banking/wizard/account_payment_order.py	2013-06-04 21:10:24 +0000
+++ account_banking_payment/model/payment_order_create.py	2013-07-25 08:56:25 +0000
@@ -2,37 +2,101 @@
 ##############################################################################
 #
 #    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
+#              (C) 2011 - 2013 Therp BV (<http://therp.nl>).
+#            
+#    All other contributions are (C) by their respective contributors
+#
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
 
-import datetime
-from osv import osv
-from account_banking.struct import struct
-from account_banking.parsers import convert
-
-today = datetime.date.today
-
-def str2date(str):
-    dt = convert.str2date(str, '%Y-%m-%d')
-    return datetime.date(dt.year, dt.month, dt.day)
-
-class payment_order_create(osv.osv_memory):
+from datetime import datetime
+from openerp.osv import orm, fields
+from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
+from openerp.tools.translate import _
+
+
+class payment_order_create(orm.TransientModel):
     _inherit = 'payment.order.create'
 
+    def extend_payment_order_domain(
+            self, cr, uid, payment_order, domain, context=None):
+        if payment_order.payment_order_type == 'payment':
+            domain += [
+                ('account_id.type', '=', 'payable'),
+                ('amount_to_pay', '>', 0)
+                ]
+        return True
+
+    def search_entries(self, cr, uid, ids, context=None):
+        """
+        This method taken from account_payment module.
+        We adapt the domain based on the payment_order_type
+        """
+        line_obj = self.pool.get('account.move.line')
+        mod_obj = self.pool.get('ir.model.data')
+        if context is None:
+            context = {}
+        data = self.read(cr, uid, ids, ['duedate'], context=context)[0]
+        search_due_date = data['duedate']
+        
+        ### start account_banking_payment ###
+        payment = self.pool.get('payment.order').browse(
+            cr, uid, context['active_id'], context=context)
+        # Search for move line to pay:
+        domain = [
+            ('move_id.state', '=', 'posted'),
+            ('reconcile_id', '=', False),
+            ('company_id', '=', payment.mode.company_id.id),
+            ]
+        # apply payment term filter
+        if payment.mode.payment_term_ids:
+            domain += [
+                ('invoice.payment_term', 'in', 
+                 [term.id for term in payment.mode.payment_term_ids]
+                 )
+                ]
+        self.extend_payment_order_domain(
+            cr, uid, payment, domain, context=context)
+        ### end account_direct_debit ###
+
+        domain = domain + [
+            '|', ('date_maturity', '<=', search_due_date),
+            ('date_maturity', '=', False)
+            ]
+        line_ids = line_obj.search(cr, uid, domain, context=context)
+        context.update({'line_ids': line_ids})
+        model_data_ids = mod_obj.search(
+            cr, uid,[
+                ('model', '=', 'ir.ui.view'),
+                ('name', '=', 'view_create_payment_order_lines')],
+            context=context)
+        resource_id = mod_obj.read(
+            cr, uid, model_data_ids, fields=['res_id'],
+            context=context)[0]['res_id']
+        return {'name': _('Entry Lines'),
+                'context': context,
+                'view_type': 'form',
+                'view_mode': 'form',
+                'res_model': 'payment.order.create',
+                'views': [(resource_id, 'form')],
+                'type': 'ir.actions.act_window',
+                'target': 'new',
+        }
+
     def create_payment(self, cr, uid, ids, context=None):
         '''
         This method is a slightly modified version of the existing method on this
@@ -53,12 +117,14 @@
         if not line_ids:
             return {'type': 'ir.actions.act_window_close'}
 
-        payment = order_obj.browse(cr, uid, context['active_id'], context=context)
+        payment = order_obj.browse(
+            cr, uid, context['active_id'], context=context)
         ### account banking
         # t = None
         # line2bank = line_obj.line2bank(cr, uid, line_ids, t, context)
-        line2bank = line_obj.line2bank(cr, uid, line_ids, payment.mode.id, context)
-        _today = today()
+        line2bank = line_obj.line2bank(
+            cr, uid, line_ids, payment.mode.id, context)
+        _today = fields.date.context_today(self, cr, uid, context=context)
         ### end account banking
 
         ## Finally populate the current payment with new lines:
@@ -69,16 +135,18 @@
             elif payment.date_prefered == 'due':
                 ### account_banking
                 # date_to_pay = line.date_maturity
-                date_to_pay = line.date_maturity and \
-                           str2date(line.date_maturity) > _today\
-                           and line.date_maturity or False
+                date_to_pay = (
+                    line.date_maturity
+                    if line.date_maturity and line.date_maturity > _today
+                    else False)
                 ### end account banking
             elif payment.date_prefered == 'fixed':
                 ### account_banking
-                # date_to_pay = payment.date_planned
-                date_to_pay = payment.date_planned and \
-                           str2date(payment.date_planned) > _today\
-                           and payment.date_planned or False
+                # date_to_pay = payment.date_scheduled
+                date_to_pay = (
+                    payment.date_scheduled
+                    if payment.date_scheduled and payment.date_scheduled > _today
+                    else False)
                 ### end account banking
 
             ### account_banking
@@ -111,7 +179,7 @@
                 amount_currency = line.amount_to_pay
             ### end account_banking
 
-            payment_obj.create(cr, uid,{
+            payment_obj.create(cr, uid, {
                 'move_line_id': line.id,
                 'amount_currency': amount_currency,
                 'bank_id': line2bank.get(line.id),
@@ -124,8 +192,8 @@
                 'state': state,
                 ### end account banking
                 'date': date_to_pay,
-                'currency': line.invoice and line.invoice.currency_id.id or line.journal_id.currency.id or line.journal_id.company_id.currency_id.id,
+                'currency': (line.invoice and line.invoice.currency_id.id
+                             or line.journal_id.currency.id
+                             or line.journal_id.company_id.currency_id.id),
                 }, context=context)
         return {'type': 'ir.actions.act_window_close'}
-
-payment_order_create()

=== added directory 'account_banking_payment/security'
=== added file 'account_banking_payment/security/ir.model.access.csv'
--- account_banking_payment/security/ir.model.access.csv	1970-01-01 00:00:00 +0000
+++ account_banking_payment/security/ir.model.access.csv	2013-07-25 08:56:25 +0000
@@ -0,0 +1,2 @@
+"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
+"access_payment_mode_type","payment.mode.type","model_payment_mode_type","account_payment.group_account_payment",1,1,1,1

=== added directory 'account_banking_payment/view'
=== added file 'account_banking_payment/view/account_payment.xml'
--- account_banking_payment/view/account_payment.xml	1970-01-01 00:00:00 +0000
+++ account_banking_payment/view/account_payment.xml	2013-07-25 08:56:25 +0000
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <!-- Make buttons on payment order sensitive for extra states,
+             restore wizard functionality when making payments
+          -->
+
+        <record id="view_banking_payment_order_form_1" model="ir.ui.view">
+            <field name="name">account.payment.order.form.banking-1</field>
+            <field name="inherit_id" ref="account_payment.view_payment_order_form" />
+            <field name="model">payment.order</field>
+            <field name="arch" type="xml">
+                <data>
+                    <xpath expr="//button[@string='Select Invoices to Pay']"
+                           position="attributes">
+                        <attribute name="attrs">{
+                            'invisible':[('state','!=','draft')]
+                        }</attribute>
+                    </xpath>
+                    <xpath expr="//button[@string='Make Payments']"
+                           position="attributes">
+                        <attribute name="name">launch_wizard</attribute>
+                    </xpath>
+                    <!-- Communication only used for 'structured' communication -->
+                    <xpath expr="//field[@name='line_ids']/form//field[@name='communication']"
+                           position="attributes">
+                        <attribute name="attrs">{
+                        'readonly': [('state', '=', 'normal')]
+                        }</attribute>
+                    </xpath>
+                </data>
+            </field>
+        </record>
+
+    </data>
+</openerp>

=== added file 'account_banking_payment/view/bank_payment_manual.xml'
--- account_banking_payment/view/bank_payment_manual.xml	1970-01-01 00:00:00 +0000
+++ account_banking_payment/view/bank_payment_manual.xml	2013-07-25 08:56:25 +0000
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record id="view_payment_manual_form" model="ir.ui.view">
+            <field name="name">Form for manual payment wizard</field>
+            <field name="model">payment.manual</field>
+            <field name="arch" type="xml">
+                <form string="Manual payment">
+                    <label string="Payment order(s) have been set to 'sent'"/>
+                    <button special="cancel" icon="gtk-ok" string="OK"/>
+                </form>
+            </field>
+        </record>
+    </data>
+</openerp>

=== added file 'account_banking_payment/view/banking_transaction_wizard.xml'
--- account_banking_payment/view/banking_transaction_wizard.xml	1970-01-01 00:00:00 +0000
+++ account_banking_payment/view/banking_transaction_wizard.xml	2013-07-25 08:56:25 +0000
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record model="ir.ui.view" id="transaction_wizard">
+            <field name="name">transaction.wizard</field>
+            <field name="model">banking.transaction.wizard</field>
+            <field name="inherit_id"
+                   ref="account_banking.transaction_wizard_first" />
+            <field name="arch" type="xml">
+                <field name="invoice_ids" position="before">
+                    <field name="payment_order_ids" invisible="True"/>
+                </field>
+                <xpath expr="//group/separator[@string='Multiple matches']/.."
+                       position="after">
+                    <field name='payment_line_id'
+                           attrs="{'invisible': [('match_type', 'not in', 
+                                       ('storno', 'payment', 'payment_manual'))]}"
+                           />
+                </xpath>
+                <field name="move_line_id" position="after">
+                    <field name='payment_order_id'
+                           attrs="{'readonly': [('match_multi', '=', False)],
+                                   'invisible': [('match_type', 'not in', 
+                                       ('payment_order', 'payment_order_manual'))]
+                                  }"
+                           domain="[('id', 'in', payment_order_ids[0][2])]"
+                           />
+                </field>
+                <field name="manual_move_line_ids" position="after">
+                    <field name="manual_payment_line_id"/>
+                    <field name="manual_payment_order_id"/>
+                </field>
+            </field>
+        </record>
+    </data>
+</openerp>
+
+

=== added file 'account_banking_payment/view/payment_mode.xml'
--- account_banking_payment/view/payment_mode.xml	1970-01-01 00:00:00 +0000
+++ account_banking_payment/view/payment_mode.xml	2013-07-25 08:56:25 +0000
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <!-- 
+             Add the payment mode type and transfer settings
+        -->
+        <record id="view_payment_mode_form_inherit" model="ir.ui.view">
+            <field name="name">payment.mode.form.inherit</field>
+            <field name="model">payment.mode</field>
+            <field name="inherit_id" ref="account_payment.view_payment_mode_form"/>
+            <field name="arch" type="xml">
+                <field name="company_id" position="after">
+                    <field name="type"/>
+                    <group colspan="4" col="4">
+                        <group colspan="2">
+                            <separator colspan="2"
+                                       string="Transfer move settings" />
+                            <field name="transfer_account_id"
+                                   domain="[('type', '=', 'other'),
+                                           ('reconcile', '=', True),
+                                           ('company_id', '=', company_id)]"
+                                   context="{
+                                       'default_type': 'other',
+                                       'default_reconcile': True,
+                                       'default_company_id': company_id}"
+                                   />
+                            <field name="transfer_journal_id"
+                                   domain="[('company_id', '=', company_id)]"
+                                   />
+                        </group>
+                        <group colspan="2">
+                            <separator colspan="2"
+                                       string="Optional filter by payment term" />
+                            <field name="payment_term_ids" nolabel="1" colspan="2"/>
+                        </group>
+                    </group>
+                </field>
+            </field>
+        </record>
+
+    </data>
+</openerp>

=== added file 'account_banking_payment/view/payment_mode_type.xml'
--- account_banking_payment/view/payment_mode_type.xml	1970-01-01 00:00:00 +0000
+++ account_banking_payment/view/payment_mode_type.xml	2013-07-25 08:56:25 +0000
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <record id="view_payment_mode_tree_inherit" model="ir.ui.view">
+            <field name="name">payment.mode.tree.inherit</field>
+            <field name="model">payment.mode</field>
+            <field name="inherit_id" ref="account_payment.view_payment_mode_tree"/>
+            <field name="arch" type="xml">
+                <field name="company_id" position="after">
+                    <field name="type"/>
+                </field>
+            </field>
+        </record>
+
+	<!-- basic view for payment mode type -->
+        <record model="ir.ui.view" id="view_payment_mode_type_form">
+            <field name="name">view.payment.mode.type.form</field>
+            <field name="model">payment.mode.type</field>
+            <field name="arch" type="xml">
+                <form string="Payment mode">
+		    <field name="name" />
+		    <field name="code" />
+		    <field name="suitable_bank_types"/>
+		    <field name="payment_order_type"/>
+		    <field name="ir_model_id"/>
+                </form>
+            </field>
+        </record>
+
+    </data>
+</openerp>

=== added directory 'account_banking_payment/workflow'
=== renamed file 'account_banking/account_banking_workflow.xml' => 'account_banking_payment/workflow/account_payment.xml'
--- account_banking/account_banking_workflow.xml	2011-12-12 15:00:03 +0000
+++ account_banking_payment/workflow/account_payment.xml	2013-07-25 08:56:25 +0000
@@ -1,43 +1,69 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!--
-  Copyright (C) EduSense BV <http://www.edusense.nl>
-  All rights reserved.
-  The licence is in the file __terp__.py
--->
 <openerp>
     <data>
         <!-- New activity for workflow payment order: sent -->
-        <record id="act_sent" model="workflow.activity">
+        <record id="account_banking.act_sent" model="workflow.activity">
             <field name="name">sent</field>
             <field name="wkf_id" ref="account_payment.wkf_payment_order"/>
             <field name="action">action_sent()</field>
             <field name="kind">function</field>
         </record>
+        <!-- New activity for workflow payment order: sent -->
+        <record id="account_banking.act_sent_wait" model="workflow.activity">
+            <field name="name">sent_wait</field>
+            <field name="wkf_id" ref="account_payment.wkf_payment_order"/>
+            <field name="action">write({'state': 'sent'})</field>
+            <field name="kind">function</field>
+        </record>
         <!-- New activity for workflow payment order: rejected -->
-        <record id="act_rejected" model="workflow.activity">
+        <record id="account_banking.act_rejected" model="workflow.activity">
             <field name="name">rejected</field>
             <field name="wkf_id" ref="account_payment.wkf_payment_order"/>
             <field name="action">action_rejected()
 write({'state':'rejected'})</field>
             <field name="kind">function</field>
         </record>
-        <!-- Add new transition sent -> done -->
-        <record id="trans_sent_done" model="workflow.transition">
-            <field name="act_from" ref="act_sent"/>
+        <!-- Rewrite existing open -> done transition to include 'sent' stage -->
+        <record id="account_payment.trans_open_done" model="workflow.transition">
+            <field name="act_from" ref="account_payment.act_open"/>
+            <field name="act_to" ref="account_banking.act_sent"/>
+            <field name="signal">sent</field>
+        </record>
+        <!-- From sent straight to sent_wait -->
+        <record id="account_banking.trans_sent_sent_wait" model="workflow.transition">
+            <field name="act_from" ref="account_banking.act_sent"/>
+            <field name="act_to" ref="account_banking.act_sent_wait"/>
+        </record>
+        <!-- Reconciliation from the banking statement leads to done state -->
+        <record id="account_banking.trans_sent_done" model="workflow.transition">
+            <field name="act_from" ref="account_banking.act_sent_wait"/>
             <field name="act_to" ref="account_payment.act_done"/>
             <field name="signal">done</field>
         </record>
-        <!-- Add new transition sent -> rejected -->
-        <record id="trans_sent_rejected" model="workflow.transition">
-            <field name="act_from" ref="act_sent"/>
-            <field name="act_to" ref="act_rejected"/>
+        <!-- Rejected by the bank -->
+        <record id="account_banking.trans_sent_rejected" model="workflow.transition">
+            <field name="act_from" ref="account_banking.act_sent"/>
+            <field name="act_to" ref="account_banking.act_rejected"/>
             <field name="signal">rejected</field>
         </record>
-        <!-- Rewrite existing open -> done transition to include 'sent' -->
-        <record id="account_payment.trans_open_done" model="workflow.transition">
-            <field name="act_from" ref="account_payment.act_open"/>
-            <field name="act_to" ref="act_sent"/>
-            <field name="signal">sent</field>
-        </record>
+        <!--
+            Transition to undo the payment order and reset to
+            sent, triggered by cancelling a bank transaction
+            with which the order was reconciled.
+            For this, we need to cancel the flow stop on the done state,
+            unfortunately.
+        -->
+        <record id="account_payment.act_done" model="workflow.activity">
+            <field name="flow_stop" eval="False"/>
+        </record>
+
+        <!-- Cancel the reconciled payment order -->
+        <record id="trans_done_sent" model="workflow.transition">
+            <field name="act_from" ref="account_payment.act_done"/>
+            <field name="act_to" ref="account_banking.act_sent_wait"/>
+            <field name="condition">test_undo_done()</field>
+            <field name="signal">undo_done</field>
+        </record>
+
     </data>
 </openerp>

=== modified file 'account_banking_sepa_credit_transfer/__openerp__.py'
--- account_banking_sepa_credit_transfer/__openerp__.py	2013-06-05 11:50:32 +0000
+++ account_banking_sepa_credit_transfer/__openerp__.py	2013-07-25 08:56:25 +0000
@@ -1,3 +1,4 @@
+<<<<<<< TREE
 ##############################################################################
 #
 #    SEPA Credit Transfer module for OpenERP
@@ -48,3 +49,53 @@
     'active': False,
     'installable': True,
 }
+=======
+##############################################################################
+#
+#    SEPA Credit Transfer module for OpenERP
+#    Copyright (C) 2010-2013 Akretion (http://www.akretion.com)
+#    @author: Alexis de Lattre <alexis.delattre@xxxxxxxxxxxx>
+#
+#    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 (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+{
+    'name': 'Account Banking SEPA Credit Transfer',
+    'version': '0.1',
+    'license': 'AGPL-3',
+    'author': 'Akretion',
+    'website': 'http://www.akretion.com',
+    'category': 'Banking addons',
+    'depends': ['account_banking_payment'],
+    'data': [
+        'account_banking_sepa_view.xml',
+        'wizard/export_sepa_view.xml',
+        'data/payment_type_sepa_sct.xml',
+        'security/ir.model.access.csv',
+    ],
+    'description': '''
+Module to export payment orders in SEPA XML file format.
+
+SEPA PAIN (PAyment INitiation) is the new european standard for Customer-to-Bank payment instructions. This module implements SEPA Credit Transfer (SCT), more specifically PAIN versions 001.001.02, 001.001.03 and 001.001.04. It is part of the ISO 20022 standard, available on http://www.iso20022.org.
+
+The Implementation Guidelines for SEPA Credit Transfer published by the European Payments Council (http://http://www.europeanpaymentscouncil.eu) use PAIN version 001.001.03, so it's probably the version of PAIN that you should try first.
+
+This module uses the framework provided by the banking addons, cf https://launchpad.net/banking-addons
+
+Please contact Alexis de Lattre from Akretion <alexis.delattre@xxxxxxxxxxxx> for any help or question about this module.
+    ''',
+    'active': False,
+    'installable': True,
+}
+>>>>>>> MERGE-SOURCE

=== modified file 'account_banking_sepa_credit_transfer/account_banking_sepa.py'
--- account_banking_sepa_credit_transfer/account_banking_sepa.py	2013-05-22 21:07:52 +0000
+++ account_banking_sepa_credit_transfer/account_banking_sepa.py	2013-07-25 08:56:25 +0000
@@ -1,3 +1,4 @@
+<<<<<<< TREE
 ##############################################################################
 #
 #    SEPA Credit Transfer module for OpenERP
@@ -78,3 +79,82 @@
 
 banking_export_sepa()
 
+=======
+##############################################################################
+#
+#    SEPA Credit Transfer module for OpenERP
+#    Copyright (C) 2010-2013 Akretion (http://www.akretion.com)
+#    @author: Alexis de Lattre <alexis.delattre@xxxxxxxxxxxx>
+#
+#    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 (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import orm, fields
+import time
+from tools.translate import _
+import decimal_precision as dp
+
+
+class banking_export_sepa(orm.Model):
+    '''SEPA export'''
+    _name = 'banking.export.sepa'
+    _description = __doc__
+    _rec_name = 'msg_identification'
+
+    def _generate_filename(self, cr, uid, ids, name, arg, context=None):
+        res = {}
+        for sepa_file in self.browse(cr, uid, ids, context=context):
+            res[sepa_file.id] = 'sepa_' + (sepa_file.msg_identification or '') + '.xml'
+        return res
+
+    _columns = {
+        'payment_order_ids': fields.many2many(
+            'payment.order',
+            'account_payment_order_sepa_rel',
+            'banking_export_sepa_id', 'account_order_id',
+            'Payment orders',
+            readonly=True),
+        'prefered_exec_date': fields.date('Prefered execution date', readonly=True),
+        'nb_transactions': fields.integer('Number of transactions', readonly=True),
+        'total_amount': fields.float('Total amount',
+            digits_compute=dp.get_precision('Account'), readonly=True),
+        'msg_identification': fields.char('Message identification', size=35,
+            readonly=True),
+        'batch_booking': fields.boolean('Batch booking', readonly=True,
+            help="If true, the bank statement will display only one debit line for all the wire transfers of the SEPA XML file ; if false, the bank statement will display one debit line per wire transfer of the SEPA XML file."),
+        'charge_bearer': fields.selection([
+            ('SHAR', 'Shared'),
+            ('CRED', 'Borne by creditor'),
+            ('DEBT', 'Borne by debtor'),
+            ('SLEV', 'Following service level'),
+            ], 'Charge bearer', readonly=True,
+            help='Shared : transaction charges on the sender side are to be borne by the debtor, transaction charges on the receiver side are to be borne by the creditor (most transfers use this). Borne by creditor : all transaction charges are to be borne by the creditor. Borne by debtor : all transaction charges are to be borne by the debtor. Following service level : transaction charges are to be applied following the rules agreed in the service level and/or scheme.'),
+        'generation_date': fields.datetime('Generation date',
+            readonly=True),
+        'file': fields.binary('SEPA XML file', readonly=True),
+        'filename': fields.function(_generate_filename, type='char', size=256,
+            method=True, string='Filename', readonly=True),
+        'state': fields.selection([
+                ('draft', 'Draft'),
+                ('sent', 'Sent'),
+                ('done', 'Reconciled'),
+            ], 'State', readonly=True),
+    }
+
+    _defaults = {
+        'generation_date': fields.date.context_today,
+        'state': 'draft',
+    }
+>>>>>>> MERGE-SOURCE

=== modified file 'account_banking_sepa_credit_transfer/account_banking_sepa_view.xml'
--- account_banking_sepa_credit_transfer/account_banking_sepa_view.xml	2013-05-22 21:07:52 +0000
+++ account_banking_sepa_credit_transfer/account_banking_sepa_view.xml	2013-07-25 08:56:25 +0000
@@ -1,3 +1,4 @@
+<<<<<<< TREE
 <?xml version="1.0" encoding="utf-8"?>
 <!--
   Copyright (C) 2010-2013 Akretion (http://www.akretion.com)
@@ -83,3 +84,88 @@
 
 </data>
 </openerp>
+=======
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2010-2013 Akretion (http://www.akretion.com)
+  @author: Alexis de Lattre <alexis.delattre@xxxxxxxxxxxx>
+  The licence is in the file __openerp__.py
+-->
+<openerp>
+<data>
+
+<record id="view_banking_export_sepa_form" model="ir.ui.view">
+    <field name="name">account.banking.export.sepa.form</field>
+    <field name="model">banking.export.sepa</field>
+    <field name="arch" type="xml">
+        <form string="SEPA Credit Transfer">
+            <notebook>
+                <page string="General information">
+                    <field name="msg_identification" select="1" />
+                    <field name="total_amount" />
+                    <field name="nb_transactions" />
+                    <field name="prefered_exec_date" />
+                    <field name="batch_booking" />
+                    <field name="charge_bearer"/>
+                    <field name="generation_date" />
+                    <newline />
+                    <field name="file" filename="filename"/>
+                    <field name="filename" invisible="True"/>
+                </page>
+                <page string="Payment orders">
+                    <field name="payment_order_ids" colspan="4" nolabel="1">
+                        <tree colors="blue:state in ('draft');gray:state in ('cancel','done');black:state in ('open')" string="Payment order">
+                            <field name="reference"/>
+                            <field name="date_created"/>
+                            <field name="date_done"/>
+                            <field name="total"/>
+                            <field name="state"/>
+                        </tree>
+                    </field>
+                </page>
+            </notebook>
+        </form>
+    </field>
+</record>
+
+
+<record id="view_banking_export_sepa_tree" model="ir.ui.view">
+    <field name="name">account.banking.export.sepa.tree</field>
+    <field name="model">banking.export.sepa</field>
+    <field name="arch" type="xml">
+        <tree string="SEPA Credit Transfer">
+            <field name="msg_identification"/>
+            <field name="prefered_exec_date"/>
+            <field name="generation_date"/>
+            <field name="nb_transactions"/>
+        </tree>
+    </field>
+</record>
+
+
+<record id="action_account_banking_sepa" model="ir.actions.act_window">
+    <field name="name">Generated SEPA XML files</field>
+    <field name="res_model">banking.export.sepa</field>
+    <field name="view_type">form</field>
+    <field name="view_mode">tree,form</field>
+</record>
+
+
+<menuitem id="menu_account_banking_sepa"
+          parent="account_banking.menu_finance_banking_actions"
+          action="action_account_banking_sepa"
+          sequence="15"
+          />
+
+<act_window id="act_banking_export_sepa_payment_order"
+    name="Generated SEPA files"
+    domain="[('payment_order_ids', '=', active_id)]"
+    res_model="banking.export.sepa"
+    src_model="payment.order"
+    view_type="form"
+    view_mode="tree,form"
+/>
+
+</data>
+</openerp>
+>>>>>>> MERGE-SOURCE

=== modified file 'account_banking_sepa_credit_transfer/wizard/export_sepa.py'
--- account_banking_sepa_credit_transfer/wizard/export_sepa.py	2013-06-06 08:04:29 +0000
+++ account_banking_sepa_credit_transfer/wizard/export_sepa.py	2013-07-25 08:56:25 +0000
@@ -1,3 +1,4 @@
+<<<<<<< TREE
 # -*- encoding: utf-8 -*-
 ##############################################################################
 #
@@ -339,3 +340,341 @@
 
 banking_export_sepa_wizard()
 
+=======
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    SEPA Credit Transfer module for OpenERP
+#    Copyright (C) 2010-2013 Akretion (http://www.akretion.com)
+#    @author: Alexis de Lattre <alexis.delattre@xxxxxxxxxxxx>
+#
+#    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 (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+
+from openerp.osv import orm, fields
+import base64
+from datetime import datetime, timedelta
+from openerp.tools.translate import _
+from openerp import tools, netsvc
+from lxml import etree
+import logging
+
+_logger = logging.getLogger(__name__)
+
+
+class banking_export_sepa_wizard(orm.TransientModel):
+    _name = 'banking.export.sepa.wizard'
+    _description = 'Export SEPA Credit Transfer XML file'
+    _columns = {
+        'state': fields.selection([('create', 'Create'), ('finish', 'Finish')],
+            'State', readonly=True),
+        'msg_identification': fields.char('Message identification', size=35,
+            # Can't set required=True on the field because it blocks
+            # the launch of the wizard -> I set it as required in the view
+            help='This is the message identification of the entire SEPA XML file. 35 characters max.'),
+        'batch_booking': fields.boolean('Batch booking',
+            help="If true, the bank statement will display only one debit line for all the wire transfers of the SEPA XML file ; if false, the bank statement will display one debit line per wire transfer of the SEPA XML file."),
+        'prefered_exec_date': fields.date('Prefered execution date',
+            help='This is the date on which the file should be processed by the bank. 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.'),
+        'charge_bearer': fields.selection([
+            ('SHAR', 'Shared'),
+            ('CRED', 'Borne by creditor'),
+            ('DEBT', 'Borne by debtor'),
+            ('SLEV', 'Following service level'),
+            ], 'Charge bearer', required=True,
+            help='Shared : transaction charges on the sender side are to be borne by the debtor, transaction charges on the receiver side are to be borne by the creditor (most transfers use this). Borne by creditor : all transaction charges are to be borne by the creditor. Borne by debtor : all transaction charges are to be borne by the debtor. Following service level : transaction charges are to be applied following the rules agreed in the service level and/or scheme.'),
+        'nb_transactions': fields.related('file_id', 'nb_transactions',
+            type='integer', string='Number of transactions', readonly=True),
+        'total_amount': fields.related('file_id', 'total_amount', type='float',
+            string='Total amount', readonly=True),
+        'file_id': fields.many2one('banking.export.sepa', 'SEPA XML file', readonly=True),
+        'file': fields.related('file_id', 'file', string="File", type='binary',
+            readonly=True),
+        'filename': fields.related('file_id', 'filename', string="Filename",
+            type='char', size=256, readonly=True),
+        'payment_order_ids': fields.many2many('payment.order',
+            'wiz_sepa_payorders_rel', 'wizard_id', 'payment_order_id',
+            'Payment orders', readonly=True),
+        }
+
+    _defaults = {
+        'charge_bearer': 'SLEV',
+        'state': 'create',
+        }
+
+
+    def _limit_size(self, cr, uid, field, max_size, context=None):
+        '''Limit size of strings to respect the PAIN standard'''
+        max_size = int(max_size)
+        return field[0:max_size]
+
+
+    def _validate_iban(self, cr, uid, iban, context=None):
+        '''if IBAN is valid, returns IBAN
+        if IBAN is NOT valid, raises an error message'''
+        partner_bank_obj = self.pool.get('res.partner.bank')
+        if partner_bank_obj.is_iban_valid(cr, uid, iban, context=context):
+            return iban.replace(' ', '')
+        else:
+            raise orm.except_orm(_('Error :'), _("This IBAN is not valid : %s") % iban)
+
+    def create(self, cr, uid, vals, context=None):
+        payment_order_ids = context.get('active_ids', [])
+        vals.update({
+            'payment_order_ids': [[6, 0, payment_order_ids]],
+        })
+        return super(banking_export_sepa_wizard, self).create(cr, uid,
+            vals, context=context)
+
+
+    def create_sepa(self, cr, uid, ids, context=None):
+        '''
+        Creates the SEPA Credit Transfer file. That's the important code !
+        '''
+        payment_order_obj = self.pool.get('payment.order')
+
+        sepa_export = self.browse(cr, uid, ids[0], context=context)
+
+        my_company_name = sepa_export.payment_order_ids[0].mode.bank_id.partner_id.name
+        my_company_iban = self._validate_iban(cr, uid, sepa_export.payment_order_ids[0].mode.bank_id.iban, context=context)
+        my_company_bic = sepa_export.payment_order_ids[0].mode.bank_id.bank.bic
+        #my_company_country_code = sepa_export.payment_order_ids[0].mode.bank_id.partner_id.address[0].country_id.code
+        #my_company_city = sepa_export.payment_order_ids[0].mode.bank_id.partner_id.address[0].city
+        #my_company_street1 = sepa_export.payment_order_ids[0].mode.bank_id.partner_id.address[0].street
+        pain_flavor = sepa_export.payment_order_ids[0].mode.type.code
+        if pain_flavor == 'pain.001.001.02':
+            bic_xml_tag = 'BIC'
+            name_maxsize = 70
+            root_xml_tag = 'pain.001.001.02'
+        elif pain_flavor == 'pain.001.001.03':
+            bic_xml_tag = 'BIC'
+            # size 70 -> 140 for <Nm> with pain.001.001.03
+            # BUT the European Payment Council, in the document
+            # "SEPA Credit Transfer Scheme Customer-to-bank Implementation guidelines" v6.0
+            # available on http://www.europeanpaymentscouncil.eu/knowledge_bank.cfm
+            # says that 'Nm' should be limited to 70
+            # so we follow the "European Payment Council" and we put 70 and not 140
+            name_maxsize = 70
+            root_xml_tag = 'CstmrCdtTrfInitn'
+        elif pain_flavor == 'pain.001.001.04':
+            bic_xml_tag = 'BICFI'
+            name_maxsize = 140
+            root_xml_tag = 'CstmrCdtTrfInitn'
+        else:
+            raise orm.except_orm(_('Error :'), _("Payment Type Code '%s' is not supported. The only Payment Type Codes supported for SEPA Credit Transfers are 'pain.001.001.02', 'pain.001.001.03' and 'pain.001.001.04'.") % pain_flavor)
+        if sepa_export.batch_booking:
+            my_batch_booking = 'true'
+        else:
+            my_batch_booking = 'false'
+        my_msg_identification = sepa_export.msg_identification
+        if sepa_export.prefered_exec_date:
+            my_requested_exec_date = sepa_export.prefered_exec_date
+        else:
+            my_requested_exec_date = datetime.strftime(datetime.today() + timedelta(days=1), '%Y-%m-%d')
+
+        pain_ns = {
+            'xsi': 'http://www.w3.org/2001/XMLSchema-instance',
+            None: 'urn:iso:std:iso:20022:tech:xsd:%s' % pain_flavor,
+            }
+
+        root = etree.Element('Document', nsmap=pain_ns)
+        pain_root = etree.SubElement(root, root_xml_tag)
+        # A. Group header
+        group_header = etree.SubElement(pain_root, 'GrpHdr')
+        message_identification = etree.SubElement(group_header, 'MsgId')
+        message_identification.text = self._limit_size(cr, uid, my_msg_identification, 35, context=context)
+        creation_date_time = etree.SubElement(group_header, 'CreDtTm')
+        creation_date_time.text = datetime.strftime(datetime.today(), '%Y-%m-%dT%H:%M:%S')
+        if pain_flavor == 'pain.001.001.02':
+            # batch_booking is in "Group header" with pain.001.001.02
+            # and in "Payment info" in pain.001.001.03/04
+            batch_booking = etree.SubElement(group_header, 'BtchBookg')
+            batch_booking.text = my_batch_booking
+        nb_of_transactions_grphdr = etree.SubElement(group_header, 'NbOfTxs')
+        control_sum_grphdr = etree.SubElement(group_header, 'CtrlSum')
+        # Grpg removed in pain.001.001.03
+        if pain_flavor == 'pain.001.001.02':
+            grouping = etree.SubElement(group_header, 'Grpg')
+            grouping.text = 'GRPD'
+        initiating_party = etree.SubElement(group_header, 'InitgPty')
+        initiating_party_name = etree.SubElement(initiating_party, 'Nm')
+        initiating_party_name.text = self._limit_size(cr, uid, my_company_name, name_maxsize, context=context)
+        # B. Payment info
+        payment_info = etree.SubElement(pain_root, 'PmtInf')
+        payment_info_identification = etree.SubElement(payment_info, 'PmtInfId')
+        payment_info_identification.text = self._limit_size(cr, uid, my_msg_identification, 35, context=context)
+        payment_method = etree.SubElement(payment_info, 'PmtMtd')
+        payment_method.text = 'TRF'
+        if pain_flavor in ['pain.001.001.03', 'pain.001.001.04']:
+            # batch_booking is in "Group header" with pain.001.001.02
+            # and in "Payment info" in pain.001.001.03/04
+            batch_booking = etree.SubElement(payment_info, 'BtchBookg')
+            batch_booking.text = my_batch_booking
+        # It may seem surprising, but the
+        # "SEPA Credit Transfer Scheme Customer-to-bank Implementation guidelines"
+        # v6.0 says that control sum and nb_of_transactions should be present
+        # at both "group header" level and "payment info" level
+        # This seems to be confirmed by the tests carried out at
+        # BNP Paribas in PAIN v001.001.03
+        if pain_flavor in ['pain.001.001.03', 'pain.001.001.04']:
+            nb_of_transactions_pmtinf = etree.SubElement(payment_info, 'NbOfTxs')
+            control_sum_pmtinf = etree.SubElement(payment_info, 'CtrlSum')
+        payment_type_info = etree.SubElement(payment_info, 'PmtTpInf')
+        service_level = etree.SubElement(payment_type_info, 'SvcLvl')
+        service_level_code = etree.SubElement(service_level, 'Cd')
+        service_level_code.text = 'SEPA'
+        requested_exec_date = etree.SubElement(payment_info, 'ReqdExctnDt')
+        requested_exec_date.text = my_requested_exec_date
+        debtor = etree.SubElement(payment_info, 'Dbtr')
+        debtor_name = etree.SubElement(debtor, 'Nm')
+        debtor_name.text = self._limit_size(cr, uid, my_company_name, name_maxsize, context=context)
+#        debtor_address = etree.SubElement(debtor, 'PstlAdr')
+#        debtor_street = etree.SubElement(debtor_address, 'AdrLine')
+#        debtor_street.text = my_company_street1
+#        debtor_city = etree.SubElement(debtor_address, 'AdrLine')
+#        debtor_city.text = my_company_city
+#        debtor_country = etree.SubElement(debtor_address, 'Ctry')
+#        debtor_country.text = my_company_country_code
+        debtor_account = etree.SubElement(payment_info, 'DbtrAcct')
+        debtor_account_id = etree.SubElement(debtor_account, 'Id')
+        debtor_account_iban = etree.SubElement(debtor_account_id, 'IBAN')
+        debtor_account_iban.text = my_company_iban
+        debtor_agent = etree.SubElement(payment_info, 'DbtrAgt')
+        debtor_agent_institution = etree.SubElement(debtor_agent, 'FinInstnId')
+        debtor_agent_bic = etree.SubElement(debtor_agent_institution, bic_xml_tag)
+        debtor_agent_bic.text = my_company_bic
+        charge_bearer = etree.SubElement(payment_info, 'ChrgBr')
+        charge_bearer.text = sepa_export.charge_bearer
+
+        transactions_count = 0
+        total_amount = 0.0
+        amount_control_sum = 0.0
+        # Iterate on payment orders
+        for payment_order in sepa_export.payment_order_ids:
+            total_amount = total_amount + payment_order.total
+            # Iterate each payment lines
+            for line in payment_order.line_ids:
+                transactions_count += 1
+                # C. Credit Transfer Transaction Info
+                credit_transfer_transaction_info = etree.SubElement(payment_info, 'CdtTrfTxInf')
+                payment_identification = etree.SubElement(credit_transfer_transaction_info, 'PmtId')
+                instruction_identification = etree.SubElement(payment_identification, 'InstrId')
+                instruction_identification.text = self._limit_size(cr, uid, line.communication, 35, context=context) #otherwise, we can reach the invoice fields via ml_inv_ref
+                end2end_identification = etree.SubElement(payment_identification, 'EndToEndId')
+                end2end_identification.text = self._limit_size(cr, uid, line.communication, 35, context=context)
+                amount = etree.SubElement(credit_transfer_transaction_info, 'Amt')
+                instructed_amount = etree.SubElement(amount, 'InstdAmt', Ccy=line.currency.name)
+                instructed_amount.text = '%.2f' % line.amount_currency
+                amount_control_sum += line.amount_currency
+                creditor_agent = etree.SubElement(credit_transfer_transaction_info, 'CdtrAgt')
+                creditor_agent_institution = etree.SubElement(creditor_agent, 'FinInstnId')
+                creditor_agent_bic = etree.SubElement(creditor_agent_institution, bic_xml_tag)
+                creditor_agent_bic.text = line.bank_id.bank.bic
+                creditor = etree.SubElement(credit_transfer_transaction_info, 'Cdtr')
+                creditor_name = etree.SubElement(creditor, 'Nm')
+                creditor_name.text = self._limit_size(cr, uid, line.partner_id.name, name_maxsize, context=context)
+# I don't think they want it
+# If they want it, we need to implement full spec p26 appendix
+#                creditor_address = etree.SubElement(creditor, 'PstlAdr')
+#                creditor_street = etree.SubElement(creditor_address, 'AdrLine')
+#                creditor_street.text = line.partner_id.address[0].street
+#                creditor_city = etree.SubElement(creditor_address, 'AdrLine')
+#                creditor_city.text = line.partner_id.address[0].city
+#                creditor_country = etree.SubElement(creditor_address, 'Ctry')
+#                creditor_country.text = line.partner_id.address[0].country_id.code
+                creditor_account = etree.SubElement(credit_transfer_transaction_info, 'CdtrAcct')
+                creditor_account_id = etree.SubElement(creditor_account, 'Id')
+                creditor_account_iban = etree.SubElement(creditor_account_id, 'IBAN')
+                creditor_account_iban.text = self._validate_iban(cr, uid, line.bank_id.iban, context=context)
+                remittance_info = etree.SubElement(credit_transfer_transaction_info, 'RmtInf')
+                # switch to Structured (Strdr) ? If we do it, beware that the format is not the same between pain 02 and pain 03
+                remittance_info_unstructured = etree.SubElement(remittance_info, 'Ustrd')
+                remittance_info_unstructured.text = self._limit_size(cr, uid, line.communication, 140, context=context)
+
+        if pain_flavor in ['pain.001.001.03', 'pain.001.001.04']:
+            nb_of_transactions_grphdr.text = nb_of_transactions_pmtinf.text = str(transactions_count)
+            control_sum_grphdr.text = control_sum_pmtinf.text = '%.2f' % amount_control_sum
+        else:
+            nb_of_transactions_grphdr.text = str(transactions_count)
+            control_sum_grphdr.text = '%.2f' % amount_control_sum
+
+
+        xml_string = etree.tostring(root, pretty_print=True, encoding='UTF-8', xml_declaration=True)
+        _logger.debug("Generated SEPA XML file below")
+        _logger.debug(xml_string)
+        official_pain_schema = etree.XMLSchema(etree.parse(tools.file_open('account_banking_sepa_credit_transfer/data/%s.xsd' % pain_flavor)))
+
+        try:
+            official_pain_schema.validate(root)
+        except Exception, e:
+            _logger.warning("The XML file is invalid against the XML Schema Definition")
+            _logger.warning(xml_string)
+            _logger.warning(e)
+            raise orm.except_orm(_('Error :'), _('The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s') % str(e))
+
+        # CREATE the banking.export.sepa record
+        file_id = self.pool.get('banking.export.sepa').create(cr, uid,
+            {
+            'msg_identification': my_msg_identification,
+            'batch_booking': sepa_export.batch_booking,
+            'charge_bearer': sepa_export.charge_bearer,
+            'prefered_exec_date': sepa_export.prefered_exec_date,
+            'total_amount': total_amount,
+            'nb_transactions': transactions_count,
+            'file': base64.encodestring(xml_string),
+            'payment_order_ids': [
+                (6, 0, [x.id for x in sepa_export.payment_order_ids])
+            ],
+            }, context=context)
+
+        self.write(cr, uid, ids, {
+            'file_id': file_id,
+            'state': 'finish',
+            }, context=context)
+
+        action = {
+            'name': 'SEPA XML',
+            'type': 'ir.actions.act_window',
+            'view_type': 'form',
+            'view_mode': 'form,tree',
+            'res_model': self._name,
+            'res_id': ids[0],
+            'target': 'new',
+            }
+        return action
+
+
+    def cancel_sepa(self, cr, uid, ids, context=None):
+        '''
+        Cancel the SEPA PAIN: just drop the file
+        '''
+        sepa_export = self.browse(cr, uid, ids[0], context=context)
+        self.pool.get('banking.export.sepa').unlink(cr, uid, sepa_export.file_id.id, context=context)
+        return {'type': 'ir.actions.act_window_close'}
+
+
+    def save_sepa(self, cr, uid, ids, context=None):
+        '''
+        Save the SEPA PAIN: mark all payments in the file as 'sent'.
+        '''
+        sepa_export = self.browse(cr, uid, ids[0], context=context)
+        sepa_file = self.pool.get('banking.export.sepa').write(cr, uid,
+            sepa_export.file_id.id, {'state': 'sent'}, context=context)
+        wf_service = netsvc.LocalService('workflow')
+        for order in sepa_export.payment_order_ids:
+            wf_service.trg_validate(uid, 'payment.order', order.id, 'sent', cr)
+        return {'type': 'ir.actions.act_window_close'}
+>>>>>>> MERGE-SOURCE

=== modified file 'account_banking_sepa_credit_transfer/wizard/export_sepa_view.xml'
--- account_banking_sepa_credit_transfer/wizard/export_sepa_view.xml	2013-05-23 13:11:42 +0000
+++ account_banking_sepa_credit_transfer/wizard/export_sepa_view.xml	2013-07-25 08:56:25 +0000
@@ -1,3 +1,4 @@
+<<<<<<< TREE
 <?xml version="1.0" encoding="utf-8"?>
 <!--
   Copyright (C) 2010-2012 Akretion (http://www.akretion.com)
@@ -46,3 +47,52 @@
 
 </data>
 </openerp>
+=======
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2010-2012 Akretion (http://www.akretion.com)
+  @author: Alexis de Lattre <alexis.delattre@xxxxxxxxxxxx>
+  The licence is in the file __openerp__.py
+-->
+<openerp>
+<data>
+
+<record id="banking_export_sepa_wizard_view" model="ir.ui.view">
+    <field name="name">banking.export.sepa.wizard.view</field>
+    <field name="model">banking.export.sepa.wizard</field>
+    <field name="arch" type="xml">
+        <form string="SEPA XML file generation">
+            <field name="state" invisible="True"/>
+            <group states="create">
+                <separator colspan="4" string="Processing details" />
+                <field name="batch_booking" />
+                <field name="prefered_exec_date" />
+                <field name="charge_bearer" />
+                <separator colspan="4" string="Reference for further communication" />
+                <field name="msg_identification" required="True" />
+                <newline />
+                <button icon="gtk-close" special="cancel" string="Cancel" colspan="2"/>
+                <button icon="gtk-ok" string="Generate" name="create_sepa" type="object" colspan="2"/>
+            </group>
+            <group states="finish">
+                <field name="total_amount" />
+                <!-- Don't display this field, to avoid this bug :
+                https://bugs.launchpad.net/openobject-client-web/+bug/718989
+                Bug desc : in the Gtk client, you have to clic twice on the
+                "Create" button.
+                <field name="nb_transactions" /> -->
+                <newline />
+                <field name="file_id" />
+                <field name="file" filename="filename" />
+                <field name="filename" invisible="True"/>
+                <newline />
+                <button icon="gtk-cancel" string="Cancel" name="cancel_sepa" type="object" colspan="2"/>
+                <button icon="gtk-ok" string="Validate" name="save_sepa" type="object" colspan="2"/>
+            </group>
+        </form>
+    </field>
+</record>
+
+</data>
+</openerp>
+>>>>>>> MERGE-SOURCE

=== modified file 'account_banking_uk_hsbc/__openerp__.py'
--- account_banking_uk_hsbc/__openerp__.py	2012-03-27 14:55:03 +0000
+++ account_banking_uk_hsbc/__openerp__.py	2013-07-25 08:56:25 +0000
@@ -25,16 +25,14 @@
     'author': 'credativ Ltd',
     'website': 'http://www.credativ.co.uk',
     'category': 'Account Banking',
-    'depends': ['account_banking'],
-    'init_xml': [],
-    'update_xml': [
+    'depends': ['account_banking_payment'],
+    'data': [
         'account_banking_uk_hsbc.xml',
         'hsbc_clientid_view.xml',
         'data/banking_export_hsbc.xml',
         'wizard/export_hsbc_view.xml',
         'security/ir.model.access.csv',
     ],
-    'demo_xml': [],
     'description': '''
     Module to import HSBC format transation files (S.W.I.F.T MT940) and to export payments for HSBC.net (PAYMUL).
 
@@ -47,6 +45,5 @@
 
     Initial release of this module was co-sponsored by Canonical.
     ''',
-    'active': False,
     'installable': True,
 }

=== modified file 'account_banking_uk_hsbc/account_banking_uk_hsbc.py'
--- account_banking_uk_hsbc/account_banking_uk_hsbc.py	2012-03-27 14:55:03 +0000
+++ account_banking_uk_hsbc/account_banking_uk_hsbc.py	2013-07-25 08:56:25 +0000
@@ -5,16 +5,16 @@
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking_uk_hsbc/wizard/__init__.py'
--- account_banking_uk_hsbc/wizard/__init__.py	2011-10-24 15:26:13 +0000
+++ account_banking_uk_hsbc/wizard/__init__.py	2013-07-25 08:56:25 +0000
@@ -6,16 +6,16 @@
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking_uk_hsbc/wizard/export_hsbc.py'
--- account_banking_uk_hsbc/wizard/export_hsbc.py	2012-03-22 12:07:57 +0000
+++ account_banking_uk_hsbc/wizard/export_hsbc.py	2013-07-25 08:56:25 +0000
@@ -6,16 +6,16 @@
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking_uk_hsbc/wizard/paymul.py'
--- account_banking_uk_hsbc/wizard/paymul.py	2012-03-22 12:07:57 +0000
+++ account_banking_uk_hsbc/wizard/paymul.py	2013-07-25 08:56:25 +0000
@@ -5,16 +5,16 @@
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_banking_uk_hsbc/wizard/paymul_test.py'
--- account_banking_uk_hsbc/wizard/paymul_test.py	2011-10-24 15:26:13 +0000
+++ account_banking_uk_hsbc/wizard/paymul_test.py	2013-07-25 08:56:25 +0000
@@ -5,16 +5,16 @@
 #    All Rights Reserved
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################

=== modified file 'account_direct_debit/__openerp__.py'
--- account_direct_debit/__openerp__.py	2012-05-03 12:40:37 +0000
+++ account_direct_debit/__openerp__.py	2013-07-25 08:56:25 +0000
@@ -1,46 +1,37 @@
 ##############################################################################
 #
-#    Copyright (C) 2011 Therp BV (<http://therp.nl>).
+#    Copyright (C) 2011 - 2013 Therp BV (<http://therp.nl>).
 #    Copyright (C) 2011 Smile (<http://smile.fr>).
 #    All Rights Reserved
 #
-#    WARNING: This program as such is intended to be used by professional
-#    programmers who take the whole responsability of assessing all potential
-#    consequences resulting from its eventual inadequacies and bugs
-#    End users who are looking for a ready-to-use solution with commercial
-#    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 General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
 {
     'name': 'Direct Debit',
-    'version': '6.1.1.134',
-    'license': 'GPL-3',
-    'author': 'Therp BV / Smile',
+    'version': '7.0.2.134',
+    'license': 'AGPL-3',
+    'author': ['Therp BV', 'Smile'],
     'website': 'https://launchpad.net/banking-addons',
     'category': 'Banking addons',
     'depends': ['account_banking'],
-    'init_xml': [],
-    'update_xml': [
+    'data': [
         'view/account_payment.xml',
         'view/account_invoice.xml',
         'workflow/account_invoice.xml',
-        'workflow/account_payment.xml',
         'data/account_payment_term.xml',
     ],
-    'demo_xml': [],
     'description': '''
 This module adds support for direct debit orders, analogous to payment orders.
 A new entry in the Accounting/Payment menu allow you to create a direct debit
@@ -57,6 +48,5 @@
 banking institutions. The banking addons are a continuation of Account Banking
 Framework by Edusense BV. See https://launchpad.net/banking-addons.
     ''',
-    'active': False,
     'installable': True,
 }

=== modified file 'account_direct_debit/i18n/nl.po'
--- account_direct_debit/i18n/nl.po	2012-08-08 10:32:52 +0000
+++ account_direct_debit/i18n/nl.po	2013-07-25 08:56:25 +0000
@@ -175,7 +175,7 @@
 msgstr "De betaalregelnaam moet uniek zijn!"
 
 #. module: account_direct_debit
-#: field:payment.line,debit_move_line_id:0
+#: field:payment.line,transit_move_line_id:0
 msgid "Debit move line"
 msgstr "Debetboeking"
 
@@ -200,7 +200,7 @@
 msgstr "Factuur"
 
 #. module: account_direct_debit
-#: help:payment.line,debit_move_line_id:0
+#: help:payment.line,transit_move_line_id:0
 msgid "Move line through which the debit order pays the invoice"
 msgstr "Dagboekregel waarmee de incasso-opdracht de factuur voldoet"
 

=== added directory 'account_direct_debit/migrations'
=== added directory 'account_direct_debit/migrations/7.0.2'
=== added file 'account_direct_debit/migrations/7.0.2/pre-migration.py'
--- account_direct_debit/migrations/7.0.2/pre-migration.py	1970-01-01 00:00:00 +0000
+++ account_direct_debit/migrations/7.0.2/pre-migration.py	2013-07-25 08:56:25 +0000
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2013 Therp BV (<http://therp.nl>).
+#            
+#    All other contributions are (C) by their respective contributors
+#
+#    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 (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+def rename_columns(cr, column_spec):
+    """
+    Rename table columns. Taken from OpenUpgrade.
+
+    :param column_spec: a hash with table keys, with lists of tuples as values. \
+    Tuples consist of (old_name, new_name).
+
+    """
+    for table in column_spec.keys():
+        for (old, new) in column_spec[table]:
+            logger.info("table %s, column %s: renaming to %s",
+                     table, old, new)
+            cr.execute('ALTER TABLE "%s" RENAME "%s" TO "%s"' % (table, old, new,))
+            cr.execute('DROP INDEX IF EXISTS "%s_%s_index"' % (table, old))
+
+def migrate(cr, version):
+    if not version:
+        return
+
+    # workflow state moved to another module
+    cr.execute(
+        """
+        UPDATE ir_model_data 
+        SET module = 'account_banking_payment'
+        WHERE name = 'trans_done_sent'
+        AND module = 'account_direct_debit'
+        """)
+
+    # rename field debit_move_line_id
+    rename_columns(cr, {
+            'payment_line': [
+                ('debit_move_line_id', 'transit_move_line_id'),
+                ]})

=== modified file 'account_direct_debit/model/__init__.py'
--- account_direct_debit/model/__init__.py	2011-12-11 15:00:41 +0000
+++ account_direct_debit/model/__init__.py	2013-07-25 08:56:25 +0000
@@ -1,3 +1,5 @@
 import account_payment
+import payment_line
 import account_move_line
 import account_invoice
+import payment_order_create

=== modified file 'account_direct_debit/model/account_invoice.py'
--- account_direct_debit/model/account_invoice.py	2012-01-12 10:58:49 +0000
+++ account_direct_debit/model/account_invoice.py	2013-07-25 08:56:25 +0000
@@ -1,6 +1,29 @@
 # -*- coding: utf-8 -*-
-from osv import osv, fields
-from tools.translate import _
+##############################################################################
+#
+#    Copyright (C) 2011 - 2013 Therp BV (<http://therp.nl>).
+#            
+#    All other contributions are (C) by their respective contributors
+#
+#    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 (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import orm, fields
+from openerp.tools.translate import _
 
 """
 This module adds support for Direct debit orders as applicable
@@ -98,7 +121,7 @@
    open invoices with a matured invoice- or due date.
 """ 
 
-class account_invoice(osv.osv):
+class account_invoice(orm.Model):
     _inherit = "account.invoice"
 
     def __init__(self, pool, cr):
@@ -139,5 +162,3 @@
             if not invoice['reconciled']:
                 return False
         return True
-
-account_invoice()

=== modified file 'account_direct_debit/model/account_move_line.py'
--- account_direct_debit/model/account_move_line.py	2013-01-24 11:04:21 +0000
+++ account_direct_debit/model/account_move_line.py	2013-07-25 08:56:25 +0000
@@ -2,9 +2,8 @@
 ##############################################################################
 #
 #    OpenERP, Open Source Management Solution
-#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
-#    This module additional (C) 2011 Therp BV (<http://therp.nl>).
-#                           (C) 2011 Smile Benelux (<http://smile.fr>).
+#    This module (C) 2011 - 2013 Therp BV (<http://therp.nl>).
+#                (C) 2011 Smile Benelux (<http://smile.fr>).
 #
 #    This program is free software: you can redistribute it and/or modify
 #    it under the terms of the GNU Affero General Public License as
@@ -22,10 +21,9 @@
 ##############################################################################
 
 from operator import itemgetter
-from osv import fields, osv
-from tools.translate import _
+from openerp.osv import fields, orm
 
-class account_move_line(osv.osv):
+class account_move_line(orm.Model):
     _inherit = "account.move.line"
 
     def amount_to_receive(self, cr, uid, ids, name, arg={}, context=None):
@@ -55,10 +53,13 @@
         return r
 
     def _to_receive_search(self, cr, uid, obj, name, args, context=None):
+        """
+        Reverse of account_payment/account_move_line.py:_to_pay_search()
+        """
         if not args:
             return []
         line_obj = self.pool.get('account.move.line')
-        query = line_obj._query_get(cr, uid, context={})
+        query = line_obj._query_get(cr, uid, context=context)
         where = ' and '.join(map(lambda x: '''(SELECT
         CASE WHEN l.amount_currency > 0
             THEN l.amount_currency
@@ -86,70 +87,9 @@
             return [('id', '=', '0')]
         return [('id', 'in', map(lambda x:x[0], res))]
 
-    def _dummy(self, cr, user, ids, name, arg, context=None):
-        res = {}
-        if ids:
-            res = dict([(x, False) for x in ids])
-        return res
-
-    def _invoice_payment_term_id_search(
-        self, cr, uid, obj, name, args, context=None):
-        """
-        Allow to search move lines associated with an invoice with
-        a particular payment term
-        """
-        if not args:
-            return []
-        invoice_obj = self.pool.get('account.invoice')
-        invoice_ids = invoice_obj.search(
-            cr, uid, [('payment_term', args[0][1], args[0][2])],
-            context=context)
-        operator = 'in' # (args[0][1] not in ['in', '=', '==', 'like', 'ilike']
-                        # and 'not in' or 'in')
-        if not invoice_ids:
-            return [('id', operator, [])]
-        cr.execute('SELECT l.id ' \
-                'FROM account_move_line l, account_invoice i ' \
-                'WHERE l.move_id = i.move_id AND i.id in %s', (tuple(invoice_ids),))
-        res = cr.fetchall()
-        if not res:
-            return [('id', '=', False)]
-        return [('id', operator, [x[0] for x in res])]
-
-    def _invoice_state_search(self, cr, uid, obj, name, args, context=None):
-        if not args:
-            return []
-        invoice_obj = self.pool.get('account.invoice')
-        invoice_ids = invoice_obj.search(
-            cr, uid, [('state', args[0][1], args[0][2])],
-            context=context)
-        operator = 'in' # (args[0][1] not in ['in', '=', '==', 'like', 'ilike']
-                        # and 'not in' or 'in')
-        if not invoice_ids:
-            return [('id', operator, [])]
-        cr.execute('SELECT l.id ' \
-                'FROM account_move_line l, account_invoice i ' \
-                'WHERE l.move_id = i.move_id AND i.id in %s', (tuple(invoice_ids),))
-        res = cr.fetchall()
-        if not res:
-            return [('id', '=', False)]
-        return [('id', operator, [x[0] for x in res])]
-        
     _columns = {
         'amount_to_receive': fields.function(
             amount_to_receive, method=True,
             type='float', string='Amount to receive',
             fnct_search=_to_receive_search),
-        'payment_term_id': fields.function(
-            _dummy, method=True,
-            string='Select by invoice payment term',
-            type='many2one', relation='account.payment.term',
-            fnct_search=_invoice_payment_term_id_search),
-        'invoice_state': fields.function(
-            _dummy, method=True,
-            string='Select by invoice state',
-            type='char', size=24,
-            fnct_search=_invoice_state_search),
         }
-
-account_move_line()

=== modified file 'account_direct_debit/model/account_payment.py'
--- account_direct_debit/model/account_payment.py	2013-01-21 11:30:46 +0000
+++ account_direct_debit/model/account_payment.py	2013-07-25 08:56:25 +0000
@@ -1,36 +1,9 @@
 # -*- coding: utf-8 -*-
-import time
-from osv import osv, fields
+from openerp.osv import orm, fields
 import netsvc
 from tools.translate import _
 
-class payment_mode(osv.osv):
-    _inherit = 'payment.mode'
-    _columns = {
-        'transfer_account_id': fields.many2one(
-            'account.account', 'Transfer account',
-            domain=[('type', '=', 'other'),
-                    ('reconcile', '=', True)],
-            help=('Pay off lines in sent orders with a ' +
-                  'move on this account. For debit type modes only. ' +
-                  'You can only select accounts of type regular that ' +
-                  'are marked for reconciliation'),
-            ),
-        'transfer_journal_id': fields.many2one(
-            'account.journal', 'Transfer journal',
-            help=('Journal to write payment entries when confirming ' +
-                  'a debit order of this mode'),
-            ),
-        'payment_term_ids': fields.many2many(
-            'account.payment.term', 'account_payment_order_terms_rel', 
-            'mode_id', 'term_id', 'Payment terms',
-            help=('Limit selected invoices to invoices with these payment ' +
-                  'terms')
-            ),
-        }
-payment_mode()
-
-class payment_order(osv.osv):
+class payment_order(orm.Model):
     _inherit = 'payment.order'
 
     def fields_view_get(self, cr, user, view_id=None, view_type='form',
@@ -56,56 +29,11 @@
                            context['search_payment_order_type'])]
                 # the magic is in the value of the selection
                 res['fields']['mode']['selection'] = mode_obj._name_search(
-                    cr, user, args=domain)
+                    cr, user, args=domain, context=context)
                 # also update the domain
                 res['fields']['mode']['domain'] = domain
         return res
 
-    def debit_reconcile_transfer(self, cr, uid, payment_order_id, 
-                                 amount, currency, context=None):
-        """
-        During import of bank statements, create the reconcile on the transfer
-        account containing all the open move lines on the transfer account.
-        """
-        move_line_obj = self.pool.get('account.move.line')
-        order = self.browse(cr, uid, payment_order_id, context)
-        line_ids = []
-        reconcile_id = False
-        for order_line in order.line_ids:
-            for line in order_line.debit_move_line_id.move_id.line_id:
-                if line.account_id.type == 'other' and not line.reconcile_id:
-                    line_ids.append(line.id)
-        if self.pool.get('res.currency').is_zero(
-            cr, uid, currency,
-            move_line_obj.get_balance(cr, uid, line_ids) - amount):
-            reconcile_id = self.pool.get('account.move.reconcile').create(
-                cr, uid, 
-                {'type': 'auto', 'line_id': [(6, 0, line_ids)]},
-                context)
-            # set direct debit order to finished state
-            wf_service = netsvc.LocalService('workflow')
-            wf_service.trg_validate(
-                uid, 'payment.order', payment_order_id, 'done', cr)
-        return reconcile_id
-
-    def debit_unreconcile_transfer(self, cr, uid, payment_order_id, reconcile_id,
-                                 amount, currency, context=None):
-        """
-        Due to a cancelled bank statements import, unreconcile the move on
-        the transfer account. Delegate the conditions to the workflow.
-        Raise on failure for rollback.
-        """
-        self.pool.get('account.move.reconcile').unlink(
-            cr, uid, reconcile_id, context=context)
-        wkf_ok = netsvc.LocalService('workflow').trg_validate(
-            uid, 'payment.order', payment_order_id, 'undo_done', cr)
-        if not wkf_ok:
-            raise osv.except_osv(
-                _("Cannot unreconcile"),
-                _("Cannot unreconcile debit order: "+
-                  "Workflow will not allow it."))
-        return True
-
     def test_undo_done(self, cr, uid, ids, context=None):
         """ 
         Called from the workflow. Used to unset done state on
@@ -117,362 +45,5 @@
                 for line in order.line_ids:
                     if line.storno:
                         return False
-            else:
-                # TODO: define conditions for 'payment' orders
-                return False
-        return True
-        
-    def action_sent(self, cr, uid, ids, context=None):
-        """ 
-        Create the moves that pay off the move lines from
-        the debit order. This happens when the debit order file is
-        generated.
-        """
-        res = super(payment_order, self).action_sent(
-            cr, uid, ids, context)
-
-        account_move_obj = self.pool.get('account.move')
-        account_move_line_obj = self.pool.get('account.move.line')
-        payment_line_obj = self.pool.get('payment.line')
-        for order in self.browse(cr, uid, ids, context=context):
-            if order.payment_order_type != 'debit':
-                continue
-            for line in order.line_ids:
-                # basic checks
-                if not line.move_line_id:
-                    raise osv.except_osv(
-                        _('Error'),
-                        _('No move line provided for line %s') % line.name)
-                if line.move_line_id.reconcile_id:
-                    raise osv.except_osv(
-                        _('Error'),
-                        _('Move line %s has already been paid/reconciled') % 
-                        line.move_line_id.name
-                        )
-
-                move_id = account_move_obj.create(cr, uid, {
-                        'journal_id': order.mode.transfer_journal_id.id,
-                        'name': 'Debit order %s' % line.move_line_id.move_id.name,
-                        'reference': 'DEB%s' % line.move_line_id.move_id.name,
-                        }, context=context)
-
-                # TODO: take multicurrency into account
-                
-                # create the debit move line on the transfer account
-                vals = {
-                    'name': 'Debit order for %s' % (
-                        line.move_line_id.invoice and 
-                        line.move_line_id.invoice.number or 
-                        line.move_line_id.name),
-                    'move_id': move_id,
-                    'partner_id': line.partner_id.id,
-                    'account_id': order.mode.transfer_account_id.id,
-                    'credit': 0.0,
-                    'debit': line.amount,
-                    'date': time.strftime('%Y-%m-%d'),
-                    }
-                transfer_move_line_id = account_move_line_obj.create(
-                    cr, uid, vals, context=context)
-
-                # create the debit move line on the receivable account
-                vals.update({
-                        'account_id': line.move_line_id.account_id.id,
-                        'credit': line.amount,
-                        'debit': 0.0,
-                        })               
-                reconcile_move_line_id = account_move_line_obj.create(
-                    cr, uid, vals, context=context)
-                
-                # register the debit move line on the payment line
-                # and call reconciliation on it
-                payment_line_obj.write(
-                    cr, uid, line.id,
-                    {'debit_move_line_id': reconcile_move_line_id},
-                    context=context)
-
-                payment_line_obj.debit_reconcile(
-                    cr, uid, line.id, context=context)
-                account_move_obj.post(cr, uid, [move_id], context=context)
-        return res
-
-payment_order()
-
-class payment_line(osv.osv):
-    _inherit = 'payment.line'
-
-    def debit_storno(self, cr, uid, payment_line_id, amount,
-                     currency, storno_retry=True, context=None):
-        """
-        The processing of a storno is triggered by a debit
-        transfer on one of the company's bank accounts.
-        This method offers to re-reconcile the original debit
-        payment. For this purpose, we have registered that
-        payment move on the payment line.
-
-        Return the (now incomplete) reconcile id. The caller MUST
-        re-reconcile this reconcile with the bank transfer and
-        re-open the associated invoice.
-
-        :param payment_line_id: the single payment line id
-        :param amount: the (signed) amount debited from the bank account
-        :param currency: the bank account's currency *browse object*
-        :param boolean storno_retry: when True, attempt to reopen the invoice, \
-        set the invoice to 'Debit denied' otherwise.
-        :return: an incomplete reconcile for the caller to fill
-        :rtype: database id of an account.move.reconcile resource.
-        """
-
-        move_line_obj = self.pool.get('account.move.line')
-        reconcile_obj = self.pool.get('account.move.reconcile')
-        line = self.browse(cr, uid, payment_line_id)
-        reconcile_id = False
-        if (line.debit_move_line_id and not line.storno and
-            self.pool.get('res.currency').is_zero(
-                cr, uid, currency, (
-                    (line.debit_move_line_id.credit or 0.0) -
-                    (line.debit_move_line_id.debit or 0.0) + amount))):
-            # Two different cases, full and partial
-            # Both cases differ subtly in the procedure to follow
-            # Needs refractoring, but why is this not in the OpenERP API?
-            # Actually, given the nature of a direct debit order and storno,
-            # we should not need to take partial into account on the side of
-            # the debit_move_line.
-            if line.debit_move_line_id.reconcile_partial_id:
-                reconcile_id = line.debit_move_line_id.reconcile_partial_id.id
-                attribute = 'reconcile_partial_id'
-                if len(line.debit_move_line_id.reconcile_id.line_partial_ids) == 2:
-                    # reuse the simple reconcile for the storno transfer
-                    reconcile_obj.write(
-                        cr, uid, reconcile_id, {
-                            'line_id': [(6, 0, line.debit_move_line_id.id)],
-                            'line_partial_ids': [(6, 0, [])],
-                            }, context=context)
-                else:
-                    # split up the original reconcile in a partial one
-                    # and a new one for reconciling the storno transfer
-                    reconcile_obj.write(
-                        cr, uid, reconcile_id, {
-                            'line_partial_ids': [(3, line.debit_move_line_id.id)],
-                            }, context=context)
-                    reconcile_id = reconcile_obj.create(
-                        cr, uid, {
-                            'type': 'auto',
-                            'line_id': [(6, 0, line.debit_move_line_id.id)],
-                            }, context=context)
-            elif line.debit_move_line_id.reconcile_id:
-                reconcile_id = line.debit_move_line_id.reconcile_id.id
-                if len(line.debit_move_line_id.reconcile_id.line_id) == 2:
-                    # reuse the simple reconcile for the storno transfer
-                    reconcile_obj.write(
-                        cr, uid, reconcile_id, {
-                            'line_id': [(6, 0, [line.debit_move_line_id.id])]
-                            }, context=context)
-                else:
-                    # split up the original reconcile in a partial one
-                    # and a new one for reconciling the storno transfer
-                    partial_ids = [ 
-                        x.id for x in line.debit_move_line_id.reconcile_id.line_id
-                        if x.id != line.debit_move_line_id.id
-                        ]
-                    reconcile_obj.write(
-                        cr, uid, reconcile_id, {
-                            'line_partial_ids': [(6, 0, partial_ids)],
-                            'line_id': [(6, 0, [])],
-                            }, context=context)
-                    reconcile_id = reconcile_obj.create(
-                        cr, uid, {
-                            'type': 'auto',
-                            'line_id': [(6, 0, line.debit_move_line_id.id)],
-                            }, context=context)
-            # mark the payment line for storno processed
-            if reconcile_id:
-                self.write(cr, uid, [payment_line_id],
-                           {'storno': True}, context=context)
-                # put forth the invoice workflow
-                if line.move_line_id.invoice:
-                    activity = (storno_retry and 'open_test'
-                                or 'invoice_debit_denied')
-                    netsvc.LocalService("workflow").trg_validate(
-                        uid, 'account.invoice', line.move_line_id.invoice.id,
-                        activity, cr)
-        return reconcile_id
-
-    def get_storno_account_id(self, cr, uid, payment_line_id, amount,
-                     currency, context=None):
-        """
-        Check the match of the arguments, and return the account associated
-        with the storno.
-        Used in account_banking interactive mode
-
-        :param payment_line_id: the single payment line id
-        :param amount: the (signed) amount debited from the bank account
-        :param currency: the bank account's currency *browse object*
-        :return: an account if there is a full match, False otherwise
-        :rtype: database id of an account.account resource.
-        """
-
-        line = self.browse(cr, uid, payment_line_id)
-        account_id = False
-        if (line.debit_move_line_id and not line.storno and
-            self.pool.get('res.currency').is_zero(
-                cr, uid, currency, (
-                    (line.debit_move_line_id.credit or 0.0) -
-                    (line.debit_move_line_id.debit or 0.0) + amount))):
-            account_id = line.debit_move_line_id.account_id.id
-        return account_id
-
-    def debit_reconcile(self, cr, uid, payment_line_id, context=None):
-        """
-        Reconcile a debit order's payment line with the the move line
-        that it is based on. Called from payment_order.action_sent().
-        As the amount is derived directly from the counterpart move line,
-        we do not expect a write off. Take partially reconcilions into
-        account though.
-
-        :param payment_line_id: the single id of the canceled payment line
-        """
-
-        if isinstance(payment_line_id, (list, tuple)):
-            payment_line_id = payment_line_id[0]
-        reconcile_obj = self.pool.get('account.move.reconcile')
-        move_line_obj = self.pool.get('account.move.line')
-        payment_line = self.browse(cr, uid, payment_line_id, context=context)
-
-        debit_move_line = payment_line.debit_move_line_id
-        torec_move_line = payment_line.move_line_id
-
-        if payment_line.storno:
-            raise osv.except_osv(
-                _('Can not reconcile'),
-                _('Cancelation of payment line \'%s\' has already been ' +
-                  'processed') % payment_line.name)
-        if (not debit_move_line or not torec_move_line):
-            raise osv.except_osv(
-                _('Can not reconcile'),
-                _('No move line for line %s') % payment_line.name)     
-        if torec_move_line.reconcile_id: # torec_move_line.reconcile_partial_id:
-            raise osv.except_osv(
-                _('Error'),
-                _('Move line %s has already been reconciled') % 
-                torec_move_line.name
-                )
-        if debit_move_line.reconcile_id or debit_move_line.reconcile_partial_id:
-            raise osv.except_osv(
-                _('Error'),
-                _('Move line %s has already been reconciled') % 
-                debit_move_line.name
-                )
-
-        def is_zero(total):
-            return self.pool.get('res.currency').is_zero(
-                cr, uid, debit_move_line.company_id.currency_id, total)
-
-        line_ids = [debit_move_line.id, torec_move_line.id]
-        if torec_move_line.reconcile_partial_id:
-            line_ids = [
-                x.id for x in debit_move_line.reconcile_partial_id.line_partial_ids] + [torec_move_line_id]
-
-        total = move_line_obj.get_balance(cr, uid, line_ids)
-        vals = {
-            'type': 'auto',
-            'line_id': is_zero(total) and [(6, 0, line_ids)] or [(6, 0, [])],
-            'line_partial_ids': is_zero(total) and [(6, 0, [])] or [(6, 0, line_ids)],
-            }
-
-        if torec_move_line.reconcile_partial_id:
-            reconcile_obj.write(
-                cr, uid, debit_move_line.reconcile_partial_id.id,
-                vals, context=context)
-        else:
-            reconcile_obj.create(
-                cr, uid, vals, context=context)
-        for line_id in line_ids:
-            netsvc.LocalService("workflow").trg_trigger(
-                uid, 'account.move.line', line_id, cr)
-
-        # If a bank transaction of a storno was first confirmed
-        # and now canceled (the invoice is now in state 'debit_denied'
-        if torec_move_line.invoice:
-            netsvc.LocalService("workflow").trg_validate(
-                uid, 'account.invoice', torec_move_line.invoice.id,
-                'undo_debit_denied', cr)
-
-
-
-    _columns = {
-        'debit_move_line_id': fields.many2one(
-            # this line is part of the credit side of move 2a 
-            # from the documentation
-            'account.move.line', 'Debit move line',
-            readonly=True,
-            help="Move line through which the debit order pays the invoice"),
-        'storno': fields.boolean(
-            'Storno',
-            readonly=True,
-            help=("If this is true, the debit order has been canceled " +
-                  "by the bank or by the customer")),
-        }
-payment_line()
-
-
-class payment_order_create(osv.osv_memory):
-    _inherit = 'payment.order.create'
-    
-    def search_entries(self, cr, uid, ids, context=None):
-        """
-        This method taken from account_payment module.
-        We adapt the domain based on the payment_order_type
-        """
-        line_obj = self.pool.get('account.move.line')
-        mod_obj = self.pool.get('ir.model.data')
-        if context is None:
-            context = {}
-        data = self.read(cr, uid, ids, [], context=context)[0]
-        search_due_date = data['duedate']
-        
-        ### start account_direct_debit ###
-        payment = self.pool.get('payment.order').browse(
-            cr, uid, context['active_id'], context=context)
-        # Search for move line to pay:
-        if payment.payment_order_type == 'debit':
-            domain = [
-                ('reconcile_id', '=', False),
-                ('account_id.type', '=', 'receivable'),
-                ('invoice_state', '!=', 'debit_denied'),
-                ('amount_to_receive', '>', 0),
-                ]
-        else:
-            domain = [
-                ('reconcile_id', '=', False),
-                ('account_id.type', '=', 'payable'),
-                ('amount_to_pay', '>', 0)
-                ]
-        domain.append(('company_id', '=', payment.mode.company_id.id))
-        # apply payment term filter
-        if payment.mode.payment_term_ids:
-            domain = domain + [
-                ('payment_term_id', 'in', 
-                 [term.id for term in payment.mode.payment_term_ids]
-                 )
-                ]
-        # domain = [('reconcile_id', '=', False), ('account_id.type', '=', 'payable'), ('amount_to_pay', '>', 0)]
-        ### end account_direct_debit ###
-
-        domain = domain + ['|', ('date_maturity', '<=', search_due_date), ('date_maturity', '=', False)]
-        line_ids = line_obj.search(cr, uid, domain, context=context)
-        context.update({'line_ids': line_ids})
-        model_data_ids = mod_obj.search(cr, uid,[('model', '=', 'ir.ui.view'), ('name', '=', 'view_create_payment_order_lines')], context=context)
-        resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
-        return {'name': ('Entry Lines'),
-                'context': context,
-                'view_type': 'form',
-                'view_mode': 'form',
-                'res_model': 'payment.order.create',
-                'views': [(resource_id,'form')],
-                'type': 'ir.actions.act_window',
-                'target': 'new',
-        }
-payment_order_create()
-
-
-                  
+        return super(payment_order, self).test_undo_done(
+            cr, uid, ids, context=context)

=== added file 'account_direct_debit/model/payment_line.py'
--- account_direct_debit/model/payment_line.py	1970-01-01 00:00:00 +0000
+++ account_direct_debit/model/payment_line.py	2013-07-25 08:56:25 +0000
@@ -0,0 +1,152 @@
+# -*- coding: utf-8 -*-
+from openerp.osv import orm, fields
+import netsvc
+from tools.translate import _
+
+class payment_line(orm.Model):
+    _inherit = 'payment.line'
+
+    def debit_storno(self, cr, uid, payment_line_id, amount,
+                     currency, storno_retry=True, context=None):
+        """
+        The processing of a storno is triggered by a debit
+        transfer on one of the company's bank accounts.
+        This method offers to re-reconcile the original debit
+        payment. For this purpose, we have registered that
+        payment move on the payment line.
+
+        Return the (now incomplete) reconcile id. The caller MUST
+        re-reconcile this reconcile with the bank transfer and
+        re-open the associated invoice.
+
+        :param payment_line_id: the single payment line id
+        :param amount: the (signed) amount debited from the bank account
+        :param currency: the bank account's currency *browse object*
+        :param boolean storno_retry: when True, attempt to reopen the invoice, \
+        set the invoice to 'Debit denied' otherwise.
+        :return: an incomplete reconcile for the caller to fill
+        :rtype: database id of an account.move.reconcile resource.
+        """
+
+        move_line_obj = self.pool.get('account.move.line')
+        reconcile_obj = self.pool.get('account.move.reconcile')
+        line = self.browse(cr, uid, payment_line_id)
+        reconcile_id = False
+        if (line.transit_move_line_id and not line.storno and
+            self.pool.get('res.currency').is_zero(
+                cr, uid, currency, (
+                    (line.transit_move_line_id.credit or 0.0) -
+                    (line.transit_move_line_id.debit or 0.0) + amount))):
+            # Two different cases, full and partial
+            # Both cases differ subtly in the procedure to follow
+            # Needs refractoring, but why is this not in the OpenERP API?
+            # Actually, given the nature of a direct debit order and storno,
+            # we should not need to take partial into account on the side of
+            # the transit_move_line.
+            if line.transit_move_line_id.reconcile_partial_id:
+                reconcile_id = line.transit_move_line_id.reconcile_partial_id.id
+                attribute = 'reconcile_partial_id'
+                if len(line.transit_move_line_id.reconcile_id.line_partial_ids) == 2:
+                    # reuse the simple reconcile for the storno transfer
+                    reconcile_obj.write(
+                        cr, uid, reconcile_id, {
+                            'line_id': [(6, 0, line.transit_move_line_id.id)],
+                            'line_partial_ids': [(6, 0, [])],
+                            }, context=context)
+                else:
+                    # split up the original reconcile in a partial one
+                    # and a new one for reconciling the storno transfer
+                    reconcile_obj.write(
+                        cr, uid, reconcile_id, {
+                            'line_partial_ids': [(3, line.transit_move_line_id.id)],
+                            }, context=context)
+                    reconcile_id = reconcile_obj.create(
+                        cr, uid, {
+                            'type': 'auto',
+                            'line_id': [(6, 0, line.transit_move_line_id.id)],
+                            }, context=context)
+            elif line.transit_move_line_id.reconcile_id:
+                reconcile_id = line.transit_move_line_id.reconcile_id.id
+                if len(line.transit_move_line_id.reconcile_id.line_id) == 2:
+                    # reuse the simple reconcile for the storno transfer
+                    reconcile_obj.write(
+                        cr, uid, reconcile_id, {
+                            'line_id': [(6, 0, [line.transit_move_line_id.id])]
+                            }, context=context)
+                else:
+                    # split up the original reconcile in a partial one
+                    # and a new one for reconciling the storno transfer
+                    partial_ids = [ 
+                        x.id for x in line.transit_move_line_id.reconcile_id.line_id
+                        if x.id != line.transit_move_line_id.id
+                        ]
+                    reconcile_obj.write(
+                        cr, uid, reconcile_id, {
+                            'line_partial_ids': [(6, 0, partial_ids)],
+                            'line_id': [(6, 0, [])],
+                            }, context=context)
+                    reconcile_id = reconcile_obj.create(
+                        cr, uid, {
+                            'type': 'auto',
+                            'line_id': [(6, 0, line.transit_move_line_id.id)],
+                            }, context=context)
+            # mark the payment line for storno processed
+            if reconcile_id:
+                self.write(cr, uid, [payment_line_id],
+                           {'storno': True}, context=context)
+                # put forth the invoice workflow
+                if line.move_line_id.invoice:
+                    activity = (storno_retry and 'open_test'
+                                or 'invoice_debit_denied')
+                    netsvc.LocalService("workflow").trg_validate(
+                        uid, 'account.invoice', line.move_line_id.invoice.id,
+                        activity, cr)
+        return reconcile_id
+
+    def get_storno_account_id(self, cr, uid, payment_line_id, amount,
+                     currency, context=None):
+        """
+        Check the match of the arguments, and return the account associated
+        with the storno.
+        Used in account_banking interactive mode
+
+        :param payment_line_id: the single payment line id
+        :param amount: the (signed) amount debited from the bank account
+        :param currency: the bank account's currency *browse object*
+        :return: an account if there is a full match, False otherwise
+        :rtype: database id of an account.account resource.
+        """
+
+        line = self.browse(cr, uid, payment_line_id)
+        account_id = False
+        if (line.transit_move_line_id and not line.storno and
+            self.pool.get('res.currency').is_zero(
+                cr, uid, currency, (
+                    (line.transit_move_line_id.credit or 0.0) -
+                    (line.transit_move_line_id.debit or 0.0) + amount))):
+            account_id = line.transit_move_line_id.account_id.id
+        return account_id
+
+    def debit_reconcile(self, cr, uid, payment_line_id, context=None):
+        """
+        Raise if a payment line is passed for which storno is True
+        """
+        if isinstance(payment_line_id, (list, tuple)):
+            payment_line_id = payment_line_id[0]
+        payment_line = self.read(
+            cr, uid, payment_line_id, ['storno', 'name'], context=context)
+        if payment_line['storno']:
+            raise orm.except_orm(
+                _('Can not reconcile'),
+                _('Cancelation of payment line \'%s\' has already been '
+                  'processed') % payment_line['name'])
+        return super(self, payment_line).debit_reconcile(
+            cr, uid, payment_line_id, context=context)
+
+    _columns = {
+        'storno': fields.boolean(
+            'Storno',
+            readonly=True,
+            help=("If this is true, the debit order has been canceled "
+                  "by the bank or by the customer")),
+        }

=== added file 'account_direct_debit/model/payment_order_create.py'
--- account_direct_debit/model/payment_order_create.py	1970-01-01 00:00:00 +0000
+++ account_direct_debit/model/payment_order_create.py	2013-07-25 08:56:25 +0000
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2013 Therp BV (<http://therp.nl>).
+#            
+#    All other contributions are (C) by their respective contributors
+#
+#    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 (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import orm
+
+
+class payment_order_create(orm.TransientModel):
+    _inherit = 'payment.order.create'
+
+    def extend_payment_order_domain(
+            self, cr, uid, payment_order, domain, context=None):
+        super(payment_order_create, self).extend_payment_order_domain(
+            cr, uid, payment_order, domain, context=context)
+        if payment_order.payment_order_type == 'debit':
+            domain += [
+                ('account_id.type', '=', 'receivable'),
+                ('invoice.state', '!=', 'debit_denied'),
+                ('amount_to_receive', '>', 0),
+                ]
+        return True

=== modified file 'account_direct_debit/view/account_invoice.xml'
--- account_direct_debit/view/account_invoice.xml	2012-05-01 20:36:44 +0000
+++ account_direct_debit/view/account_invoice.xml	2013-07-25 08:56:25 +0000
@@ -4,7 +4,6 @@
         <record id="invoice_form" model="ir.ui.view">
             <field name="name">account.invoice.form</field>
             <field name="model">account.invoice</field>
-            <field name="type">form</field>
             <field name="inherit_id" ref="account.invoice_form"/>
             <field name="arch" type="xml">
                 <data>
@@ -16,14 +15,6 @@
                     <!-- button name="invoice_open" position="attributes">
                         <attribute name="states">draft,proforma2,debit_denied</attribute>
                     </button -->
-                    <button string='Re-Open' position="attributes">
-                        <attribute name="states">paid,debit_denied</attribute>
-                        <!--
-                            unintentional fix of
-                            https://bugs.launchpad.net/openobject-addons/+bug/807543
-                        -->
-                        <attribute name="groups"/>
-                    </button>
                     <button name="invoice_open" position="after">
                         <button name="invoice_debit_denied" states="paid"
                                 string="Debit Denied" icon="gtk-cancel"/>
@@ -38,7 +29,11 @@
             <field name="inherit_id" ref="account.view_account_invoice_filter"/>
             <field name="arch" type="xml">
                 <filter name="invoices" position="after">
-                    <filter name="debit_denied" icon="terp-dolar_ok!" string="Debit denied" domain="[('state','=','debit_denied')]" help="Show only invoices with state Debit denied"/>
+                    <filter name="debit_denied" icon="terp-dolar_ok!"
+                            string="Debit denied"
+                            domain="[('state','=','debit_denied')]"
+                            help="Show only invoices with state Debit denied"
+                            />
                 </filter>
             </field>
         </record>

=== modified file 'account_direct_debit/view/account_payment.xml'
--- account_direct_debit/view/account_payment.xml	2013-01-21 11:19:04 +0000
+++ account_direct_debit/view/account_payment.xml	2013-07-25 08:56:25 +0000
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <openerp>
     <data>
+
         <!-- distinguish between payment orders and debit orders in the menu -->
         <record id="account_payment.action_payment_order_tree" model="ir.actions.act_window">
             <field name="domain">[('payment_order_type', '=', 'payment')]</field>
@@ -24,7 +25,6 @@
         <record id="view_payment_order_form" model="ir.ui.view">
             <field name="name">payment.order.form</field>
             <field name="model">payment.order</field>
-            <field name="type">form</field>
             <field name="inherit_id" ref="account_payment.view_payment_order_form"/>
             <field name="priority" eval="60"/>
             <field name="arch" type="xml">
@@ -46,40 +46,13 @@
                                 icon="gtk-find"
                                 />
                     </xpath>
-                    <!-- the attrs do not work like this, apparently
-                         <xpath expr="//tree[@string='Payment Line']" position="inside">
-                             <field name="storno" attrs="{'invisible': [(parent.payment_order_type, '!=', 'debit')]}"/>
-                         </xpath>
-                    -->
                 </data>
             </field>
         </record>
 
-	<!-- Add transfer account for debit type modes -->
-	<record model="ir.ui.view" id="view_payment_mode_form">
-	  <field name="name">payment.mode.form add transfer account</field>
-	  <field name="model">payment.mode</field>
-	  <field name="inherit_id" ref="account_banking.view_payment_mode_form_inherit"/>
-	  <field name="type">form</field>
-	  <field name="arch" type="xml">
-	    <field name="type" position="after">
-	      <field name="transfer_account_id"
-                     domain="[('type', '=', 'other'),
-                              ('reconcile', '=', True),
-                              ('company_id', '=', company_id)]"
-                     />
-	      <field name="transfer_journal_id"
-                     domain="[('company_id', '=', company_id)]"
-                     />
-              <field name="payment_term_ids"/>
-	    </field>
-	  </field>
-	</record>
-
         <record id="view_payment_line_tree" model="ir.ui.view">
             <field name="name">Payment Lines</field>
             <field name="model">payment.line</field>
-            <field name="type">tree</field>
             <field name="inherit_id" ref="account_payment.view_payment_line_tree"/>
             <field eval="4" name="priority"/>
             <field name="arch" type="xml">
@@ -88,5 +61,6 @@
                 </field>
             </field>
         </record>
+
     </data>
 </openerp>

=== removed file 'account_direct_debit/workflow/account_payment.xml'
--- account_direct_debit/workflow/account_payment.xml	2013-01-02 14:45:02 +0000
+++ account_direct_debit/workflow/account_payment.xml	1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<openerp>
-    <data>
-        <!--
-            Transition to undo the payment order and reset to
-            sent, triggered by
-            cancelling a bank transaction with which the order
-            was reconciled.
-            For this, we need to cancel the flow stop on the done state,
-            unfortunately.
-            TODO: what is below is not enough. We need to inject
-            another state, 'sent_wait' between sent and done.
-        -->
-        <record id="account_payment.act_done" model="workflow.activity">
-            <field name="flow_stop" eval="False"/>
-        </record>
-
-        <record id="trans_done_sent" model="workflow.transition">
-            <field name="act_from" ref="account_payment.act_done"/>
-            <field name="act_to" ref="account_banking.act_sent"/>
-            <field name="condition">test_undo_done()</field>
-            <field name="signal">undo_done</field>
-        </record>
-    </data>
-</openerp>

=== modified file 'account_iban_preserve_domestic/__openerp__.py'
--- account_iban_preserve_domestic/__openerp__.py	2012-05-03 12:40:37 +0000
+++ account_iban_preserve_domestic/__openerp__.py	2013-07-25 08:56:25 +0000
@@ -1,60 +1,52 @@
 ##############################################################################
 #
-#    Copyright (C) 2012 Therp BV (<http://therp.nl>).
+#    Copyright (C) 2012 - 2013 Therp BV (<http://therp.nl>).
 #            
 #    All other contributions are (C) by their respective contributors
 #
 #    All Rights Reserved
 #
-#    WARNING: This program as such is intended to be used by professional
-#    programmers who take the whole responsability of assessing all potential
-#    consequences resulting from its eventual inadequacies and bugs
-#    End users who are looking for a ready-to-use solution with commercial
-#    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 General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
+
 {
     'name': 'Domestic bank account number',
-    'version': '0.1.134',
+    'version': '0.1.163',
     'license': 'AGPL-3',
     'author': 'Therp BV',
     'website': 'https://launchpad.net/banking-addons',
     'category': 'Banking addons',
-    'depends': ['base_iban','account'],
-    'init_xml': [],
-    'update_xml': [
+    'depends': [
+        'base_iban',
+        'account',
+        ],
+    'data': [
         'res_partner_bank_view.xml'
         ],
-    'demo_xml': [],
     'description': '''
-This module is compatible with OpenERP 6.1.
+This module is compatible with OpenERP 7.0.
 
-The IBAN module in OpenERP 6.1 registers the IBAN
+The IBAN module in OpenERP 6.1/7.0 registers the IBAN
 on the same field as the domestic account number, 
 instead of keeping both on separate fields as is the
 case in 6.0.
 
 This module adds a field to register the domestic account
-number on IBANs, while the domestic account number is
-still widely in use in certain regions.
-
-Note that an upgrade to OpenERP 6.1 makes you lose the
-domestic account numbers on IBANs that were already in 
-your system, unless you installed the 6.0 version of this
-module prior to the upgrade to OpenERP 6.1. 
+number on IBANs, as the domestic account number is
+still in use in certain regions. This should make for a
+smoother migration to SEPA.
     ''',
     'active': False,
     'installable': True,

=== modified file 'account_iban_preserve_domestic/res_partner_bank.py'
--- account_iban_preserve_domestic/res_partner_bank.py	2012-04-14 08:58:58 +0000
+++ account_iban_preserve_domestic/res_partner_bank.py	2013-07-25 08:56:25 +0000
@@ -1,5 +1,28 @@
-from osv import fields,osv
-class res_partner_bank(osv.osv):
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This module copyright (C) 2012 - 2013 Therp BV (<http://therp.nl>).
+#
+#    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 (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import fields, orm
+
+
+class res_partner_bank(orm.Model):
     ''' Adds a field for domestic account numbers '''
     _inherit = "res.partner.bank"
 

=== modified file 'account_iban_preserve_domestic/res_partner_bank_view.xml'
--- account_iban_preserve_domestic/res_partner_bank_view.xml	2012-02-19 21:10:20 +0000
+++ account_iban_preserve_domestic/res_partner_bank_view.xml	2013-07-25 08:56:25 +0000
@@ -18,20 +18,5 @@
             </field>
         </record>
 
-        <!-- add the field to the partner form, as defined in 
-        the account module -->
-        <record id="view_partner_account_form" model="ir.ui.view">
-            <field name="name">res.partner.account.form</field>
-            <field name="model">res.partner</field>
-            <field name="inherit_id" ref="account.view_partner_property_form"/>
-            <field name="arch" type="xml">
-                <field name="acc_number" position="after">
-                    <newline/>
-                    <field name="acc_number_domestic"
-                           attrs="{'invisible': [('state', '!=', 'iban')]}"
-                           />
-                </field>
-            </field>
-        </record>
     </data>
 </openerp>

=== modified file 'account_payment_shortcut/__init__.py'
--- account_payment_shortcut/__init__.py	2011-12-09 13:07:52 +0000
+++ account_payment_shortcut/__init__.py	2013-07-25 08:56:25 +0000
@@ -1,1 +1,2 @@
+# -*- coding: utf-8 -*-
 import payment_order

=== modified file 'account_payment_shortcut/__openerp__.py'
--- account_payment_shortcut/__openerp__.py	2012-05-03 12:40:37 +0000
+++ account_payment_shortcut/__openerp__.py	2013-07-25 08:56:25 +0000
@@ -4,41 +4,30 @@
 #                  2011 Smile BV (<http://smile.fr>).
 #    All Rights Reserved
 #
-#    WARNING: This program as such is intended to be used by professional
-#    programmers who take the whole responsability of assessing all potential
-#    consequences resulting from its eventual inadequacies and bugs
-#    End users who are looking for a ready-to-use solution with commercial
-#    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 General Public License as published by
+#    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,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
 {
     'name': 'Account Payment Invoice Selection Shortcut',
     'version': '6.1.1.134',
-    'license': 'GPL-3',
+    'license': 'AGPL-3',
     'author': 'Smile / Therp BV',
     'website': 'https://launchpad.net/banking-addons',
     'category': 'Banking addons',
     'depends': ['account_payment'],
-    'init_xml': [],
-    'update_xml': [
-    ],
-    'demo_xml': [],
     'description': '''
 When composing a payment order, select all candidates by default (in the second step of the "Select invoices to pay" wizard).
     ''',
-    'active': False,
-    'installable': True,
+    'installable': False,
 }

=== modified file 'account_payment_shortcut/payment_order.py'
--- account_payment_shortcut/payment_order.py	2011-12-09 13:07:52 +0000
+++ account_payment_shortcut/payment_order.py	2013-07-25 08:56:25 +0000
@@ -1,8 +1,30 @@
 # -*- coding: utf-8 -*-
-from osv import osv, fields
-
-class payment_order_create(osv.osv_memory):
-
+##############################################################################
+#
+#    Copyright (C) 2011 - 2013 Therp BV (<http://therp.nl>).
+#            
+#    All other contributions are (C) by their respective contributors
+#
+#    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 (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import orm
+
+class payment_order_create(orm.TransientModel):
     _inherit = 'payment.order.create'
 
     def default_get(self, cr, uid, fields_list, context=None):
@@ -27,5 +49,3 @@
             res['entries'] = context['line_ids']
 
         return res
-
-payment_order_create()

=== modified file 'bank_statement_instant_voucher/model/account_bank_statement_line.py'
--- bank_statement_instant_voucher/model/account_bank_statement_line.py	2012-12-05 20:16:14 +0000
+++ bank_statement_instant_voucher/model/account_bank_statement_line.py	2013-07-25 08:56:25 +0000
@@ -2,7 +2,7 @@
 ##############################################################################
 #
 #    OpenERP, Open Source Management Solution
-#    This module copyright (C) 2012 Therp BV (<http://therp.nl>).
+#    This module copyright (C) 2012 - 2013 Therp BV (<http://therp.nl>).
 #
 #    This program is free software: you can redistribute it and/or modify
 #    it under the terms of the GNU Affero General Public License as
@@ -19,10 +19,10 @@
 #
 ##############################################################################
 
-from openerp.osv import osv, fields
-
-
-class account_bank_statement_line(osv.Model):
+from openerp.osv import orm, fields
+
+
+class account_bank_statement_line(orm.Model):
     _inherit = 'account.bank.statement.line'
     def create_instant_voucher(self, cr, uid, ids, context=None):
         res = False

=== modified file 'bank_statement_instant_voucher/model/account_voucher_instant.py'
--- bank_statement_instant_voucher/model/account_voucher_instant.py	2012-12-05 20:16:14 +0000
+++ bank_statement_instant_voucher/model/account_voucher_instant.py	2013-07-25 08:56:25 +0000
@@ -2,7 +2,7 @@
 ##############################################################################
 #
 #    OpenERP, Open Source Management Solution
-#    This module copyright (C) 2012 Therp BV (<http://therp.nl>).
+#    This module copyright (C) 2012 - 2013 Therp BV (<http://therp.nl>).
 #
 #    This program is free software: you can redistribute it and/or modify
 #    it under the terms of the GNU Affero General Public License as
@@ -19,12 +19,12 @@
 #
 ##############################################################################
 
-from openerp.osv import osv, fields
+from openerp.osv import orm, fields
 from openerp.tools.translate import _
 from openerp.addons.decimal_precision import decimal_precision as dp
 
 
-class instant_voucher(osv.TransientModel):
+class instant_voucher(orm.TransientModel):
     _name = 'account.voucher.instant'
     _description = 'Instant Voucher'
 
@@ -76,7 +76,7 @@
             cr, uid, [('company_id', '=', line.company_id.id),
                       ('type', '=', voucher_type)])
         if not journal_ids:
-            osv.exept_osv(
+            orm.exept_orm(
                 _('Error'),
                 _('No %s journal defined') % voucher_type)
                
@@ -156,7 +156,7 @@
                 context.get('active_id') or
                 context.get('active_ids') and context.get('active_ids')[0])
             if not res['statement_line_id']:
-                raise osv.except_osv(
+                raise orm.except_orm(
                     _('Error'),
                     _('Cannot determine statement line'))
             line = self.pool.get('account.bank.statement.line').browse(
@@ -212,7 +212,7 @@
                             instant.voucher_id.company_id.currency_id)
         if (instant.statement_line_id.statement_id.currency.id !=
             voucher_currency.id):
-            raise osv.except_osv(
+            raise orm.except_orm(
                 _("Error"),
                 _("Currency on the bank statement line needs to be the "
                   "same as on the voucher. Currency conversion is not yet "
@@ -222,7 +222,7 @@
                 cr, uid, [instant.voucher_id.id], context=context)
             instant.refresh()
             if instant.voucher_id.state != 'posted':
-                raise osv.except_osv(
+                raise orm.except_orm(
                     _("Error"),
                     _("The voucher could not be posted."))
         if instant.voucher_id.move_id.state != 'posted':
@@ -230,12 +230,12 @@
                 cr, uid, [instant.voucher_id.move_id.id], context=context)
             instant.refresh()
             if instant.voucher_id.move_id.state != 'posted':
-                raise osv.except_osv(
+                raise orm.except_orm(
                     _("Error"),
                     _("The voucher's move line could not be posted."))
         if not self.pool.get('res.currency').is_zero(
             cr, uid, voucher_currency, instant.balance):
-            raise osv.except_osv(
+            raise orm.except_orm(
                 _("Error"),
                 _("The amount on the bank statement line needs to be the "
                   "same as on the voucher. Write-off is not yet "
@@ -245,7 +245,7 @@
         # and trigger its posting and reconciliation.
         if 'import_transaction_id' in statement_line_obj._columns:
             if instant.statement_line_id.state == 'confirmed':
-                raise osv.except_osv(
+                raise orm.except_orm(
                     _("Error"),
                     _("Cannot match a confirmed statement line"))
             if not instant.statement_line_id.import_transaction_id:

=== modified file 'bank_statement_instant_voucher/view/account_bank_statement_line.xml'
--- bank_statement_instant_voucher/view/account_bank_statement_line.xml	2012-11-28 13:49:36 +0000
+++ bank_statement_instant_voucher/view/account_bank_statement_line.xml	2013-07-25 08:56:25 +0000
@@ -5,7 +5,6 @@
             <field name="name">Add instant voucher button to bank statement line on statement form</field>
             <field name="inherit_id" ref="account.view_bank_statement_form" />
             <field name="model">account.bank.statement</field>
-            <field name="type">form</field>
             <field name="priority" eval="30"/>
             <field name="arch" type="xml">
                 <xpath expr="/form/notebook/page/field[@name='line_ids']/tree/field[@name='voucher_id']"

=== modified file 'bank_statement_instant_voucher/view/account_voucher_instant.xml'
--- bank_statement_instant_voucher/view/account_voucher_instant.xml	2012-11-28 13:49:36 +0000
+++ bank_statement_instant_voucher/view/account_voucher_instant.xml	2013-07-25 08:56:25 +0000
@@ -4,7 +4,6 @@
         <record id="instant_voucher_form" model="ir.ui.view">
             <field name="name">Instant voucher form view</field>
             <field name="model">account.voucher.instant</field>
-            <field name="type">form</field>
             <field name="arch" type="xml">
                 <form>
                     <field name="state" invisible="1" readonly="1"/>


Follow ups