mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
Fix refresh_record method so that only one reconcile line is created for each move line
Signed-off-by: Sandy Carter <sandy.carter@savoirfairelinux.com>
This commit is contained in:
committed by
Sandy Carter
parent
8464edfecd
commit
7044a2a7a8
@@ -396,7 +396,8 @@ class bank_acc_rec_statement(orm.Model):
|
||||
to_write['credit_move_line_ids'].append(res)
|
||||
else:
|
||||
to_write['debit_move_line_ids'].append(res)
|
||||
obj.write(to_write)
|
||||
|
||||
obj.write(to_write)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
28
account_banking_reconciliation/tests/__init__.py
Normal file
28
account_banking_reconciliation/tests/__init__.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# coding: utf-8
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
|
||||
# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
|
||||
# Copyright (C) 2015 Savoir-faire Linux (<http://www.savoirfairelinux.com>)
|
||||
#
|
||||
# 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 . import test_bank_reconciliation
|
||||
|
||||
checks = [
|
||||
test_bank_reconciliation,
|
||||
]
|
||||
@@ -0,0 +1,97 @@
|
||||
# coding: utf-8
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
|
||||
# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
|
||||
# Copyright (C) 2015 Savoir-faire Linux (<http://www.savoirfairelinux.com>)
|
||||
#
|
||||
# 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 openerp.tests import common
|
||||
from datetime import datetime
|
||||
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||
|
||||
|
||||
class test_bank_reconciliation(common.TransactionCase):
|
||||
def setUp(self):
|
||||
super(test_bank_reconciliation, self).setUp()
|
||||
self.user_model = self.registry('res.users')
|
||||
self.account_model = self.registry('account.account')
|
||||
self.journal_model = self.registry('account.journal')
|
||||
self.move_model = self.registry('account.move')
|
||||
self.move_line_model = self.registry('account.move.line')
|
||||
self.reconcile_model = self.registry('bank.acc.rec.statement')
|
||||
|
||||
self.context = self.user_model.context_get(self.cr, self.uid)
|
||||
cr, uid, context = self.cr, self.uid, self.context
|
||||
|
||||
self.account_bank_id = self.account_model.search(
|
||||
cr, uid, [('type', '=', 'liquidity')], context=context)[0]
|
||||
|
||||
self.account_supplier_id = self.account_model.search(
|
||||
cr, uid, [('type', '=', 'payable')], context=context)[0]
|
||||
|
||||
self.journal_id = self.journal_model.search(
|
||||
cr, uid, [('type', '=', 'bank')], context=context)[0]
|
||||
|
||||
today = datetime.now().strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
|
||||
self.move_id = self.move_model.create(
|
||||
cr, uid, {
|
||||
'journal_id': self.journal_id,
|
||||
'date': today,
|
||||
'line_id': [
|
||||
(0, 0, {
|
||||
'name': 'Test',
|
||||
'account_id': move_line[0],
|
||||
'debit': move_line[1],
|
||||
'credit': move_line[2],
|
||||
})
|
||||
for move_line in [
|
||||
(self.account_bank_id, 0, 10),
|
||||
(self.account_bank_id, 0, 20),
|
||||
(self.account_bank_id, 0, 30),
|
||||
(self.account_supplier_id, 60, 0),
|
||||
]
|
||||
]
|
||||
}, context=context)
|
||||
|
||||
account_move = self.move_model.browse(
|
||||
cr, uid, self.move_id, context=context)
|
||||
|
||||
account_move.button_validate()
|
||||
|
||||
self.reconcile_id = self.reconcile_model.create(
|
||||
cr, uid, {
|
||||
'account_id': self.account_bank_id,
|
||||
'name': 'Test',
|
||||
'ending_date': today,
|
||||
'ending_balance': 100,
|
||||
'starting_balance': 30,
|
||||
}, context=context)
|
||||
|
||||
self.reconcile = self.reconcile_model.browse(
|
||||
cr, uid, self.reconcile_id, context=context)
|
||||
|
||||
self.reconcile.refresh_record()
|
||||
|
||||
self.reconcile.refresh()
|
||||
|
||||
def test_one_reconcile_line_per_move_line(self):
|
||||
"""Test that one line of reconciliation is created for
|
||||
each account move for the account"""
|
||||
self.assertEqual(len(self.reconcile.credit_move_line_ids), 3)
|
||||
Reference in New Issue
Block a user