mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
[FIX] optimize new rule
This commit is contained in:
committed by
Leonardo Pistone
parent
b48a46a299
commit
c9779f3326
@@ -1,8 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# Author: Matthieu Dietrich
|
# Author: Romain Deheele. Copyright Camptocamp SA
|
||||||
# Copyright 2014 Camptocamp SA
|
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Affero General Public License as
|
# it under the terms of the GNU Affero General Public License as
|
||||||
@@ -20,5 +19,4 @@
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from . import easy_reconcile
|
from . import easy_reconcile
|
||||||
from . import base_advanced_reconciliation
|
|
||||||
from . import advanced_reconciliation
|
from . import advanced_reconciliation
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# Author: Matthieu Dietrich
|
# Author: Matthieu Dietrich. Copyright Camptocamp SA
|
||||||
# Copyright 2014 Camptocamp SA
|
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Affero General Public License as
|
# it under the terms of the GNU Affero General Public License as
|
||||||
@@ -27,6 +26,33 @@ class easy_reconcile_advanced_bank_statement(orm.TransientModel):
|
|||||||
_name = 'easy.reconcile.advanced.bank_statement'
|
_name = 'easy.reconcile.advanced.bank_statement'
|
||||||
_inherit = 'easy.reconcile.advanced'
|
_inherit = 'easy.reconcile.advanced'
|
||||||
|
|
||||||
|
def _base_columns(self, rec):
|
||||||
|
""" Mandatory columns for move lines queries
|
||||||
|
An extra column aliased as ``key`` should be defined
|
||||||
|
in each query."""
|
||||||
|
aml_cols = (
|
||||||
|
'id',
|
||||||
|
'debit',
|
||||||
|
'credit',
|
||||||
|
'date',
|
||||||
|
'period_id',
|
||||||
|
'ref',
|
||||||
|
'name',
|
||||||
|
'partner_id',
|
||||||
|
'account_id',
|
||||||
|
'move_id',
|
||||||
|
'statement_id')
|
||||||
|
result = ["account_move_line.%s" % col for col in aml_cols]
|
||||||
|
result += ["account_bank_statement.name as statement_name"]
|
||||||
|
return result
|
||||||
|
|
||||||
|
def _from(self, rec, *args, **kwargs):
|
||||||
|
# Overriden to use a inner join
|
||||||
|
return """FROM account_move_line
|
||||||
|
INNER JOIN account_bank_statement
|
||||||
|
ON account_bank_statement.id =
|
||||||
|
account_move_line.statement_id"""
|
||||||
|
|
||||||
def _skip_line(self, cr, uid, rec, move_line, context=None):
|
def _skip_line(self, cr, uid, rec, move_line, context=None):
|
||||||
"""
|
"""
|
||||||
When True is returned on some conditions, the credit move line
|
When True is returned on some conditions, the credit move line
|
||||||
@@ -42,13 +68,8 @@ class easy_reconcile_advanced_bank_statement(orm.TransientModel):
|
|||||||
|
|
||||||
def _opposite_matchers(self, cr, uid, rec, move_line, context=None):
|
def _opposite_matchers(self, cr, uid, rec, move_line, context=None):
|
||||||
yield ('partner_id', move_line['partner_id'])
|
yield ('partner_id', move_line['partner_id'])
|
||||||
if move_line['statement_id']:
|
yield ('ref',
|
||||||
cr.execute("""SELECT name FROM account_bank_statement
|
(move_line['statement_name'] or '').lower().strip())
|
||||||
WHERE id = %s""", (move_line['statement_id'],))
|
|
||||||
statement_name = cr.fetchone()[0]
|
|
||||||
yield ('ref', statement_name.lower().strip())
|
|
||||||
else:
|
|
||||||
yield ('ref', '')
|
|
||||||
|
|
||||||
# Re-defined for this particular rule; since the commission line is a
|
# Re-defined for this particular rule; since the commission line is a
|
||||||
# credit line inside of the target statement, it should also be considered
|
# credit line inside of the target statement, it should also be considered
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# Author: Matthieu Dietrich
|
|
||||||
# Copyright 2014 Camptocamp SA
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
from itertools import product
|
|
||||||
from openerp.osv import orm
|
|
||||||
|
|
||||||
|
|
||||||
class easy_reconcile_advanced(orm.AbstractModel):
|
|
||||||
|
|
||||||
_inherit = 'easy.reconcile.advanced'
|
|
||||||
|
|
||||||
def _base_columns(self, rec):
|
|
||||||
""" Mandatory columns for move lines queries
|
|
||||||
An extra column aliased as ``key`` should be defined
|
|
||||||
in each query."""
|
|
||||||
aml_cols = (
|
|
||||||
'id',
|
|
||||||
'debit',
|
|
||||||
'credit',
|
|
||||||
'date',
|
|
||||||
'period_id',
|
|
||||||
'ref',
|
|
||||||
'name',
|
|
||||||
'partner_id',
|
|
||||||
'account_id',
|
|
||||||
'move_id',
|
|
||||||
'statement_id')
|
|
||||||
return ["account_move_line.%s" % col for col in aml_cols]
|
|
||||||
Reference in New Issue
Block a user