mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[ADD] Ability to store the HSBC Client ID for HSBCNet, and use that on the payment files
[FIX] Upgrading to version 6.1
This commit is contained in:
@@ -1135,7 +1135,7 @@ class res_partner_bank(osv.osv):
|
|||||||
'''
|
'''
|
||||||
Create dual function IBAN account for SEPA countries
|
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
|
self._correct_IBAN(vals), context
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1143,7 +1143,7 @@ class res_partner_bank(osv.osv):
|
|||||||
'''
|
'''
|
||||||
Create dual function IBAN account for SEPA countries
|
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
|
self._correct_IBAN(vals), context
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1207,7 +1207,7 @@ class res_partner_bank(osv.osv):
|
|||||||
newargs = extended_search_expression(args)
|
newargs = extended_search_expression(args)
|
||||||
|
|
||||||
# Original search (_founder)
|
# Original search (_founder)
|
||||||
results = self._founder.search(self, cursor, uid, newargs,
|
results = self._founder.search(cursor, uid, newargs,
|
||||||
*rest, **kwargs
|
*rest, **kwargs
|
||||||
)
|
)
|
||||||
return results
|
return results
|
||||||
@@ -1216,7 +1216,7 @@ class res_partner_bank(osv.osv):
|
|||||||
'''
|
'''
|
||||||
Convert IBAN electronic format to IBAN display format
|
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):
|
if not isinstance(records, list):
|
||||||
records = [records,]
|
records = [records,]
|
||||||
for record in 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.
|
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(cursor, uid, ids, context):
|
||||||
if not record.iban:
|
if not record.iban:
|
||||||
res[record.id] = False
|
res[record.id] = False
|
||||||
@@ -1247,7 +1248,7 @@ class res_partner_bank(osv.osv):
|
|||||||
try:
|
try:
|
||||||
res[record.id] = iban_acc.localized_BBAN
|
res[record.id] = iban_acc.localized_BBAN
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
res[record_id] = False
|
res[record.id] = False
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def onchange_acc_number(self, cursor, uid, ids, acc_number,
|
def onchange_acc_number(self, cursor, uid, ids, acc_number,
|
||||||
@@ -1264,6 +1265,7 @@ class res_partner_bank(osv.osv):
|
|||||||
values = {}
|
values = {}
|
||||||
country_obj = self.pool.get('res.country')
|
country_obj = self.pool.get('res.country')
|
||||||
country_ids = []
|
country_ids = []
|
||||||
|
country = False
|
||||||
|
|
||||||
# Pre fill country based on available data. This is just a default
|
# Pre fill country based on available data. This is just a default
|
||||||
# which can be overridden by the user.
|
# which can be overridden by the user.
|
||||||
@@ -1294,12 +1296,8 @@ class res_partner_bank(osv.osv):
|
|||||||
# the handling user
|
# the handling user
|
||||||
if not country_ids:
|
if not country_ids:
|
||||||
user = self.pool.get('res.users').browse(cursor, uid, uid)
|
user = self.pool.get('res.users').browse(cursor, uid, uid)
|
||||||
# Try users address first
|
# Try user companies partner (user no longer has address in 6.1)
|
||||||
if user.address_id and user.address_id.country_id:
|
if (user.company_id and
|
||||||
country = user.address_id.country_id
|
|
||||||
country_ids = [country.id]
|
|
||||||
# Last try user companies partner
|
|
||||||
elif (user.company_id and
|
|
||||||
user.company_id.partner_id and
|
user.company_id.partner_id and
|
||||||
user.company_id.partner_id.country
|
user.company_id.partner_id.country
|
||||||
):
|
):
|
||||||
@@ -1316,7 +1314,7 @@ class res_partner_bank(osv.osv):
|
|||||||
)
|
)
|
||||||
result = {'value': values}
|
result = {'value': values}
|
||||||
# Complete data with online database when available
|
# 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:
|
try:
|
||||||
info = sepa.online.account_info(country.code, acc_number)
|
info = sepa.online.account_info(country.code, acc_number)
|
||||||
if info:
|
if info:
|
||||||
|
|||||||
@@ -120,6 +120,16 @@
|
|||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</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">
|
<record model="ir.actions.act_window" id="action_account_banking_imported_files">
|
||||||
<field name="name">Imported Bank Statements Files</field>
|
<field name="name">Imported Bank Statements Files</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
@@ -345,7 +355,7 @@
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- Set trigger on IBAN and acc_number fields in res_partner_bank form -->
|
<!-- Set trigger on IBAN and acc_number fields in res_partner_bank form -->
|
||||||
<record id="view_partner_bank_account_banking_form_1" model="ir.ui.view">
|
<!--record id="view_partner_bank_account_banking_form_1" model="ir.ui.view">
|
||||||
<field name="name">res.partner.bank.form.banking-1</field>
|
<field name="name">res.partner.bank.form.banking-1</field>
|
||||||
<field name="model">res.partner.bank</field>
|
<field name="model">res.partner.bank</field>
|
||||||
<field name="inherit_id" ref="base_iban.view_partner_bank_iban_form"/>
|
<field name="inherit_id" ref="base_iban.view_partner_bank_iban_form"/>
|
||||||
@@ -355,7 +365,7 @@
|
|||||||
<field name="iban" on_change="onchange_iban(iban)" />
|
<field name="iban" on_change="onchange_iban(iban)" />
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record-->
|
||||||
<record id="view_partner_bank_account_banking_form_2" model="ir.ui.view">
|
<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="name">res.partner.bank.form.banking-2</field>
|
||||||
<field name="model">res.partner.bank</field>
|
<field name="model">res.partner.bank</field>
|
||||||
@@ -364,12 +374,15 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="acc_number" position="replace">
|
<field name="acc_number" position="replace">
|
||||||
<field name="acc_number" on_change="onchange_acc_number(acc_number, partner_id, country_id)"/>
|
<field name="acc_number" on_change="onchange_acc_number(acc_number, partner_id, country_id)"/>
|
||||||
|
<newline />
|
||||||
|
<field name="iban" on_change="onchange_iban(iban)" />
|
||||||
|
<newline />
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- Set trigger on IBAN and acc_number field in res_partner form -->
|
<!-- Set trigger on IBAN and acc_number field in res_partner form -->
|
||||||
<record id="view_partner_account_banking_form_1" model="ir.ui.view">
|
<!--record id="view_partner_account_banking_form_1" model="ir.ui.view">
|
||||||
<field name="name">res.partner.form.banking-1</field>
|
<field name="name">res.partner.form.banking-1</field>
|
||||||
<field name="model">res.partner</field>
|
<field name="model">res.partner</field>
|
||||||
<field name="inherit_id" ref="base_iban.view_partner_iban_form"/>
|
<field name="inherit_id" ref="base_iban.view_partner_iban_form"/>
|
||||||
@@ -379,7 +392,7 @@
|
|||||||
<field name="iban" on_change="onchange_iban(iban)" />
|
<field name="iban" on_change="onchange_iban(iban)" />
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record-->
|
||||||
<record id="view_partner_account_banking_form_2" model="ir.ui.view">
|
<record id="view_partner_account_banking_form_2" model="ir.ui.view">
|
||||||
<field name="name">res.partner.form.banking-2</field>
|
<field name="name">res.partner.form.banking-2</field>
|
||||||
<field name="model">res.partner</field>
|
<field name="model">res.partner</field>
|
||||||
@@ -388,7 +401,10 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="/form/notebook/page/field[@name='bank_ids']/form/field[@name='acc_number']" position="replace">
|
<xpath expr="/form/notebook/page/field[@name='bank_ids']/form/field[@name='acc_number']" position="replace">
|
||||||
<field name="acc_number" on_change="onchange_acc_number(acc_number, parent.id, country_id)" />
|
<field name="acc_number" on_change="onchange_acc_number(acc_number, parent.id, country_id)" />
|
||||||
</xpath>
|
<newline />
|
||||||
|
<field name="iban" on_change="onchange_iban(iban)" />
|
||||||
|
<newline />
|
||||||
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
<record id="view_partner_account_banking_form_3" model="ir.ui.view">
|
<record id="view_partner_account_banking_form_3" model="ir.ui.view">
|
||||||
@@ -399,6 +415,7 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="/form/notebook/page/field[@name='bank_ids']/tree/field[@name='acc_number']" position="replace">
|
<xpath expr="/form/notebook/page/field[@name='bank_ids']/tree/field[@name='acc_number']" position="replace">
|
||||||
<field name="acc_number" on_change="onchange_acc_number(acc_number, parent.id, country_id)" select="1" />
|
<field name="acc_number" on_change="onchange_acc_number(acc_number, parent.id, country_id)" select="1" />
|
||||||
|
<field name="iban" on_change="onchange_iban(iban)" />
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
@@ -1378,6 +1378,7 @@ class banking_import_transaction(osv.osv):
|
|||||||
if (not values['partner_bank_id'] and partner_banks and
|
if (not values['partner_bank_id'] and partner_banks and
|
||||||
len(partner_banks) == 1):
|
len(partner_banks) == 1):
|
||||||
values['partner_bank_id'] = partner_banks[0].id
|
values['partner_bank_id'] = partner_banks[0].id
|
||||||
|
|
||||||
if not transaction.statement_line_id:
|
if not transaction.statement_line_id:
|
||||||
values.update(dict(
|
values.update(dict(
|
||||||
name = '%s.%s' % (transaction.statement, transaction.transaction),
|
name = '%s.%s' % (transaction.statement, transaction.transaction),
|
||||||
@@ -1391,6 +1392,7 @@ class banking_import_transaction(osv.osv):
|
|||||||
account_id = account_id,
|
account_id = account_id,
|
||||||
import_transaction_id = transaction.id,
|
import_transaction_id = transaction.id,
|
||||||
))
|
))
|
||||||
|
|
||||||
statement_line_id = statement_line_obj.create(cr, uid, values, context)
|
statement_line_id = statement_line_obj.create(cr, uid, values, context)
|
||||||
results['trans_loaded_cnt'] += 1
|
results['trans_loaded_cnt'] += 1
|
||||||
self_values['statement_line_id'] = statement_line_id
|
self_values['statement_line_id'] = statement_line_id
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<openerp>
|
<openerp>
|
||||||
<data>
|
<data>
|
||||||
|
<!-- Re-introduce changes that were removed in 6.1 -->
|
||||||
|
<record id="bank_iban_field" model="res.partner.bank.type.field">
|
||||||
|
<field name="name">iban</field>
|
||||||
|
<field name="bank_type_id" ref="base_iban.bank_iban"/>
|
||||||
|
<field eval="True" name="required"/>
|
||||||
|
<field eval="False" name="readonly"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
<!-- Unset readonly state of acc_number for IBAN accounts.
|
<!-- Unset readonly state of acc_number for IBAN accounts.
|
||||||
Leaving it will make it impossible to deduce BBAN's from any
|
Leaving it will make it impossible to deduce BBAN's from any
|
||||||
client.
|
client.
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ class banking_import(osv.osv_memory):
|
|||||||
statement_obj = self.pool.get('account.bank.statement')
|
statement_obj = self.pool.get('account.bank.statement')
|
||||||
statement_file_obj = self.pool.get('account.banking.imported.file')
|
statement_file_obj = self.pool.get('account.banking.imported.file')
|
||||||
import_transaction_obj = self.pool.get('banking.import.transaction')
|
import_transaction_obj = self.pool.get('banking.import.transaction')
|
||||||
|
period_obj = self.pool.get('account.period')
|
||||||
|
|
||||||
# get the parser to parse the file
|
# get the parser to parse the file
|
||||||
parser_code = banking_import.parser
|
parser_code = banking_import.parser
|
||||||
@@ -256,6 +257,12 @@ class banking_import(osv.osv_memory):
|
|||||||
)
|
)
|
||||||
continue
|
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)])
|
||||||
|
|
||||||
|
# Create the bank statement record
|
||||||
statement_id = statement_obj.create(cursor, uid, dict(
|
statement_id = statement_obj.create(cursor, uid, dict(
|
||||||
name = statement.id,
|
name = statement.id,
|
||||||
journal_id = account_info.journal_id.id,
|
journal_id = account_info.journal_id.id,
|
||||||
@@ -266,6 +273,8 @@ class banking_import(osv.osv_memory):
|
|||||||
state = 'draft',
|
state = 'draft',
|
||||||
user_id = uid,
|
user_id = uid,
|
||||||
banking_id = import_id,
|
banking_id = import_id,
|
||||||
|
company_id = company.id,
|
||||||
|
period_id = period_ids[0],
|
||||||
))
|
))
|
||||||
imported_statement_ids.append(statement_id)
|
imported_statement_ids.append(statement_id)
|
||||||
|
|
||||||
@@ -282,6 +291,8 @@ class banking_import(osv.osv_memory):
|
|||||||
values[attr] = eval('transaction.%s' % attr)
|
values[attr] = eval('transaction.%s' % attr)
|
||||||
values['statement_id'] = statement_id
|
values['statement_id'] = statement_id
|
||||||
values['bank_country_code'] = bank_country_code
|
values['bank_country_code'] = bank_country_code
|
||||||
|
values['local_account'] = statement.local_account
|
||||||
|
|
||||||
transaction_id = import_transaction_obj.create(cursor, uid, values, context=context)
|
transaction_id = import_transaction_obj.create(cursor, uid, values, context=context)
|
||||||
if transaction_id:
|
if transaction_id:
|
||||||
transaction_ids.append(transaction_id)
|
transaction_ids.append(transaction_id)
|
||||||
@@ -292,6 +303,30 @@ class banking_import(osv.osv_memory):
|
|||||||
|
|
||||||
import_transaction_obj.match(cursor, uid, transaction_ids, results=results, context=context)
|
import_transaction_obj.match(cursor, uid, transaction_ids, results=results, context=context)
|
||||||
|
|
||||||
|
#recompute statement end_balance for validation
|
||||||
|
statement_obj.button_dummy(
|
||||||
|
cursor, uid, imported_statement_ids, context=context)
|
||||||
|
|
||||||
|
|
||||||
|
# Original code. Didn't take workflow logistics into account...
|
||||||
|
#
|
||||||
|
#cursor.execute(
|
||||||
|
# "UPDATE payment_order o "
|
||||||
|
# "SET state = 'done', "
|
||||||
|
# "date_done = '%s' "
|
||||||
|
# "FROM payment_line l "
|
||||||
|
# "WHERE o.state = 'sent' "
|
||||||
|
# "AND o.id = l.order_id "
|
||||||
|
# "AND l.id NOT IN ("
|
||||||
|
# "SELECT DISTINCT id FROM payment_line "
|
||||||
|
# "WHERE date_done IS NULL "
|
||||||
|
# "AND id IN (%s)"
|
||||||
|
# ")" % (
|
||||||
|
# time.strftime('%Y-%m-%d'),
|
||||||
|
# ','.join([str(x) for x in payment_line_ids])
|
||||||
|
# )
|
||||||
|
#)
|
||||||
|
|
||||||
report = [
|
report = [
|
||||||
'%s: %s' % (_('Total number of statements'),
|
'%s: %s' % (_('Total number of statements'),
|
||||||
results.stat_skipped_cnt + results.stat_loaded_cnt),
|
results.stat_skipped_cnt + results.stat_loaded_cnt),
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<notebook colspan="4">
|
<notebook colspan="4">
|
||||||
<page attrs="{'invisible': [('state', '!=', 'review')]}" string="Transactions">
|
<page attrs="{'invisible': [('state', '!=', 'review')]}" string="Transactions">
|
||||||
<field name="line_ids" colspan="4" nolabel="1">
|
<field name="line_ids" colspan="4" nolabel="1">
|
||||||
<tree string="Transaction" min_rows="20" colors="red:duplicate;blue:reconcile_id">
|
<tree string="Transaction" colors="red:duplicate;blue:reconcile_id">
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
<field name="ref"/>
|
<field name="ref"/>
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
<page attrs="{'invisible': [('state', '=', 'init'')]}" string="Log">
|
<page attrs="{'invisible': [('state', '=', 'init')]}" string="Log">
|
||||||
<field name="log" colspan="4" nolabel="1" width="500"/>
|
<field name="log" colspan="4" nolabel="1" width="500"/>
|
||||||
</page>
|
</page>
|
||||||
<page attrs="{'invisible': [('state', '!=', 'ready')]}" string="Statements">
|
<page attrs="{'invisible': [('state', '!=', 'ready')]}" string="Statements">
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class banking_transaction_wizard(osv.osv_memory):
|
|||||||
"""
|
"""
|
||||||
Return a popup window for this model
|
Return a popup window for this model
|
||||||
"""
|
"""
|
||||||
if isinstance(ids, (int, float)):
|
if isinstance(ids, (int,long)):
|
||||||
ids = [ids]
|
ids = [ids]
|
||||||
return {
|
return {
|
||||||
'name': self._description,
|
'name': self._description,
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
<field name='payment_line_id'
|
<field name='payment_line_id'
|
||||||
attrs="{'invisible': [('match_type', '!=', 'storno'),('match_type', '!=', 'payment')]}"
|
attrs="{'invisible': [('match_type', '!=', 'storno'),('match_type', '!=', 'payment')]}"
|
||||||
/>
|
/>
|
||||||
<group attrs="{'readonly': [('match_multi', '!=' True)]}">
|
<group attrs="{'readonly': [('match_multi', '!=', True)]}">
|
||||||
<!-- show if we have an invoice type match (but the user may need to select from multiple options)
|
<!-- 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)
|
or whenever there is an invoice_id (e.g. in case of a manual match)
|
||||||
-->
|
-->
|
||||||
|
|||||||
@@ -242,6 +242,7 @@ def get_company_bank_account(pool, cursor, uid, account_number, currency,
|
|||||||
results.costs_account_id = settings.costs_account_id
|
results.costs_account_id = settings.costs_account_id
|
||||||
results.invoice_journal_id = settings.invoice_journal_id
|
results.invoice_journal_id = settings.invoice_journal_id
|
||||||
results.bank_partner_id = settings.bank_partner_id
|
results.bank_partner_id = settings.bank_partner_id
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def get_or_create_bank(pool, cursor, uid, bic, online=False, code=None,
|
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
|
# search key
|
||||||
bank_ids = bank_obj.search(
|
bank_ids = bank_obj.search(
|
||||||
cursor, uid, [
|
cursor, uid, [
|
||||||
('code', '=', bic[:6])
|
('bic', '=', bic[:6])
|
||||||
])
|
])
|
||||||
if not bank_ids:
|
if not bank_ids:
|
||||||
bank_ids = bank_obj.search(
|
bank_ids = bank_obj.search(
|
||||||
|
|||||||
@@ -22,4 +22,5 @@
|
|||||||
import account_banking_uk_hsbc
|
import account_banking_uk_hsbc
|
||||||
import wizard
|
import wizard
|
||||||
import hsbc_mt940
|
import hsbc_mt940
|
||||||
|
import hsbc_clientid
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|||||||
@@ -29,8 +29,10 @@
|
|||||||
'init_xml': [],
|
'init_xml': [],
|
||||||
'update_xml': [
|
'update_xml': [
|
||||||
'account_banking_uk_hsbc.xml',
|
'account_banking_uk_hsbc.xml',
|
||||||
|
'hsbc_clientid_view.xml',
|
||||||
'data/banking_export_hsbc.xml',
|
'data/banking_export_hsbc.xml',
|
||||||
'wizard/export_hsbc_view.xml',
|
'wizard/export_hsbc_view.xml',
|
||||||
|
'security/ir.model.access.csv',
|
||||||
],
|
],
|
||||||
'demo_xml': [],
|
'demo_xml': [],
|
||||||
'description': '''
|
'description': '''
|
||||||
|
|||||||
48
account_banking_uk_hsbc/hsbc_clientid.py
Normal file
48
account_banking_uk_hsbc/hsbc_clientid.py
Normal 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()
|
||||||
|
|
||||||
76
account_banking_uk_hsbc/hsbc_clientid_view.xml
Normal file
76
account_banking_uk_hsbc/hsbc_clientid_view.xml
Normal 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>
|
||||||
@@ -121,7 +121,7 @@ class statement(models.mem_bank_statement):
|
|||||||
|
|
||||||
transaction = self.transactions[-1]
|
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):
|
def raise_error(message, line):
|
||||||
raise osv.except_osv(_('Import error'),
|
raise osv.except_osv(_('Import error'),
|
||||||
@@ -136,7 +136,7 @@ class parser_hsbc_mt940(models.parser):
|
|||||||
the HSBC web interface.
|
the HSBC web interface.
|
||||||
''')
|
''')
|
||||||
|
|
||||||
def parse(self, data):
|
def parse(self, cr, data):
|
||||||
result = []
|
result = []
|
||||||
parser = HSBCParser()
|
parser = HSBCParser()
|
||||||
# Split into statements
|
# Split into statements
|
||||||
@@ -156,6 +156,7 @@ class parser_hsbc_mt940(models.parser):
|
|||||||
print "Invalid Statement:"
|
print "Invalid Statement:"
|
||||||
print records[0]
|
print records[0]
|
||||||
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ class HSBCParser(object):
|
|||||||
|
|
||||||
return matchdict
|
return matchdict
|
||||||
|
|
||||||
def parse(self, data):
|
def parse(self, cr, data):
|
||||||
records = []
|
records = []
|
||||||
# Some records are multiline
|
# Some records are multiline
|
||||||
for line in data:
|
for line in data:
|
||||||
|
|||||||
3
account_banking_uk_hsbc/security/ir.model.access.csv
Normal file
3
account_banking_uk_hsbc/security/ir.model.access.csv
Normal 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
|
||||||
|
|
||||||
|
@@ -132,7 +132,7 @@ class banking_export_hsbc_wizard(osv.osv_memory):
|
|||||||
wizard_data.update({
|
wizard_data.update({
|
||||||
'execution_date_create': strfdate(execution_date),
|
'execution_date_create': strfdate(execution_date),
|
||||||
'reference': reference,
|
'reference': reference,
|
||||||
'payment_order_ids': [[6, 0, po_ids]],
|
'payment_order_ids': [(6, 0, po_ids)],
|
||||||
'state': 'create',
|
'state': 'create',
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -298,8 +298,10 @@ class banking_export_hsbc_wizard(osv.osv_memory):
|
|||||||
try:
|
try:
|
||||||
self.logger.notifyChannel('paymul', netsvc.LOG_INFO, 'Create transactions...')
|
self.logger.notifyChannel('paymul', netsvc.LOG_INFO, 'Create transactions...')
|
||||||
transactions = []
|
transactions = []
|
||||||
|
hsbc_clientid = ''
|
||||||
for po in payment_orders:
|
for po in payment_orders:
|
||||||
transactions += [self._create_transaction(l) for l in po.line_ids]
|
transactions += [self._create_transaction(l) for l in po.line_ids]
|
||||||
|
hsbc_clientid = po.hsbc_clientid_id.clientid
|
||||||
|
|
||||||
batch = paymul.Batch(
|
batch = paymul.Batch(
|
||||||
exec_date=strpdate(wizard_data.execution_date_create),
|
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 = paymul.Message(reference=ref)
|
||||||
message.batches.append(batch)
|
message.batches.append(batch)
|
||||||
interchange = paymul.Interchange(client_id='CLIENTID',
|
interchange = paymul.Interchange(client_id=hsbc_clientid,
|
||||||
reference=ref,
|
reference=ref,
|
||||||
message=message)
|
message=message)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user