diff --git a/account_banking/account_banking.py b/account_banking/account_banking.py index f2f0d4438..df3cae2c5 100644 --- a/account_banking/account_banking.py +++ b/account_banking/account_banking.py @@ -1135,7 +1135,7 @@ class res_partner_bank(osv.osv): ''' Create dual function IBAN account for SEPA countries ''' - return self._founder.create(self, cursor, uid, + return self._founder.create(cursor, uid, self._correct_IBAN(vals), context ) @@ -1143,7 +1143,7 @@ class res_partner_bank(osv.osv): ''' Create dual function IBAN account for SEPA countries ''' - return self._founder.write(self, cursor, uid, ids, + return self._founder.write(cursor, uid, ids, self._correct_IBAN(vals), context ) @@ -1207,7 +1207,7 @@ class res_partner_bank(osv.osv): newargs = extended_search_expression(args) # Original search (_founder) - results = self._founder.search(self, cursor, uid, newargs, + results = self._founder.search(cursor, uid, newargs, *rest, **kwargs ) return results @@ -1216,7 +1216,7 @@ class res_partner_bank(osv.osv): ''' Convert IBAN electronic format to IBAN display format ''' - records = self._founder.read(self, *args, **kwargs) + records = self._founder.read(*args, **kwargs) if not isinstance(records, list): records = [records,] for record in records: @@ -1239,6 +1239,7 @@ class res_partner_bank(osv.osv): ''' Return the local bank account number aka BBAN from the IBAN. ''' + res = {} for record in self.browse(cursor, uid, ids, context): if not record.iban: res[record.id] = False @@ -1247,7 +1248,7 @@ class res_partner_bank(osv.osv): try: res[record.id] = iban_acc.localized_BBAN except NotImplementedError: - res[record_id] = False + res[record.id] = False return res def onchange_acc_number(self, cursor, uid, ids, acc_number, @@ -1264,6 +1265,7 @@ class res_partner_bank(osv.osv): values = {} country_obj = self.pool.get('res.country') country_ids = [] + country = False # Pre fill country based on available data. This is just a default # which can be overridden by the user. @@ -1294,12 +1296,8 @@ class res_partner_bank(osv.osv): # the handling user if not country_ids: user = self.pool.get('res.users').browse(cursor, uid, uid) - # Try users address first - if user.address_id and user.address_id.country_id: - country = user.address_id.country_id - country_ids = [country.id] - # Last try user companies partner - elif (user.company_id and + # Try user companies partner (user no longer has address in 6.1) + if (user.company_id and user.company_id.partner_id and user.company_id.partner_id.country ): @@ -1316,7 +1314,7 @@ class res_partner_bank(osv.osv): ) result = {'value': values} # Complete data with online database when available - if country.code in sepa.IBAN.countries: + if partner_id and country.code in sepa.IBAN.countries: try: info = sepa.online.account_info(country.code, acc_number) if info: diff --git a/account_banking/account_banking_view.xml b/account_banking/account_banking_view.xml index a6778fe67..aa3dd1ef1 100644 --- a/account_banking/account_banking_view.xml +++ b/account_banking/account_banking_view.xml @@ -120,6 +120,16 @@ + + account.banking.imported.line.search + account.bank.imported.line + search + + + + + + Imported Bank Statements Files ir.actions.act_window @@ -345,7 +355,7 @@ - + res.partner.bank.form.banking-2 res.partner.bank @@ -364,12 +374,15 @@ + + + - + res.partner.form.banking-2 res.partner @@ -388,7 +401,10 @@ - + + + + @@ -399,6 +415,7 @@ + diff --git a/account_banking/banking_import_transaction.py b/account_banking/banking_import_transaction.py index 0b9636fa7..fc52f7e64 100644 --- a/account_banking/banking_import_transaction.py +++ b/account_banking/banking_import_transaction.py @@ -1378,6 +1378,7 @@ class banking_import_transaction(osv.osv): if (not values['partner_bank_id'] and partner_banks and 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), @@ -1391,6 +1392,7 @@ class banking_import_transaction(osv.osv): 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 diff --git a/account_banking/data/account_banking_data.xml b/account_banking/data/account_banking_data.xml index 8906d6c34..86a568696 100644 --- a/account_banking/data/account_banking_data.xml +++ b/account_banking/data/account_banking_data.xml @@ -1,6 +1,14 @@ + + + iban + + + + + diff --git a/account_banking/wizard/banktools.py b/account_banking/wizard/banktools.py index 2cf28c79c..2a66a740a 100644 --- a/account_banking/wizard/banktools.py +++ b/account_banking/wizard/banktools.py @@ -242,6 +242,7 @@ def get_company_bank_account(pool, cursor, uid, account_number, currency, results.costs_account_id = settings.costs_account_id results.invoice_journal_id = settings.invoice_journal_id results.bank_partner_id = settings.bank_partner_id + return results def get_or_create_bank(pool, cursor, uid, bic, online=False, code=None, @@ -261,7 +262,7 @@ def get_or_create_bank(pool, cursor, uid, bic, online=False, code=None, # search key bank_ids = bank_obj.search( cursor, uid, [ - ('code', '=', bic[:6]) + ('bic', '=', bic[:6]) ]) if not bank_ids: bank_ids = bank_obj.search( diff --git a/account_banking_uk_hsbc/__init__.py b/account_banking_uk_hsbc/__init__.py index b9c3e7a5e..887cb5d93 100644 --- a/account_banking_uk_hsbc/__init__.py +++ b/account_banking_uk_hsbc/__init__.py @@ -22,4 +22,5 @@ import account_banking_uk_hsbc import wizard import hsbc_mt940 +import hsbc_clientid # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_banking_uk_hsbc/__openerp__.py b/account_banking_uk_hsbc/__openerp__.py index f1a2fc471..b20aa9bdf 100644 --- a/account_banking_uk_hsbc/__openerp__.py +++ b/account_banking_uk_hsbc/__openerp__.py @@ -29,8 +29,10 @@ 'init_xml': [], 'update_xml': [ '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': ''' diff --git a/account_banking_uk_hsbc/hsbc_clientid.py b/account_banking_uk_hsbc/hsbc_clientid.py new file mode 100644 index 000000000..84acd5c05 --- /dev/null +++ b/account_banking_uk_hsbc/hsbc_clientid.py @@ -0,0 +1,48 @@ +# -*- encoding: utf-8 -*- +from osv import osv, fields + +class hsbc_clientid(osv.osv): + """ + Record to hold the HSBCNet Client ID for the company. + """ + _name = 'banking.hsbc.clientid' + _description = 'HSBC Client ID' + + _columns = { + 'name': fields.char('Name', size=64, required=True), + 'clientid': fields.char('Client ID', size=20, required=True), + 'company_id': fields.many2one('res.company','Company', required=True), + } + + _defaults = { + 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, + } + +hsbc_clientid() + + +class payment_order(osv.osv): + _name = 'payment.order' + _inherit = 'payment.order' + + _columns = { + 'hsbc_clientid_id': fields.many2one('banking.hsbc.clientid', 'HSBC Client ID', required=True), + } + + + def _default_hsbc_clientid(self, cr, uid, context=None): + company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id + + clientid_ids = self.pool.get('banking.hsbc.clientid').search(cr, uid, [('company_id','=',company_id)]) + if len(clientid_ids)==0: + return False + else: + return clientid_ids[0] + + + _defaults = { + 'hsbc_clientid_id':_default_hsbc_clientid, + } + +payment_order() + diff --git a/account_banking_uk_hsbc/hsbc_clientid_view.xml b/account_banking_uk_hsbc/hsbc_clientid_view.xml new file mode 100644 index 000000000..db579d59e --- /dev/null +++ b/account_banking_uk_hsbc/hsbc_clientid_view.xml @@ -0,0 +1,76 @@ + + + + + + + payment.order.form + payment.order + form + + + + + + + + + + + + banking.hsbc.clientid.form + banking.hsbc.clientid + form + +
+ + + + + +
+
+
+ + + + banking.hsbc.clientid.tree + banking.hsbc.clientid + tree + + + + + + + + + + + + banking.hsbc.clientid.filter + banking.hsbc.clientid + search + + + + + + + + + + + + HSBC Client ID + banking.hsbc.clientid + form + tree,form + + + + + + +
+
\ No newline at end of file diff --git a/account_banking_uk_hsbc/hsbc_mt940.py b/account_banking_uk_hsbc/hsbc_mt940.py index 510147de4..c9d208d1a 100644 --- a/account_banking_uk_hsbc/hsbc_mt940.py +++ b/account_banking_uk_hsbc/hsbc_mt940.py @@ -121,7 +121,7 @@ class statement(models.mem_bank_statement): transaction = self.transactions[-1] - transaction.id = ','.join([record[k] for k in ['infoline{0}'.format(i) for i in range(1,5)] if record.has_key(k)]) + transaction.reference = ','.join([record[k] for k in ['infoline{0}'.format(i) for i in range(1,5)] if record.has_key(k)]) def raise_error(message, line): raise osv.except_osv(_('Import error'), @@ -136,7 +136,7 @@ class parser_hsbc_mt940(models.parser): the HSBC web interface. ''') - def parse(self, data): + def parse(self, cr, data): result = [] parser = HSBCParser() # Split into statements @@ -156,6 +156,7 @@ class parser_hsbc_mt940(models.parser): print "Invalid Statement:" print records[0] + return result # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_banking_uk_hsbc/mt940_parser.py b/account_banking_uk_hsbc/mt940_parser.py index d4a6a2ba0..4cfd7ffbe 100644 --- a/account_banking_uk_hsbc/mt940_parser.py +++ b/account_banking_uk_hsbc/mt940_parser.py @@ -124,7 +124,7 @@ class HSBCParser(object): return matchdict - def parse(self, data): + def parse(self, cr, data): records = [] # Some records are multiline for line in data: diff --git a/account_banking_uk_hsbc/security/ir.model.access.csv b/account_banking_uk_hsbc/security/ir.model.access.csv new file mode 100644 index 000000000..42495678f --- /dev/null +++ b/account_banking_uk_hsbc/security/ir.model.access.csv @@ -0,0 +1,3 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +"access_banking_hsbc_clientid","banking.hsbc.clientid","model_banking_hsbc_clientid","account_payment.group_account_payment",1,1,1,1 + diff --git a/account_banking_uk_hsbc/wizard/export_hsbc.py b/account_banking_uk_hsbc/wizard/export_hsbc.py index 72ffe43e9..08fc64d85 100644 --- a/account_banking_uk_hsbc/wizard/export_hsbc.py +++ b/account_banking_uk_hsbc/wizard/export_hsbc.py @@ -132,7 +132,7 @@ class banking_export_hsbc_wizard(osv.osv_memory): wizard_data.update({ 'execution_date_create': strfdate(execution_date), 'reference': reference, - 'payment_order_ids': [[6, 0, po_ids]], + 'payment_order_ids': [(6, 0, po_ids)], 'state': 'create', }) @@ -298,8 +298,10 @@ class banking_export_hsbc_wizard(osv.osv_memory): try: self.logger.notifyChannel('paymul', netsvc.LOG_INFO, 'Create transactions...') transactions = [] + hsbc_clientid = '' for po in payment_orders: transactions += [self._create_transaction(l) for l in po.line_ids] + hsbc_clientid = po.hsbc_clientid_id.clientid batch = paymul.Batch( exec_date=strpdate(wizard_data.execution_date_create), @@ -328,7 +330,7 @@ class banking_export_hsbc_wizard(osv.osv_memory): message = paymul.Message(reference=ref) message.batches.append(batch) - interchange = paymul.Interchange(client_id='CLIENTID', + interchange = paymul.Interchange(client_id=hsbc_clientid, reference=ref, message=message)