[IMP] l10n_be_coda: using the ref field to store the structured communication for automatic reconciliation as per new process on bank statement

This commit is contained in:
qdp-odoo 2014-06-16 13:30:50 +02:00
parent 01d642f2d4
commit ffa6df1e4c
3 changed files with 27 additions and 57 deletions

View File

@ -32,5 +32,27 @@
<field eval="'2011-01-31'" name="date_stop"/>
<field name="company_id" ref="base.main_company"/>
</record>
<!-- invoice with BBA -->
<record id="coda_demo_invoice_1" model="account.invoice">
<field name="currency_id" ref="base.EUR"/>
<field name="company_id" ref="base.main_company"/>
<field name="journal_id" ref="account.sales_journal"/>
<field name="period_id" ref="period_1_2011"/>
<field name="state">draft</field>
<field name="type">out_invoice</field>
<field name="account_id" ref="account.a_recv"/>
<field name="partner_id" ref="base.res_partner_9"/>
<field name="reference_type">bba</field>
<field name="reference">+++240/2838/42818+++</field>
</record>
<record id="invoice_1_line_1" model="account.invoice.line">
<field name="name">Otpez Laptop without OS</field>
<field name="invoice_id" ref="coda_demo_invoice_1"/>
<field name="price_unit">608.89</field>
<field name="quantity">10</field>
<field name="account_id" ref="account.a_sale"/>
</record>
<workflow action="invoice_open" model="account.invoice" ref="coda_demo_invoice_1"/>
</data>
</openerp>

View File

@ -4,7 +4,7 @@
2200010000 GKCCBEBB 1 0
2300010000BE41063012345610 PARTNER 1 0 1
3100010001OL44483FW SCTOFBIONLO001010001001PARTNER 1 0 0
2100020000OL4414AC8BOVSOVSOVERS00000000030444501101110015000002010237 11011113501 0
2100020000OL4414AC8BOVSOVSOVERS000000000304445011011100150001101240283842818 11011113501 0
2200020000 BBRUBEBB 1 0
2300020000BE61310126985517 PARTNER 2 0 1
3100020001OL4414AC8BOVSOVSOVERS001500001001PARTNER 2 1 0

View File

@ -291,62 +291,10 @@ class account_coda_import(osv.osv_memory):
if 'counterpartyAddress' in line and line['counterpartyAddress'] != '':
note.append(_('Counter Party Address') + ': ' + line['counterpartyAddress'])
line['name'] = "\n".join(filter(None, [line['counterpartyName'], line['communication']]))
partner = None
partner_id = None
invoice = False
structured_com = ""
if line['communication_struct'] and 'communication_type' in line and line['communication_type'] == '101':
ids = self.pool.get('account.invoice').search(cr, uid, [('reference', '=', line['communication']), ('reference_type', '=', 'bba')])
# Gère les communications structurées
# TODO : à faire primer sur resolution_proposition : si la communication indique une facture, on la sélectionne
# if ids:
# invoice = self.pool.get('account.invoice').browse(cr, uid, ids[0])
# partner = invoice.partner_id
# partner_id = partner.id
# if invoice.type in ['in_invoice', 'in_refund'] and line['debit'] == '1':
# line['transaction_type'] = 'supplier'
# elif invoice.type in ['out_invoice', 'out_refund'] and line['debit'] == '0':
# line['transaction_type'] = 'customer'
# line['account'] = invoice.account_id.id
# line['reconcile'] = False
# if invoice.type in ['in_invoice', 'out_invoice']:
# iml_ids = self.pool.get('account.move.line').search(cr, uid, [('move_id', '=', invoice.move_id.id), ('reconcile_id', '=', False), ('account_id.reconcile', '=', True)])
# if iml_ids:
# line['reconcile'] = iml_ids[0]
# if line['reconcile']:
# voucher_vals = {
# 'type': line['transaction_type'] == 'supplier' and 'payment' or 'receipt',
# 'name': line['name'],
# 'partner_id': partner_id,
# 'journal_id': statement['journal_id'].id,
# 'account_id': statement['journal_id'].default_credit_account_id.id,
# 'company_id': statement['journal_id'].company_id.id,
# 'currency_id': statement['journal_id'].company_id.currency_id.id,
# 'date': line['entryDate'],
# 'amount': abs(line['amount']),
# 'period_id': statement['period_id'],
# 'invoice_id': invoice.id,
# }
# context['invoice_id'] = invoice.id
# voucher_vals.update(self.pool.get('account.voucher').onchange_partner_id(cr, uid, [],
# partner_id=partner_id,
# journal_id=statement['journal_id'].id,
# amount=abs(line['amount']),
# currency_id=statement['journal_id'].company_id.currency_id.id,
# ttype=line['transaction_type'] == 'supplier' and 'payment' or 'receipt',
# date=line['transactionDate'],
# context=context
# )['value'])
# line_drs = []
# for line_dr in voucher_vals['line_dr_ids']:
# line_drs.append((0, 0, line_dr))
# voucher_vals['line_dr_ids'] = line_drs
# line_crs = []
# for line_cr in voucher_vals['line_cr_ids']:
# line_crs.append((0, 0, line_cr))
# voucher_vals['line_cr_ids'] = line_crs
# line['voucher_id'] = self.pool.get('account.voucher').create(cr, uid, voucher_vals, context=context)
structured_com = line['communication']
if 'counterpartyNumber' in line and line['counterpartyNumber']:
ids = self.pool.get('res.partner.bank').search(cr, uid, [('acc_number', '=', str(line['counterpartyNumber']))])
if ids and len(ids) > 0:
@ -356,12 +304,12 @@ class account_coda_import(osv.osv_memory):
note.append(_('Communication') + ': ' + line['communication'])
data = {
'name': line['name'],
'note': "\n".join(note),
'note': "\n".join(note),
'date': line['entryDate'],
'amount': line['amount'],
'partner_id': partner_id,
'statement_id': statement['id'],
'ref': line['ref'],
'ref': structured_com,
'sequence': line['sequence'],
'coda_account_number': line['counterpartyNumber'],
}