[REF] Extract the domain generation for get_move_lines_for_reconciliation and get_rec...
authorGuewen Baconnier <guewen.baconnier@camptocamp.com>
Fri, 10 Oct 2014 12:16:12 +0000 (14:16 +0200)
committerArthur Maniet <me@whisno.be>
Thu, 16 Oct 2014 12:12:06 +0000 (14:12 +0200)
commit3af6bed7436ac1f00628ce5da65e632860793512
tree749bd6c726194eb8622f9d55e2ce1084d9cfdaf0
parent83b8e413ffdbfed34f123c5c907042ab75f38d28
[REF] Extract the domain generation for get_move_lines_for_reconciliation and get_reconciliation_proposition in new methods

This way, the query method can be used with a custom domain. Such a domain
could match on a 'transaction_ref' field as well as on 'ref' and 'name'.

Example of implementation:

    class account_bank_statement_line(orm.Model):
        _inherit = 'account.bank.statement.line'

        def _domain_reconciliation_proposition(self, cr, uid, st_line,
                                               excluded_ids=None, context=None):
            _super = super(account_bank_statement_line, self)
            _get_domain = _super._domain_reconciliation_proposition
            domain = _get_domain(cr, uid, st_line, excluded_ids=excluded_ids,
                                 context=context)
            new_domain = []
            for criterium in domain:
                if len(criterium) == 3:
                    field, op, value = criterium
                    if (field, op) == ('ref', '='):
                        new_domain += [
                            '|',
                            ('transaction_ref', '=', value),
                        ]
                new_domain.append(criterium)
            return new_domain

        def _domain_move_lines_for_reconciliation(self, cr, uid, st_line,
                                                  excluded_ids=None, str=False,
                                                  additional_domain=None,
                                                  context=None):
            _super = super(account_bank_statement_line, self)
            _domain_meth = _super._domain_move_lines_for_reconciliation
            domain = _domain_meth(cr, uid, st_line, excluded_ids=excluded_ids,
                                  str=str, additional_domain=additional_domain,
                                  context=context)
            if not str and str != '/':
                return domain
            domain = domain[:]
            domain.insert(-1, '|')
            domain.append(('transaction_ref', 'ilike', str))
            return domain
addons/account/account_bank_statement.py