Skip to content

Commit 38fdf13

Browse files
[IMP] account_journal_restrict_mode: do not force hash on bank and cash journals
Forcing the hashing of bank and cash journals results in errors when creating bank transactions, due to the commit added in Odoo: odoo/odoo@9740189
1 parent 123c1e9 commit 38fdf13

File tree

6 files changed

+45
-42
lines changed

6 files changed

+45
-42
lines changed

account_journal_restrict_mode/README.rst

+7-11
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,21 @@ Account Journal Restrict Mode
2929
|badge1| |badge2| |badge3| |badge4| |badge5|
3030

3131
This module enables by default the setting *Lock Posted Entries with
32-
Hash* in all Journals and prevents the setting to be modified.
32+
Hash* in all Sales, Purchase and Miscellaneous Journals, and prevents
33+
the setting to be modified.
3334

3435
The goal is to assure that all journal entries are locked when posted to
3536
prevent them to be modified.
3637

38+
Bank and Cash journals can't be hashed as it conflicts with Odoo's logic
39+
when creating bank transactions
40+
(https://github.com/odoo/odoo/commit/9740189bc59658a62da6a624e166505841ac30a4).
41+
3742
**Table of contents**
3843

3944
.. contents::
4045
:local:
4146

42-
Known issues / Roadmap
43-
======================
44-
45-
- Odoo hides the setting *Lock Posted Entries with Hash* on Bank and
46-
Cash Journals, but enabling it does not cause issues in the
47-
reconciliation for now. If the Odoo logic changes at any point, the
48-
module may need to be adapted to only force the setting on other types
49-
of journals.
50-
5147
Bug Tracker
5248
===========
5349

@@ -69,7 +65,7 @@ Authors
6965
Contributors
7066
------------
7167

72-
- Jordi Masvidal <jordi.masvidal@forgeflow.com>
68+
- Jordi Masvidal <jordi.masvidal@forgeflow.com>
7369

7470
Maintainers
7571
-----------

account_journal_restrict_mode/hooks.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
def post_init_hook(env):
66
"""Enable restrict mode on all journals"""
77
journals_to_update = env["account.journal"].search(
8-
[("restrict_mode_hash_table", "=", False)]
8+
[
9+
("restrict_mode_hash_table", "=", False),
10+
("type", "in", ["sale", "purchase", "general"]),
11+
]
912
)
1013
journals_to_update.write({"restrict_mode_hash_table": True})

account_journal_restrict_mode/models/account_journal.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,25 @@
88
class AccountJournal(models.Model):
99
_inherit = "account.journal"
1010

11-
restrict_mode_hash_table = fields.Boolean(default=True, readonly=True)
11+
restrict_mode_hash_table = fields.Boolean(readonly=True)
1212

1313
@api.constrains("restrict_mode_hash_table")
1414
def _check_journal_restrict_mode(self):
1515
for rec in self:
16-
if not rec.restrict_mode_hash_table:
16+
if not rec.restrict_mode_hash_table and rec.type in [
17+
"sale",
18+
"purchase",
19+
"general",
20+
]:
1721
raise UserError(
1822
self.env._("Journal %s must have Lock Posted Entries enabled.")
1923
% rec.name
2024
)
25+
26+
@api.onchange("type")
27+
def _onchange_type_restrict_mode(self):
28+
for rec in self:
29+
if rec.type in ["sale", "purchase", "general"]:
30+
rec.restrict_mode_hash_table = True
31+
else:
32+
rec.restrict_mode_hash_table = False
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
This module enables by default the setting *Lock Posted Entries with
2-
Hash* in all Journals and prevents the setting to be modified.
2+
Hash* in all Sales, Purchase and Miscellaneous Journals, and prevents
3+
the setting to be modified.
34

45
The goal is to assure that all journal entries are locked when posted to
56
prevent them to be modified.
7+
8+
Bank and Cash journals can't be hashed as it conflicts with Odoo's logic when
9+
creating bank transactions (https://github.com/odoo/odoo/commit/9740189bc59658a62da6a624e166505841ac30a4).

account_journal_restrict_mode/readme/ROADMAP.md

-5
This file was deleted.

account_journal_restrict_mode/static/description/index.html

+15-22
Original file line numberDiff line numberDiff line change
@@ -371,56 +371,49 @@ <h1 class="title">Account Journal Restrict Mode</h1>
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372372
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-financial-tools/tree/18.0/account_journal_restrict_mode"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-financial-tools-18-0/account-financial-tools-18-0-account_journal_restrict_mode"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373373
<p>This module enables by default the setting <em>Lock Posted Entries with
374-
Hash</em> in all Journals and prevents the setting to be modified.</p>
374+
Hash</em> in all Sales, Purchase and Miscellaneous Journals, and prevents
375+
the setting to be modified.</p>
375376
<p>The goal is to assure that all journal entries are locked when posted to
376377
prevent them to be modified.</p>
378+
<p>Bank and Cash journals can’t be hashed as it conflicts with Odoo’s logic
379+
when creating bank transactions
380+
(<a class="reference external" href="https://github.com/odoo/odoo/commit/9740189bc59658a62da6a624e166505841ac30a4">https://github.com/odoo/odoo/commit/9740189bc59658a62da6a624e166505841ac30a4</a>).</p>
377381
<p><strong>Table of contents</strong></p>
378382
<div class="contents local topic" id="contents">
379383
<ul class="simple">
380-
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-1">Known issues / Roadmap</a></li>
381-
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
382-
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
383-
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
384-
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
385-
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
384+
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-1">Bug Tracker</a></li>
385+
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
386+
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
387+
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
388+
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
386389
</ul>
387390
</li>
388391
</ul>
389392
</div>
390-
<div class="section" id="known-issues-roadmap">
391-
<h1><a class="toc-backref" href="#toc-entry-1">Known issues / Roadmap</a></h1>
392-
<ul class="simple">
393-
<li>Odoo hides the setting <em>Lock Posted Entries with Hash</em> on Bank and
394-
Cash Journals, but enabling it does not cause issues in the
395-
reconciliation for now. If the Odoo logic changes at any point, the
396-
module may need to be adapted to only force the setting on other types
397-
of journals.</li>
398-
</ul>
399-
</div>
400393
<div class="section" id="bug-tracker">
401-
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
394+
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
402395
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-tools/issues">GitHub Issues</a>.
403396
In case of trouble, please check there if your issue has already been reported.
404397
If you spotted it first, help us to smash it by providing a detailed and welcomed
405398
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_journal_restrict_mode%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
406399
<p>Do not contact contributors directly about support or help with technical issues.</p>
407400
</div>
408401
<div class="section" id="credits">
409-
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
402+
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
410403
<div class="section" id="authors">
411-
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
404+
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
412405
<ul class="simple">
413406
<li>ForgeFlow S.L.</li>
414407
</ul>
415408
</div>
416409
<div class="section" id="contributors">
417-
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
410+
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
418411
<ul class="simple">
419412
<li>Jordi Masvidal &lt;<a class="reference external" href="mailto:jordi.masvidal&#64;forgeflow.com">jordi.masvidal&#64;forgeflow.com</a>&gt;</li>
420413
</ul>
421414
</div>
422415
<div class="section" id="maintainers">
423-
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
416+
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
424417
<p>This module is maintained by the OCA.</p>
425418
<a class="reference external image-reference" href="https://odoo-community.org">
426419
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />

0 commit comments

Comments
 (0)