From 7461ef99f841a5a9a089c5bae7f60f86175a1055 Mon Sep 17 00:00:00 2001 From: James Jesudason Date: Wed, 15 Feb 2012 17:15:52 +0000 Subject: [PATCH] Added ability to store the HSBC Client ID for HSBCNet, and use that on the payment files. --- account_banking_uk_hsbc/__init__.py | 1 + account_banking_uk_hsbc/__openerp__.py | 2 + account_banking_uk_hsbc/hsbc_clientid.py | 48 ++++++++++++ .../hsbc_clientid_view.xml | 76 +++++++++++++++++++ .../security/ir.model.access.csv | 3 + account_banking_uk_hsbc/wizard/export_hsbc.py | 4 +- 6 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 account_banking_uk_hsbc/hsbc_clientid.py create mode 100644 account_banking_uk_hsbc/hsbc_clientid_view.xml create mode 100644 account_banking_uk_hsbc/security/ir.model.access.csv 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/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..7eaa6406f 100644 --- a/account_banking_uk_hsbc/wizard/export_hsbc.py +++ b/account_banking_uk_hsbc/wizard/export_hsbc.py @@ -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)