diff --git a/account_set_reconcilable/README.rst b/account_set_reconcilable/README.rst new file mode 100644 index 00000000..e6bec561 --- /dev/null +++ b/account_set_reconcilable/README.rst @@ -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 +`_. 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 `_. + +Contributors +------------ + +* Miquel Raïch + +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. diff --git a/account_set_reconcilable/__init__.py b/account_set_reconcilable/__init__.py new file mode 100755 index 00000000..4b76c7b2 --- /dev/null +++ b/account_set_reconcilable/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/account_set_reconcilable/__manifest__.py b/account_set_reconcilable/__manifest__.py new file mode 100644 index 00000000..7ec0f6bd --- /dev/null +++ b/account_set_reconcilable/__manifest__.py @@ -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, +} diff --git a/account_set_reconcilable/models/__init__.py b/account_set_reconcilable/models/__init__.py new file mode 100755 index 00000000..187b10d4 --- /dev/null +++ b/account_set_reconcilable/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import account_account diff --git a/account_set_reconcilable/models/account_account.py b/account_set_reconcilable/models/account_account.py new file mode 100644 index 00000000..2c759388 --- /dev/null +++ b/account_set_reconcilable/models/account_account.py @@ -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) diff --git a/account_set_reconcilable/readme/CONTRIBUTORS.rst b/account_set_reconcilable/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..2e34e218 --- /dev/null +++ b/account_set_reconcilable/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Miquel Raïch diff --git a/account_set_reconcilable/readme/DESCRIPTION.rst b/account_set_reconcilable/readme/DESCRIPTION.rst new file mode 100644 index 00000000..294916d4 --- /dev/null +++ b/account_set_reconcilable/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Allows to set as reconcilable a non reconcilable account that already have journal items. diff --git a/account_set_reconcilable/static/description/icon.png b/account_set_reconcilable/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/account_set_reconcilable/static/description/icon.png differ diff --git a/account_set_reconcilable/tests/__init__.py b/account_set_reconcilable/tests/__init__.py new file mode 100644 index 00000000..93a76bb5 --- /dev/null +++ b/account_set_reconcilable/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_account_set_reconcilable diff --git a/account_set_reconcilable/tests/test_account_set_reconcilable.py b/account_set_reconcilable/tests/test_account_set_reconcilable.py new file mode 100644 index 00000000..883382a1 --- /dev/null +++ b/account_set_reconcilable/tests/test_account_set_reconcilable.py @@ -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)