Merge pull request #220 from Eficent/11.0-add-account_set_reconcilable

[11.0][ADD] account_set_reconcilable
This commit is contained in:
Jordi Ballester Alomar
2018-10-29 16:12:40 +01:00
committed by GitHub
10 changed files with 143 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3
========================
Account Set Reconcilable
========================
Allows to set as reconcilable a non reconcilable account that already have journal items.
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/11.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 smash it by providing detailed and welcomed feedback.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://odoo-community.org/logo.png>`_.
Contributors
------------
* Miquel Raïch <miquel.raich@eficent.com>
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,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import models

View File

@@ -0,0 +1,15 @@
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Account Set Reconcilable",
"summary": "Allows to set as reconcilable a non reconcilable"
"account that already have journal items.",
"version": "11.0.1.0.0",
"depends": ["account"],
"author": "Eficent, Odoo Community Association (OCA)",
"website": "http://www.github.com/OCA/account-reconcile",
"category": "Finance",
'license': 'AGPL-3',
'installable': True,
}

View File

@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import account_account

View File

@@ -0,0 +1,24 @@
# © 2018 Eficent Business and IT Consulting Services S.L. (www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, models
class AccountAccount(models.Model):
_inherit = "account.account"
@api.multi
def write(self, vals):
if vals.get('reconcile', False):
move_lines = self.env['account.move.line'].search(
[('account_id', 'in', self.ids)])
if move_lines:
for acc in self:
acc_move_lines = move_lines.filtered(
lambda line: line.account_id == acc)
self.env.cr.execute(
"UPDATE account_account SET reconcile=True "
"WHERE id=%s", (acc.id,))
acc_move_lines._amount_residual()
vals.pop('reconcile')
return super(AccountAccount, self).write(vals=vals)

View File

@@ -0,0 +1 @@
* Miquel Raïch <miquel.raich@eficent.com>

View File

@@ -0,0 +1 @@
Allows to set as reconcilable a non reconcilable account that already have journal items.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import test_account_set_reconcilable

View File

@@ -0,0 +1,39 @@
# © 2018 Eficent Business and IT Consulting Services S.L. (www.eficent.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests.common import TransactionCase
class TestAccountSetReconcilable(TransactionCase):
def setUp(self):
super(TestAccountSetReconcilable, self).setUp()
account_account_model = self.env['account.account']
account_move_model = self.env['account.move']
journal = self.env['account.journal'].search(
[('type', '=', 'general')], limit=1)
self.account1 = account_account_model.create({
'name': 'account_test',
'code': 'code_test',
'reconcile': False,
'user_type_id': self.env.ref(
'account.data_account_type_current_liabilities').id,
})
self.move1 = account_move_model.create({
'journal_id': journal.id,
'ref': 'move_test',
'line_ids': [(0, 0, {
'name': 'foo',
'debit': 10,
'account_id': self.account1.id,
}), (0, 0, {
'name': 'bar',
'credit': 10,
'account_id': self.account1.id,
})]
})
def test_write(self):
self.account1.reconcile = True
self.assertTrue(self.account1.reconcile)
self.assertEqual(len(self.move1.line_ids), 2)