~pedro.baeza/banking-addons/bank-statement-reconcile-7.0-base_completion_imp

« back to all changes in this revision

Viewing changes to account_advanced_reconcile_transaction_ref/account.py

  • Committer: alexandre.fayolle at camptocamp
  • Author(s): guewen.baconnier at camptocamp
  • Date: 2014-04-14 13:09:19 UTC
  • mfrom: (113.3.22 7.0-transaction_id-imp)
  • Revision ID: alexandre.fayolle@camptocamp.com-20140414130919-mmdjici0ybn4fq3v
Improvement around the Transaction IDs modules
==============================================

This proposal aims to improve the modules using transaction ids, I will start
by summarizing what are they used for, then what are the existing problems and
what changes I propose.

Transaction IDs?
----------------

The transaction IDs are a technical reference for a move line. They are to
differentiate from the usual reference that are a reference for humans firstly
(more about that here [0]). Usually, the transaction IDs are defined by
external systems such as payment gateways and are a way to streamline the
reconciliations between the invoices, bank statements...

Changes
-------

1) account_move_line.transaction_ref is defined in 'account_advanced_reconcile_transaction_ref' which adds a reconciliation method with transaction id.
It makes much sense to add the field in 'base_transaction_id' so we can use the field in other modules such as the bank statement completion modules. It is a pity that the field on the invoice and the sale order is 'transaction_id' and in move lines 'transaction_ref' but I prefer to keep the backward-compatibility.

So I moved these things from 'account_advanced_reconcile_transaction_ref' to 'base_transaction_id'

2) In account_advanced_reconcile_transaction_ref there is an inherit of the bank statement that copies the line's ref in the move line's transaction_id. I think this is a mismatch between the ref and the transaction_id that we have to avoid. In fact, only the transaction id of the statement lines should be copied if any, or left empty if the statement line has no transaction id.

3) A consequence of the change 2) is that the automatic reconcile from transaction ref will no longer work for those not using the transaction ids in the bank statement but only the ref. So I added a new reconciliation rule that matches 'ref' vs 'transaction id'. The only drawback is that they will need to change their configuration, but at least the rules will be clear on their intentions.

4) completion rules: 'base_transaction_id' adds a transaction_id on sales order and invoices. There is actually a completion rule that searches the bank statement information from a matching invoice with the same transaction_id. I added the same rule that searches for an invoice with the same transaction id. This is the logical continuation and a good complement when an invoice / refund was not generated by a sales order and we still need to autocomplete the bank statement.

[0] https://code.launchpad.net/~camptocamp/banking-addons/7.0-bank-statement-reconcile-account_invoice_reference/+merge/202689

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
##############################################################################
3
 
#
4
 
#    Author: Romain Deheele
5
 
#    Copyright 2013 Camptocamp SA
6
 
#
7
 
#    This program is free software: you can redistribute it and/or modify
8
 
#    it under the terms of the GNU Affero General Public License as
9
 
#    published by the Free Software Foundation, either version 3 of the
10
 
#    License, or (at your option) any later version.
11
 
#
12
 
#    This program is distributed in the hope that it will be useful,
13
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
#    GNU Affero General Public License for more details.
16
 
#
17
 
#    You should have received a copy of the GNU Affero General Public License
18
 
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 
#
20
 
##############################################################################
21
 
 
22
 
from openerp.osv.orm import Model, fields
23
 
 
24
 
class AccountMoveLine(Model):
25
 
    """
26
 
    Inherit account.move.line class in order to add transaction_ref field
27
 
    """
28
 
    _inherit = "account.move.line"
29
 
    _columns = {
30
 
        'transaction_ref': fields.char('Transaction Ref.', size=128),
31
 
    }
32
 
    
33
 
class AccountBankStatement(Model):
34
 
    """
35
 
    Inherit account.bank.statement class in order to set transaction_ref info on account.move.line
36
 
    """
37
 
    _inherit = "account.bank.statement"   
38
 
   
39
 
    def _prepare_move_line_vals(
40
 
            self, cr, uid, st_line, move_id, debit, credit, currency_id=False,
41
 
            amount_currency=False, account_id=False, analytic_id=False,
42
 
            partner_id=False, context=None):
43
 
 
44
 
        if context is None:
45
 
            context = {}
46
 
        res = super(AccountBankStatement, self)._prepare_move_line_vals(
47
 
                cr, uid, st_line, move_id, debit, credit,
48
 
                currency_id=currency_id,
49
 
                amount_currency=amount_currency,
50
 
                account_id=account_id,
51
 
                analytic_id=analytic_id,
52
 
                partner_id=partner_id, context=context)
53
 
        res.update({'transaction_ref': st_line.ref})
54
 
        return res