1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Author: Matthieu Dietrich. Copyright Camptocamp SA
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU Affero General Public License as
8
# published by the Free Software Foundation, either version 3 of the
9
# License, or (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU Affero General Public License for more details.
16
# You should have received a copy of the GNU Affero General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
##############################################################################
21
from openerp.osv import orm
24
class easy_reconcile_advanced_bank_statement(orm.TransientModel):
26
_name = 'easy.reconcile.advanced.bank_statement'
27
_inherit = 'easy.reconcile.advanced'
29
def _skip_line(self, cr, uid, rec, move_line, context=None):
31
When True is returned on some conditions, the credit move line
32
will be skipped for reconciliation. Can be inherited to
33
skip on some conditions. ie: ref or partner_id is empty.
35
return not (move_line.get('ref') and
36
move_line.get('partner_id'))
38
def _matchers(self, cr, uid, rec, move_line, context=None):
39
return (('partner_id', move_line['partner_id']),
40
('ref', move_line['ref'].lower().strip()))
42
def _opposite_matchers(self, cr, uid, rec, move_line, context=None):
43
yield ('partner_id', move_line['partner_id'])
44
if move_line['statement_id']:
45
cr.execute("""SELECT name FROM account_bank_statement
46
WHERE id = %s""", (move_line['statement_id'],))
47
statement_name = cr.fetchone()[0]
48
yield ('ref', statement_name.lower().strip())
52
# Re-defined for this particular rule; since the commission line is a
53
# credit line inside of the target statement, it should also be considered
54
# as an opposite to be reconciled.
55
def _action_rec(self, cr, uid, rec, context=None):
56
credit_lines = self._query_credit(cr, uid, rec, context=context)
57
debit_lines = self._query_debit(cr, uid, rec, context=context)
58
return self._rec_auto_lines_advanced(
59
cr, uid, rec, credit_lines, credit_lines + debit_lines,