diff --git a/account_journal_restrict_mode/README.rst b/account_journal_restrict_mode/README.rst new file mode 100644 index 00000000..3cd3f15a --- /dev/null +++ b/account_journal_restrict_mode/README.rst @@ -0,0 +1,88 @@ +============================= +Account Journal Restrict Mode +============================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:b7345b32df60a41001389fcd7bf25c52e026a6fed2d88655f95f6ee12ca3d960 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github + :target: https://github.com/OCA/account-financial-tools/tree/16.0/account_journal_restrict_mode + :alt: OCA/account-financial-tools +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-financial-tools-16-0/account-financial-tools-16-0-account_journal_restrict_mode + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module enables by default the setting *Lock Posted Entries with Hash* in +all Journals and prevents the setting to be modified. + +The goal is to assure that all journal entries are locked when posted to prevent +them to be modified. + +**Table of contents** + +.. contents:: + :local: + +Known issues / Roadmap +====================== + +* Odoo hides the setting *Lock Posted Entries with Hash* on Bank and Cash + Journals, but enabling it does not cause issues in the reconciliation for now. + If the Odoo logic changes at any point, the module may need to be adapted to + only force the setting on other types of journals. + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow S.L. + +Contributors +~~~~~~~~~~~~ + +* Jordi Masvidal + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +This module is part of the `OCA/account-financial-tools `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_journal_restrict_mode/__init__.py b/account_journal_restrict_mode/__init__.py new file mode 100644 index 00000000..e66fb1c2 --- /dev/null +++ b/account_journal_restrict_mode/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import models +from .hooks import post_init_hook diff --git a/account_journal_restrict_mode/__manifest__.py b/account_journal_restrict_mode/__manifest__.py new file mode 100644 index 00000000..01721a51 --- /dev/null +++ b/account_journal_restrict_mode/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2023 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Account Journal Restrict Mode", + "summary": "Lock All Posted Entries of Journals.", + "version": "16.0.1.0.0", + "author": "ForgeFlow S.L., Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-financial-tools", + "category": "Accounting", + "depends": [ + "account", + ], + "license": "AGPL-3", + "data": [], + "installable": True, + "post_init_hook": "post_init_hook", +} diff --git a/account_journal_restrict_mode/hooks.py b/account_journal_restrict_mode/hooks.py new file mode 100644 index 00000000..31671f92 --- /dev/null +++ b/account_journal_restrict_mode/hooks.py @@ -0,0 +1,13 @@ +# Copyright 2023 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import SUPERUSER_ID, api + + +def post_init_hook(cr, registry): + """Enable restrict mode on all journals""" + env = api.Environment(cr, SUPERUSER_ID, {}) + journals_to_update = env["account.journal"].search( + [("restrict_mode_hash_table", "=", False)] + ) + journals_to_update.write({"restrict_mode_hash_table": True}) diff --git a/account_journal_restrict_mode/models/__init__.py b/account_journal_restrict_mode/models/__init__.py new file mode 100644 index 00000000..a8e96f29 --- /dev/null +++ b/account_journal_restrict_mode/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import account_journal diff --git a/account_journal_restrict_mode/models/account_journal.py b/account_journal_restrict_mode/models/account_journal.py new file mode 100644 index 00000000..921ac92b --- /dev/null +++ b/account_journal_restrict_mode/models/account_journal.py @@ -0,0 +1,19 @@ +# Copyright 2023 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import _, api, fields, models +from odoo.exceptions import UserError + + +class AccountJournal(models.Model): + _inherit = "account.journal" + + restrict_mode_hash_table = fields.Boolean(default=True) + + @api.constrains("restrict_mode_hash_table") + def _check_journal_restrict_mode(self): + for rec in self: + if not rec.restrict_mode_hash_table: + raise UserError( + _("Journal %s must have Lock Posted Entries enabled.") % rec.name + ) diff --git a/account_journal_restrict_mode/readme/CONTRIBUTORS.rst b/account_journal_restrict_mode/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..e4263e41 --- /dev/null +++ b/account_journal_restrict_mode/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Jordi Masvidal diff --git a/account_journal_restrict_mode/readme/DESCRIPTION.rst b/account_journal_restrict_mode/readme/DESCRIPTION.rst new file mode 100644 index 00000000..1afc6c1b --- /dev/null +++ b/account_journal_restrict_mode/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +This module enables by default the setting *Lock Posted Entries with Hash* in +all Journals and prevents the setting to be modified. + +The goal is to assure that all journal entries are locked when posted to prevent +them to be modified. diff --git a/account_journal_restrict_mode/readme/ROADMAP.rst b/account_journal_restrict_mode/readme/ROADMAP.rst new file mode 100644 index 00000000..c13dd56b --- /dev/null +++ b/account_journal_restrict_mode/readme/ROADMAP.rst @@ -0,0 +1,4 @@ +* Odoo hides the setting *Lock Posted Entries with Hash* on Bank and Cash + Journals, but enabling it does not cause issues in the reconciliation for now. + If the Odoo logic changes at any point, the module may need to be adapted to + only force the setting on other types of journals. diff --git a/account_journal_restrict_mode/static/description/icon.png b/account_journal_restrict_mode/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/account_journal_restrict_mode/static/description/icon.png differ diff --git a/account_journal_restrict_mode/static/description/index.html b/account_journal_restrict_mode/static/description/index.html new file mode 100644 index 00000000..7e4ee05c --- /dev/null +++ b/account_journal_restrict_mode/static/description/index.html @@ -0,0 +1,433 @@ + + + + + + +Account Move Line Sale Info + + + +
+

Account Move Line Sale Info

+ + +

Beta License: AGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runboat

+

This module will add the sale order line to journal items.

+

The ultimate goal is to establish the purchase order line as one of the key +fields to reconcile the Goods Delivered Not Invoiced accrual account.

+

Table of contents

+ +
+

Known issues / Roadmap

+
    +
  • Odoo hides the setting Lock Posted Entries with Hash on Bank and Cash +Journals, but enabling it does not cause issues in the reconciliation for now. +If the Odoo logic changes at any point, the module may need to be adapted to +only force the setting on other types of journals.
  • +
+
+
+

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 to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow S.L.
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/account-financial-tools project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/account_journal_restrict_mode/tests/__init__.py b/account_journal_restrict_mode/tests/__init__.py new file mode 100644 index 00000000..f42a275d --- /dev/null +++ b/account_journal_restrict_mode/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import test_account_journal_restrict_mode diff --git a/account_journal_restrict_mode/tests/test_account_journal_restrict_mode.py b/account_journal_restrict_mode/tests/test_account_journal_restrict_mode.py new file mode 100644 index 00000000..fbd5eb20 --- /dev/null +++ b/account_journal_restrict_mode/tests/test_account_journal_restrict_mode.py @@ -0,0 +1,20 @@ +# Copyright 2023 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo.exceptions import UserError +from odoo.tests import common + + +class TestAccountJournalRestrictMode(common.TransactionCase): + @classmethod + def setUpClass(cls): + super(TestAccountJournalRestrictMode, cls).setUpClass() + cls.account_journal_obj = cls.env["account.journal"] + + def test_journal_default_lock_entries(self): + journal = self.account_journal_obj.create( + {"name": "Test Journal", "code": "TJ", "type": "general"} + ) + self.assertTrue(journal.restrict_mode_hash_table) + with self.assertRaises(UserError): + journal.write({"restrict_mode_hash_table": False}) diff --git a/setup/account_journal_restrict_mode/odoo/addons/account_journal_restrict_mode b/setup/account_journal_restrict_mode/odoo/addons/account_journal_restrict_mode new file mode 120000 index 00000000..6d1da32a --- /dev/null +++ b/setup/account_journal_restrict_mode/odoo/addons/account_journal_restrict_mode @@ -0,0 +1 @@ +../../../../account_journal_restrict_mode \ No newline at end of file diff --git a/setup/account_journal_restrict_mode/setup.py b/setup/account_journal_restrict_mode/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/account_journal_restrict_mode/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)