← Back to team overview

credativ team mailing list archive

[Merge] lp:~jamesj/banking-addons/hsbc-client-id into lp:banking-addons

 

James Jesudason has proposed merging lp:~jamesj/banking-addons/hsbc-client-id into lp:banking-addons.

Requested reviews:
  Banking Addons Team (banking-addons-team)

For more details, see:
https://code.launchpad.net/~jamesj/banking-addons/hsbc-client-id/+merge/93254
-- 
https://code.launchpad.net/~jamesj/banking-addons/hsbc-client-id/+merge/93254
Your team Banking Addons Team is requested to review the proposed merge of lp:~jamesj/banking-addons/hsbc-client-id into lp:banking-addons.
=== modified file 'account_banking_uk_hsbc/__init__.py'
--- account_banking_uk_hsbc/__init__.py	2011-10-31 10:59:25 +0000
+++ account_banking_uk_hsbc/__init__.py	2012-02-15 17:33:24 +0000
@@ -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:

=== modified file 'account_banking_uk_hsbc/__openerp__.py'
--- account_banking_uk_hsbc/__openerp__.py	2011-11-18 17:41:16 +0000
+++ account_banking_uk_hsbc/__openerp__.py	2012-02-15 17:33:24 +0000
@@ -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': '''

=== added file 'account_banking_uk_hsbc/hsbc_clientid.py'
--- account_banking_uk_hsbc/hsbc_clientid.py	1970-01-01 00:00:00 +0000
+++ account_banking_uk_hsbc/hsbc_clientid.py	2012-02-15 17:33:24 +0000
@@ -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()
+

=== added file 'account_banking_uk_hsbc/hsbc_clientid_view.xml'
--- account_banking_uk_hsbc/hsbc_clientid_view.xml	1970-01-01 00:00:00 +0000
+++ account_banking_uk_hsbc/hsbc_clientid_view.xml	2012-02-15 17:33:24 +0000
@@ -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>
\ No newline at end of file

=== added directory 'account_banking_uk_hsbc/security'
=== added file 'account_banking_uk_hsbc/security/ir.model.access.csv'
--- account_banking_uk_hsbc/security/ir.model.access.csv	1970-01-01 00:00:00 +0000
+++ account_banking_uk_hsbc/security/ir.model.access.csv	2012-02-15 17:33:24 +0000
@@ -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
+

=== modified file 'account_banking_uk_hsbc/wizard/export_hsbc.py'
--- account_banking_uk_hsbc/wizard/export_hsbc.py	2012-01-11 18:21:15 +0000
+++ account_banking_uk_hsbc/wizard/export_hsbc.py	2012-02-15 17:33:24 +0000
@@ -298,8 +298,10 @@
         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 @@
 
         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)