Skip to content

Commit

Permalink
[MIG] account_journal_lock_date: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HeliconiaSolutions committed Jan 2, 2025
1 parent 9dc218b commit 9a720d9
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 128 deletions.
36 changes: 19 additions & 17 deletions account_journal_lock_date/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Account Journal Lock Date
: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/17.0/account_journal_lock_date
:target: https://github.com/OCA/account-financial-tools/tree/18.0/account_journal_lock_date
: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-17-0/account-financial-tools-17-0-account_journal_lock_date
:target: https://translation.odoo-community.org/projects/account-financial-tools-18-0/account-financial-tools-18-0-account_journal_lock_date
: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=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -69,16 +69,16 @@ entry.
Known issues / Roadmap
======================

- the module does not check that all moves prior the lock date are
posted, this could be made as part of the wizard
- the module does not check that all moves prior the lock date are
posted, this could be made as part of the wizard

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-tools/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 <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_journal_lock_date%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_journal_lock_date%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Expand All @@ -94,21 +94,23 @@ Authors
Contributors
------------

- `Akretion <https://www.akretion.com>`__:
- `Akretion <https://www.akretion.com>`__:

- Benoît GUILLOT <[email protected]>
- Chafique DELLI <[email protected]>
- Alexis de Lattre <[email protected]>
- Mourad EL HADJ MIMOUNE <[email protected]>
- Benoît GUILLOT <[email protected]>
- Chafique DELLI <[email protected]>
- Alexis de Lattre <[email protected]>
- Mourad EL HADJ MIMOUNE <[email protected]>

- `Tecnativa <https://www.tecnativa.com>`__:
- `Tecnativa <https://www.tecnativa.com>`__:

- Pedro M. Baeza
- Ernesto Tejeda
- Pedro M. Baeza
- Ernesto Tejeda

- `Factor Libre <https://www.factorlibre.com>`__:
- `Factor Libre <https://www.factorlibre.com>`__:

- Rodrigo Bonilla Martinez <[email protected]>
- Rodrigo Bonilla Martinez <[email protected]>

- ``Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>``\ \_

Maintainers
-----------
Expand All @@ -123,6 +125,6 @@ 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 <https://github.com/OCA/account-financial-tools/tree/17.0/account_journal_lock_date>`_ project on GitHub.
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/18.0/account_journal_lock_date>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion account_journal_lock_date/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Account Journal Lock Date",
"summary": "Lock each journal independently",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV, Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-financial-tools",
Expand Down
8 changes: 4 additions & 4 deletions account_journal_lock_date/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
class AccountMove(models.Model):
_inherit = "account.move"

def _check_fiscalyear_lock_date(self):
res = super()._check_fiscalyear_lock_date()
def _check_fiscal_lock_dates(self):
res = super()._check_fiscal_lock_dates()
if self.env.context.get("bypass_journal_lock_date"):
return res

date_min = fields.date.min
for move in self:
if self.user_has_groups("account.group_account_manager"):
if self.env.user.has_group("account.group_account_manager"):
lock_date = move.journal_id.fiscalyear_lock_date or date_min
else:
lock_date = max(
Expand All @@ -25,7 +25,7 @@ def _check_fiscalyear_lock_date(self):
)
if move.date <= lock_date:
lock_date = format_date(self.env, lock_date)
if self.user_has_groups("account.group_account_manager"):
if self.env.user.has_group("account.group_account_manager"):
message = _(

Check warning on line 29 in account_journal_lock_date/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

account_journal_lock_date/models/account_move.py#L29

Added line #L29 was not covered by tests
"You cannot add/modify entries for the journal '%(journal)s' "
"prior to and inclusive of the lock date %(journal_date)s"
Expand Down
1 change: 1 addition & 0 deletions account_journal_lock_date/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
- Ernesto Tejeda
- [Factor Libre](https://www.factorlibre.com):
- Rodrigo Bonilla Martinez \<<[email protected]>\>
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`_
18 changes: 11 additions & 7 deletions account_journal_lock_date/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -368,7 +369,7 @@ <h1 class="title">Account Journal Lock Date</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:cd335b11f1bbc561bf62345e5d9d1c702a74199b7dd180df5da89d7be2e42346
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/17.0/account_journal_lock_date"><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-17-0/account-financial-tools-17-0-account_journal_lock_date"><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=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<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_lock_date"><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_lock_date"><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>
<p>Lock each accounting journal independently.</p>
<p>In addition to the lock dates provided by standard Odoo, this module
provides a ‘Lock Date’ and a ‘Lock Date for Non-Advisers’ per journal.</p>
Expand Down Expand Up @@ -424,7 +425,7 @@ <h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-tools/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_journal_lock_date%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_journal_lock_date%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -455,16 +456,19 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<li>Rodrigo Bonilla Martinez &lt;<a class="reference external" href="mailto:rodrigo.bonilla&#64;factorlibre.com">rodrigo.bonilla&#64;factorlibre.com</a>&gt;</li>
</ul>
</li>
<li><tt class="docutils literal">Heliconia Solutions Pvt. Ltd. <span class="pre">&lt;https://www.heliconia.io&gt;</span></tt>_</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/17.0/account_journal_lock_date">OCA/account-financial-tools</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/18.0/account_journal_lock_date">OCA/account-financial-tools</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
131 changes: 32 additions & 99 deletions account_journal_lock_date/tests/test_journal_lock_date.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from datetime import date, timedelta

from odoo.exceptions import UserError
Expand All @@ -22,36 +19,9 @@ def setUp(self):
self.account2 = self.company_data["default_account_expense"]
self.journal = self.company_data["default_journal_bank"]

# create a move and post it
self.move = self.account_move_obj.create(
{
"date": date.today(),
"journal_id": self.journal.id,
"line_ids": [
(
0,
0,
{
"account_id": self.account.id,
"credit": 1000.0,
"name": "Credit line",
},
),
(
0,
0,
{
"account_id": self.account2.id,
"debit": 1000.0,
"name": "Debit line",
},
),
],
}
)
self.move.action_post()
# lock journal, set 'Lock Date for Non-Advisers'
self.journal.period_lock_date = date.today() + timedelta(days=2)
self.lock_date = date.today()
self.journal.period_lock_date = self.lock_date

def test_journal_lock_date(self):
self.env.user.write({"groups_id": [(3, self.ref("base.group_system"))]})
Expand All @@ -60,21 +30,42 @@ def test_journal_lock_date(self):
)
self.assertFalse(self.env.user.has_group("account.group_account_manager"))

# Test that the move cannot be written, or cancelled
with self.assertRaisesRegex(
UserError, ".*prior to and inclusive of the lock date.*"
):
self.move.write({"name": "TEST"})

# Test that a new move cannot be created on lock date
with self.assertRaisesRegex(
UserError, ".*prior to and inclusive of the lock date.*"
):
self.move.button_cancel()
move = self.account_move_obj.create(
{
"date": self.lock_date,
"journal_id": self.journal.id,
"line_ids": [
(
0,
0,
{
"account_id": self.account.id,
"credit": 1000.0,
"name": "Credit line",
},
),
(
0,
0,
{
"account_id": self.account2.id,
"debit": 1000.0,
"name": "Debit line",
},
),
],
}
)
move.action_post()

# create a move after the 'Lock Date for Non-Advisers' and post it
move2 = self.account_move_obj.create(
{
"date": self.journal.period_lock_date + timedelta(days=3),
"date": self.lock_date + timedelta(days=3),
"journal_id": self.journal.id,
"line_ids": [
(
Expand Down Expand Up @@ -105,7 +96,7 @@ def test_journal_lock_date(self):
bypass_journal_lock_date=True
).create(
{
"date": self.journal.period_lock_date,
"date": self.lock_date,
"journal_id": self.journal.id,
"line_ids": [
(
Expand All @@ -130,61 +121,3 @@ def test_journal_lock_date(self):
}
)
move3.action_post()

def test_journal_lock_date_adviser(self):
"""The journal lock date is ignored for Advisers"""
self.env.user.write(
{"groups_id": [(4, self.env.ref("account.group_account_manager").id)]}
)
self.assertTrue(self.env.user.has_group("account.group_account_manager"))
wizard = (
self.env["update.journal.lock.dates.wizard"]
.with_context(active_model="account.journal", active_ids=self.journal.id)
.create(
{
"fiscalyear_lock_date": date.today() + timedelta(days=2),
"period_lock_date": date.today() + timedelta(days=4),
}
)
)
wizard.action_update_lock_dates()
# Advisers cannot write, or cancel moves before 'Lock Date'
with self.assertRaisesRegex(
UserError, ".*prior to and inclusive of the lock date.*"
):
self.move.write({"name": "TEST"})

with self.assertRaisesRegex(
UserError, ".*prior to and inclusive of the lock date.*"
):
self.move.button_cancel()
# Advisers can create movements on a date after the 'Lock Date'
# even if that date is before and inclusive of
# the 'Lock Date for Non-Advisers' (self.journal.period_lock_date)
move2 = self.account_move_obj.create(
{
"date": self.journal.period_lock_date,
"journal_id": self.journal.id,
"line_ids": [
(
0,
0,
{
"account_id": self.account.id,
"credit": 1000.0,
"name": "Credit line",
},
),
(
0,
0,
{
"account_id": self.account2.id,
"debit": 1000.0,
"name": "Debit line",
},
),
],
}
)
move2.action_post()

0 comments on commit 9a720d9

Please sign in to comment.