Set "Transaction_id" field in CSV/XLS file

This commit is contained in:
Matthieu Dietrich
2016-06-21 10:52:11 +02:00
committed by Yannick Vaucher
parent 03f344009b
commit e0a6d51926
5 changed files with 15 additions and 15 deletions

View File

@@ -2,15 +2,15 @@
<odoo noupdate="1">
<record id="bank_statement_completion_rule_4" model="account.move.completion.rule">
<field name="name">Match from Sales Order using transaction ref</field>
<field name="name">Match from Sales Order using transaction ID</field>
<field name="sequence">30</field>
<field name="function_to_call">get_from_transaction_ref_and_so</field>
<field name="function_to_call">get_from_transaction_id_and_so</field>
</record>
<record id="bank_statement_completion_rule_trans_id_invoice" model="account.move.completion.rule">
<field name="name">Match from Invoice using transaction ref</field>
<field name="name">Match from Invoice using transaction ID</field>
<field name="sequence">40</field>
<field name="function_to_call">get_from_transaction_ref_and_invoice</field>
<field name="function_to_call">get_from_transaction_id_and_invoice</field>
</record>
</odoo>

View File

@@ -1,4 +1,4 @@
"transaction_ref";"date";"amount";"commission_amount";"label"
"transaction_id";"date";"amount";"commission_amount";"label"
50969286;2011-03-07 13:45:14;118.4;-11.84;"label a"
51065326;2011-03-05 13:45:14;189;-15.12;"label b"
51179306;2011-03-02 17:45:14;189;-15.12;"label c"
1 transaction_ref transaction_id date amount commission_amount label
2 50969286 50969286 2011-03-07 13:45:14 118.4 -11.84 label a
3 51065326 51065326 2011-03-05 13:45:14 189 -15.12 label b
4 51179306 51179306 2011-03-02 17:45:14 189 -15.12 label c

View File

@@ -13,13 +13,13 @@ class AccountMoveCompletionRule(models.Model):
function_to_call = fields.Selection(
selection_add=[
('get_from_transaction_ref_and_so',
'Match Sales Order using transaction ref'),
('get_from_transaction_ref_and_invoice',
'Match Invoice using transaction ref')
('get_from_transaction_id_and_so',
'Match Sales Order using transaction ID'),
('get_from_transaction_id_and_invoice',
'Match Invoice using transaction ID')
])
def get_from_transaction_ref_and_so(self, line):
def get_from_transaction_id_and_so(self, line):
"""
Match the partner based on the transaction ID field of the SO.
Then, call the generic st_line method to complete other values.
@@ -35,7 +35,7 @@ class AccountMoveCompletionRule(models.Model):
"""
res = {}
so_obj = self.env['sale.order']
sales = so_obj.search([('transaction_id', '=', line.transaction_ref)])
sales = so_obj.search([('transaction_id', '=', line.transaction_id)])
if len(sales) > 1:
raise ErrorTooManyPartner(
_('Line named "%s" was matched by more than '
@@ -45,7 +45,7 @@ class AccountMoveCompletionRule(models.Model):
res['partner_id'] = sale.partner_id.id
return res
def get_from_transaction_ref_and_invoice(self, line):
def get_from_transaction_id_and_invoice(self, line):
"""Match the partner based on the transaction ID field of the invoice.
Then, call the generic st_line method to complete other values.
@@ -63,7 +63,7 @@ class AccountMoveCompletionRule(models.Model):
res = {}
invoice_obj = self.env['account.invoice']
invoices = invoice_obj.search(
[('transaction_id', '=', line.transaction_ref)])
[('transaction_id', '=', line.transaction_id)])
if len(invoices) > 1:
raise ErrorTooManyPartner(
_('Line named "%s" was matched by more than '

View File

@@ -24,7 +24,7 @@ class TransactionIDFileParser(FileParser):
header
"""
conversion_dict = {
'transaction_ref': ustr,
'transaction_id': ustr,
'label': ustr,
'date': datetime.datetime,
'amount': float_or_zero,
@@ -67,5 +67,5 @@ class TransactionIDFileParser(FileParser):
'date_maturity': line.get('date', datetime.datetime.now().date()),
'credit': amount > 0.0 and amount or 0.0,
'debit': amount < 0.0 and amount or 0.0,
'transaction_ref': line.get('transaction_ref', '/'),
'transaction_ref': line.get('transaction_id', '/'),
}