[ADD] account_move_reconcile_helper

pull/282/head
Benjamin Willig 2017-10-13 15:40:47 +02:00 committed by OCA-git-bot
parent 17c3ec9964
commit 24aa987668
11 changed files with 282 additions and 0 deletions

View File

@ -0,0 +1,64 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
=============================
Account Move Reconcile Helper
=============================
Provides tools to facilitate reconciliation.
* Display a button on Journal entries list to show reconciled lines.
* Added Balance field in Journal entries list (this feature
is provided by account_balance_line).
.. image:: ./static/docs/journal_entries_1.png
:alt: Journal entries
:scale: 50 %
.. image:: ./static/docs/journal_entries_2.png
:alt: Reconciled lines view
:scale: 50 %
Usage
=====
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/98/10.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/account-reconcile/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Benjamin Willig <benjamin.willig@acsone.eu>
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit https://odoo-community.org.

View File

@ -0,0 +1 @@
from . import models

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Account Move Reconcile Helper',
'summary': "Provides tools to facilitate reconciliation",
'version': '10.0.1.0.0',
'license': 'AGPL-3',
'author': 'ACSONE SA/NV, Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/account-reconcile',
'depends': [
'account_balance_line',
],
'data': [
'views/account_move_line.xml',
],
'demo': [
],
}

View File

@ -0,0 +1 @@
from . import account_move_line

View File

@ -0,0 +1,72 @@
# -*- coding: utf-8 -*-
# Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
partial_reconciliation_in_progress = fields.Boolean(
compute='_compute_partial_reconciliation_in_progress')
reconcile_line_ids = fields.One2many(
compute='_compute_reconciled_lines',
comodel_name='account.move.line',
string="Reconciled lines")
@api.multi
@api.depends('matched_debit_ids', 'matched_credit_ids')
def _compute_partial_reconciliation_in_progress(self):
for rec in self:
rec.partial_reconciliation_in_progress = (
bool(rec.matched_debit_ids) or bool(rec.matched_credit_ids))
@api.multi
def _compute_reconciled_lines(self):
for rec in self:
rec.reconcile_line_ids = rec._get_reconciled_lines()
@api.multi
def _get_reconciled_lines(self, move_lines=None):
"""
Returns lines which were reconciled directly or indirectly with
current lines given in self.
If A has been reconciled (or partially) with B, and B with C. This
method will returns A, B, and C.
:param move_lines: found moves lines to avoid recursivity
:return: recordset('account.move.line')
"""
move_lines = move_lines or self.env[self._name]
for line in self:
if line.full_reconcile_id:
matched_lines = line.full_reconcile_id.reconciled_line_ids
elif line.credit > 0:
matched_lines = line.matched_debit_ids.mapped('debit_move_id')
else:
matched_lines = line.matched_credit_ids.mapped(
'credit_move_id')
if not matched_lines:
continue
move_lines |= line
for matched_line in matched_lines:
if matched_line not in move_lines:
move_lines |= matched_line
move_lines |= matched_line._get_reconciled_lines(
move_lines)
return move_lines
@api.multi
def open_full_reconcile_view(self):
action = self.env.ref('account.action_account_moves_all_a').read()[0]
action['domain'] = [
('id', 'in', self.mapped('reconcile_line_ids').ids)]
return action

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -0,0 +1 @@
from . import test_account_move_reconcile_helper

View File

@ -0,0 +1,100 @@
# -*- coding: utf-8 -*-
# Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests.common import TransactionCase
class TestAccountMoveReconcileHelper(TransactionCase):
def setUp(self):
super(TestAccountMoveReconcileHelper, self).setUp()
self.AccountObj = self.env['account.account']
self.AccountJournalObj = self.env['account.journal']
self.AccountMoveObj = self.env['account.move']
self.AccountMoveLineObj = self.env['account.move.line']
self.account_type_recv = self.env.ref(
'account.data_account_type_receivable')
self.account_type_rev = self.env.ref(
'account.data_account_type_revenue')
self.account_recv = self.AccountObj.create({
'code': 'MRH-RECVT',
'name': "Receivable (test)",
'reconcile': True,
'user_type_id': self.account_type_recv.id,
})
self.account_sale = self.AccountObj.create({
'code': 'MRH-SALET',
'name': "Receivable (sale)",
'reconcile': True,
'user_type_id': self.account_type_rev.id,
})
self.sales_journal = self.AccountJournalObj.create({
'name': "Sales journal",
'code': 'MRH-SAJT',
'type': 'sale',
'default_credit_account_id': self.account_sale.id,
'default_debit_account_id': self.account_sale.id,
})
def create_account_move(self, amount, debit_account, credit_account):
return self.AccountMoveObj.create({
'journal_id': self.sales_journal.id,
'line_ids': [
(0, 0, {
'name': "Receivable line",
'account_id': debit_account.id,
'debit': amount,
}),
(0, 0, {
'name': "Sales line",
'account_id': credit_account.id,
'credit': amount,
}),
]
})
def test_01_partial_reconcile(self):
base_move = self.create_account_move(
5000, self.account_recv, self.account_sale)
move1 = self.create_account_move(
1000, self.account_sale, self.account_recv)
move2 = self.create_account_move(
1000, self.account_sale, self.account_recv)
lines = self.AccountMoveLineObj.search([
('move_id', 'in', [base_move.id, move1.id, move2.id]),
('account_id', '=', self.account_recv.id)
])
lines.reconcile()
for line in lines:
self.assertEquals(line.reconcile_line_ids, lines)
def test_02_full_reconcile(self):
base_move = self.create_account_move(
5000, self.account_recv, self.account_sale)
move2 = self.create_account_move(
2500, self.account_sale, self.account_recv)
move3 = self.create_account_move(
2500, self.account_sale, self.account_recv)
lines = self.AccountMoveLineObj.search([
('move_id', 'in', [base_move.id, move2.id, move3.id]),
('account_id', '=', self.account_recv.id)
])
lines.reconcile()
for line in lines:
self.assertEquals(line.reconcile_line_ids, lines)
self.assertEquals(
line.full_reconcile_id.reconciled_line_ids,
line.reconcile_line_ids)

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record model="ir.ui.view" id="account_move_line_tree_view">
<field name="name">account.move.line.tree (in account_move_reconcile_helper)</field>
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_move_line_tree"/>
<field name="arch" type="xml">
<field name="full_reconcile_id" position="after">
<field name="partial_reconciliation_in_progress" invisible="1"/>
<button name="open_full_reconcile_view" type="object"
string="Reconciled lines" icon="fa-list"
attrs="{'invisible': [('full_reconcile_id', '=', False), ('partial_reconciliation_in_progress', '=', False)]}"/>
</field>
</field>
</record>
</odoo>