[MERGE] Added ability to store the HSBC Client ID for HSBCNet

This commit is contained in:
James Jesudason
2012-03-19 14:46:40 +00:00
committed by Dmitrijs Ledkovs (credativ)
6 changed files with 133 additions and 1 deletions

View File

@@ -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:

View File

@@ -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': '''

View File

@@ -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()

View File

@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Add the HSBC Client ID to the Payment Order -->
<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="arch" type="xml">
<field name="date_scheduled" position="after">
<field name="hsbc_clientid_id" />
</field>
</field>
</record>
<!-- Form view for HSBC Client ID -->
<record id="banking_hsbc_clientid_form" model="ir.ui.view">
<field name="name">banking.hsbc.clientid.form</field>
<field name="model">banking.hsbc.clientid</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="HSBC Client ID">
<group colspan="4">
<field name="name" />
<field name="company_id" />
<field name="clientid" />
</group>
</form>
</field>
</record>
<!-- Tree view for HSBC Client ID -->
<record id="banking_hsbc_clientid_tree" model="ir.ui.view">
<field name="name">banking.hsbc.clientid.tree</field>
<field name="model">banking.hsbc.clientid</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="HSBC Client IDs">
<field name="name" />
<field name="company_id" />
<field name="clientid" />
</tree>
</field>
</record>
<!-- Search view for HSBC Client ID -->
<record id="banking_hsbc_clientid_filter" model="ir.ui.view">
<field name="name">banking.hsbc.clientid.filter</field>
<field name="model">banking.hsbc.clientid</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="HSBC Client IDs">
<field name="name"/>
<field name="company_id" />
<field name="clientid" />
</search>
</field>
</record>
<!-- Action for HSBC Client ID -->
<record id="banking_hsbc_clientid_action" model="ir.actions.act_window">
<field name="name">HSBC Client ID</field>
<field name="res_model">banking.hsbc.clientid</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="banking_hsbc_clientid_filter"/>
</record>
<!-- Menu for HSBC Client ID -->
<menuitem action="banking_hsbc_clientid_action" id="banking_hsbc_clientid_menu" parent="account.menu_configuration_misc"/>
</data>
</openerp>

View File

@@ -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
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_banking_hsbc_clientid banking.hsbc.clientid model_banking_hsbc_clientid account_payment.group_account_payment 1 1 1 1

View File

@@ -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)