[IMP] account_journal_lock_date: two dates per journal
- Change in journal the existing 'Lock date' by two dates, the same as in company. - Add a wizard to allows a massive update of those dates for several journals at the same time.
This commit is contained in:
parent
6e1f206475
commit
0464802099
@ -27,26 +27,43 @@ Account Journal Lock Date
|
||||
|
||||
Lock each accounting journal independently.
|
||||
|
||||
In addition to the lock dates provided by standard Odoo and
|
||||
account_permanent_lock_move, provide a per journal lock date.
|
||||
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.
|
||||
|
||||
Note: this module depends on account_permanent_lock_move because it
|
||||
implements stricter checks than standard Odoo, such as verifying that
|
||||
one cannot create draft moves before the lock date.
|
||||
|
||||
Note: the journal lock date is ignored for users that are part of
|
||||
the Adviser group. This rule can be adapted by overriding method
|
||||
`_can_bypass_journal_lock_date` of `account.journal`.
|
||||
This module also adds a wizard that allows you to update the 'Lock Date'
|
||||
and the 'Lock Date for Non-Advisers' for several Journals at the same time.
|
||||
|
||||
**Table of contents**
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
To configure this module, you need to:
|
||||
|
||||
#. Go to *Invoicing > Configuration > Journals*
|
||||
#. Open a Journal and set the 'Lock Date' and the 'Lock Date for Non-Advisers'
|
||||
in the' Advanced Settings' tab of the form view or select several
|
||||
Journals in the list view and click on the action menu
|
||||
'Update journals lock dates' to update those dates for the selected
|
||||
journals at the same time.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
If the logged-in user has the access group 'Adviser', he/she will
|
||||
not be able to create a journal entry if the 'Lock Date' of the
|
||||
journal is greater than or equal to the journal entry.
|
||||
|
||||
If the logged-in user has not the access group 'Adviser', he/she will
|
||||
not be able to create a journal entry if the 'Lock Date for Non-Advisers'
|
||||
of the journal is greater than or equal to the journal entry.
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
* a wizard to set the lock date on several journals could be nice to have
|
||||
* the module does not check that all moves prior the lock date are posted, this could be
|
||||
made as part of the wizard
|
||||
|
||||
@ -81,6 +98,7 @@ Contributors
|
||||
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||
|
||||
* Pedro M. Baeza
|
||||
* Ernesto Tejeda
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
@ -1 +1,4 @@
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import models
|
||||
from . import wizards
|
||||
|
@ -5,7 +5,7 @@
|
||||
'name': 'Account Journal Lock Date',
|
||||
'summary': """
|
||||
Lock each journal independently""",
|
||||
'version': '12.0.1.0.0',
|
||||
'version': '12.0.2.0.0',
|
||||
'license': 'AGPL-3',
|
||||
'author': 'ACSONE SA/NV,Odoo Community Association (OCA)',
|
||||
'website': 'https://github.com/OCA/account-financial-tools',
|
||||
@ -14,6 +14,7 @@
|
||||
],
|
||||
'data': [
|
||||
'views/account_journal.xml',
|
||||
'wizards/update_journal_lock_dates_views.xml',
|
||||
],
|
||||
'demo': [
|
||||
],
|
||||
|
@ -4,8 +4,10 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Project-Id-Version: Odoo Server 12.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-20 04:25+0000\n"
|
||||
"PO-Revision-Date: 2020-08-20 04:25+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -14,8 +16,28 @@ msgstr ""
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model,name:account_journal_lock_date.model_account_move
|
||||
msgid "Account Entry"
|
||||
#: model_terms:ir.ui.view,arch_db:account_journal_lock_date.update_journal_lock_dates_wizard_view_form
|
||||
msgid "Cancel"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_update_journal_lock_dates_wizard__create_uid
|
||||
msgid "Created by"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_update_journal_lock_dates_wizard__create_date
|
||||
msgid "Created on"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_update_journal_lock_dates_wizard__display_name
|
||||
msgid "Display Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_update_journal_lock_dates_wizard__id
|
||||
msgid "ID"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
@ -24,18 +46,77 @@ msgid "Journal"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_account_journal_journal_lock_date
|
||||
msgid "Lock date"
|
||||
#: model:ir.model,name:account_journal_lock_date.model_account_move
|
||||
msgid "Journal Entries"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,help:account_journal_lock_date.field_account_journal_journal_lock_date
|
||||
msgid "Moves cannot be entered nor modified in this journal prior to the lock date, unless the user has the Adviser role."
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_update_journal_lock_dates_wizard____last_update
|
||||
msgid "Last Modified on"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: code:addons/account_journal_lock_date/models/account_move.py:23
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_update_journal_lock_dates_wizard__write_uid
|
||||
msgid "Last Updated by"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_update_journal_lock_dates_wizard__write_date
|
||||
msgid "Last Updated on"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_account_journal__fiscalyear_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_update_journal_lock_dates_wizard__fiscalyear_lock_date
|
||||
msgid "Lock Date"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_account_journal__period_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_update_journal_lock_dates_wizard__period_lock_date
|
||||
msgid "Lock Date for Non-Advisers"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model,name:account_journal_lock_date.model_update_journal_lock_dates_wizard
|
||||
msgid "Mass Update Journal Lock Dates Wizard"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,help:account_journal_lock_date.field_account_journal__fiscalyear_lock_date
|
||||
msgid "No users, including Advisers, can edit accounts prior to and inclusive of this date for this journal. Use it for fiscal year locking for this journal, for example."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,help:account_journal_lock_date.field_account_journal__period_lock_date
|
||||
msgid "Only users with the 'Adviser' role can edit accounts prior to and inclusive of this date for this journal. Use it for period locking inside an open fiscal year for this journal, for example."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model_terms:ir.ui.view,arch_db:account_journal_lock_date.update_journal_lock_dates_wizard_view_form
|
||||
msgid "Update"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.actions.act_window,name:account_journal_lock_date.update_journal_lock_dates_wizard_action
|
||||
msgid "Update journal lock dates"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: code:addons/account_journal_lock_date/wizards/update_journal_lock_dates.py:20
|
||||
#, python-format
|
||||
msgid "You cannot add/modify entries prior to and inclusive of the journal lock date %s"
|
||||
msgid "You are not allowed to execute this action."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: code:addons/account_journal_lock_date/models/account_move.py:39
|
||||
#, python-format
|
||||
msgid "You cannot add/modify entries for the journal '%s' prior to and inclusive of the lock date %s"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: code:addons/account_journal_lock_date/models/account_move.py:44
|
||||
#, python-format
|
||||
msgid "You cannot add/modify entries for the journal '%s' prior to and inclusive of the lock date %s. Check the Journal settings or ask someone with the 'Adviser' role"
|
||||
msgstr ""
|
||||
|
||||
|
@ -8,20 +8,41 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-05-30 00:47+0000\n"
|
||||
"PO-Revision-Date: 2017-05-30 00:47+0000\n"
|
||||
"POT-Creation-Date: 2020-08-20 04:25+0000\n"
|
||||
"PO-Revision-Date: 2020-08-20 00:52-0400\n"
|
||||
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n"
|
||||
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n"
|
||||
"Language: es\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Generator: Poedit 2.0.6\n"
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model,name:account_journal_lock_date.model_account_move
|
||||
msgid "Account Entry"
|
||||
msgstr "Asiento contable"
|
||||
#: model_terms:ir.ui.view,arch_db:account_journal_lock_date.update_journal_lock_dates_wizard_view_form
|
||||
msgid "Cancel"
|
||||
msgstr "Cancelar"
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_update_journal_lock_dates_wizard__create_uid
|
||||
msgid "Created by"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_update_journal_lock_dates_wizard__create_date
|
||||
msgid "Created on"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_update_journal_lock_dates_wizard__display_name
|
||||
msgid "Display Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_update_journal_lock_dates_wizard__id
|
||||
msgid "ID"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model,name:account_journal_lock_date.model_account_journal
|
||||
@ -29,21 +50,101 @@ msgid "Journal"
|
||||
msgstr "Diario"
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_account_journal_journal_lock_date
|
||||
msgid "Lock date"
|
||||
#: model:ir.model,name:account_journal_lock_date.model_account_move
|
||||
msgid "Journal Entries"
|
||||
msgstr "Asientos Contables"
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_update_journal_lock_dates_wizard____last_update
|
||||
msgid "Last Modified on"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,help:account_journal_lock_date.field_account_journal_journal_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_update_journal_lock_dates_wizard__write_uid
|
||||
msgid "Last Updated by"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_update_journal_lock_dates_wizard__write_date
|
||||
msgid "Last Updated on"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_account_journal__fiscalyear_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_update_journal_lock_dates_wizard__fiscalyear_lock_date
|
||||
msgid "Lock Date"
|
||||
msgstr "Fecha de bloqueo"
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_account_journal__period_lock_date
|
||||
#: model:ir.model.fields,field_description:account_journal_lock_date.field_update_journal_lock_dates_wizard__period_lock_date
|
||||
msgid "Lock Date for Non-Advisers"
|
||||
msgstr "Fecha de bloqueo para no asesores"
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model,name:account_journal_lock_date.model_update_journal_lock_dates_wizard
|
||||
msgid "Mass Update Journal Lock Dates Wizard"
|
||||
msgstr "Asistente para la actualización masiva de fechas de bloqueo"
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.model.fields,help:account_journal_lock_date.field_account_journal__fiscalyear_lock_date
|
||||
msgid ""
|
||||
"Moves cannot be entered nor modified in this journal prior to the lock date, "
|
||||
"unless the user has the Adviser role."
|
||||
"No users, including Advisers, can edit accounts prior to and inclusive of "
|
||||
"this date for this journal. Use it for fiscal year locking for this journal, "
|
||||
"for example."
|
||||
msgstr ""
|
||||
"Ningún usuario, incluyendo Asesores, pueden editar cuentas antes de y en "
|
||||
"esta fecha para este diario. Utilícela, por ejemplo, para bloquear un año "
|
||||
"fiscal para este Diario."
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: code:addons/account_journal_lock_date/models/account_move.py:23
|
||||
#: model:ir.model.fields,help:account_journal_lock_date.field_account_journal__period_lock_date
|
||||
msgid ""
|
||||
"Only users with the 'Adviser' role can edit accounts prior to and inclusive "
|
||||
"of this date for this journal. Use it for period locking inside an open "
|
||||
"fiscal year for this journal, for example."
|
||||
msgstr ""
|
||||
"Sólo los usuarios con el rol 'Asesor' pueden editar cuentas antes de y en "
|
||||
"esta fecha para este Diario. Utilícelo para bloquear un período dentro de un "
|
||||
"año fiscal abierto para este diario, por ejemplo."
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model_terms:ir.ui.view,arch_db:account_journal_lock_date.update_journal_lock_dates_wizard_view_form
|
||||
msgid "Update"
|
||||
msgstr "Actualizar"
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: model:ir.actions.act_window,name:account_journal_lock_date.update_journal_lock_dates_wizard_action
|
||||
msgid "Update journal lock dates"
|
||||
msgstr "Actualizar fechas de bloqueo"
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: code:addons/account_journal_lock_date/wizards/update_journal_lock_dates.py:20
|
||||
#, python-format
|
||||
msgid "You are not allowed to execute this action."
|
||||
msgstr "No está autorizado a realizar esta acción."
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: code:addons/account_journal_lock_date/models/account_move.py:39
|
||||
#, python-format
|
||||
msgid ""
|
||||
"You cannot add/modify entries prior to and inclusive of the journal lock "
|
||||
"date %s"
|
||||
"You cannot add/modify entries for the journal '%s' prior to and inclusive of "
|
||||
"the lock date %s"
|
||||
msgstr ""
|
||||
"No puede añadir/modificar asientos para el diario '%s' con anterioridad y "
|
||||
"hasta la fecha de bloqueo %s"
|
||||
|
||||
#. module: account_journal_lock_date
|
||||
#: code:addons/account_journal_lock_date/models/account_move.py:44
|
||||
#, python-format
|
||||
msgid ""
|
||||
"You cannot add/modify entries for the journal '%s' prior to and inclusive of "
|
||||
"the lock date %s. Check the Journal settings or ask someone with the "
|
||||
"'Adviser' role"
|
||||
msgstr ""
|
||||
"No puede añadir/modificar asientos para el Diario '%s' con anterioridad y "
|
||||
"hasta la fecha de bloqueo %s. Compruebe la configuración del Diario o "
|
||||
"pregunte a alguien con el grupo de acceso 'Asesor'"
|
||||
|
||||
#~ msgid "Account Entry"
|
||||
#~ msgstr "Asiento contable"
|
||||
|
@ -1,22 +1,23 @@
|
||||
# Copyright 2017 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AccountJournal(models.Model):
|
||||
|
||||
_inherit = 'account.journal'
|
||||
|
||||
journal_lock_date = fields.Date(
|
||||
string="Lock date",
|
||||
help="Moves cannot be entered nor modified in this "
|
||||
"journal prior to the lock date, unless the user "
|
||||
"has the Adviser role."
|
||||
fiscalyear_lock_date = fields.Date(
|
||||
string="Lock Date",
|
||||
help="No users, including Advisers, can edit accounts prior "
|
||||
"to and inclusive of this date for this journal. Use it "
|
||||
"for fiscal year locking for this journal, for example."
|
||||
)
|
||||
period_lock_date = fields.Date(
|
||||
string="Lock Date for Non-Advisers",
|
||||
help="Only users with the 'Adviser' role can edit accounts "
|
||||
"prior to and inclusive of this date for this journal. "
|
||||
"Use it for period locking inside an open fiscal year "
|
||||
"for this journal, for example."
|
||||
)
|
||||
|
||||
@api.model
|
||||
def _can_bypass_journal_lock_date(self):
|
||||
""" This method is meant to be overridden to provide
|
||||
finer control on who can bypass the lock date """
|
||||
return self.env.user.has_group('account.group_account_manager')
|
||||
|
@ -1,6 +1,7 @@
|
||||
# Copyright 2017 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from datetime import date
|
||||
from odoo import api, models, _
|
||||
|
||||
from ..exceptions import JournalLockDateError
|
||||
@ -23,16 +24,30 @@ class AccountMove(models.Model):
|
||||
self._check_lock_date()
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def _check_lock_date(self):
|
||||
res = super(AccountMove, self)._check_lock_date()
|
||||
if self.env['account.journal']._can_bypass_journal_lock_date():
|
||||
res = super()._check_lock_date()
|
||||
if self.env.context.get("bypass_journal_lock_date"):
|
||||
return res
|
||||
for move in self:
|
||||
lock_date = move.journal_id.journal_lock_date
|
||||
if lock_date and move.date <= lock_date:
|
||||
raise JournalLockDateError(
|
||||
_("You cannot add/modify entries prior to and "
|
||||
"inclusive of the journal lock date %s") %
|
||||
(lock_date, ))
|
||||
if self.user_has_groups('account.group_account_manager'):
|
||||
lock_date = move.journal_id.fiscalyear_lock_date or date.min
|
||||
else:
|
||||
lock_date = max(
|
||||
move.journal_id.period_lock_date or date.min,
|
||||
move.journal_id.fiscalyear_lock_date or date.min,
|
||||
)
|
||||
if move.date <= lock_date:
|
||||
if self.user_has_groups('account.group_account_manager'):
|
||||
message = _(
|
||||
"You cannot add/modify entries for the journal '%s' "
|
||||
"prior to and inclusive of the lock date %s"
|
||||
) % (move.journal_id.display_name, lock_date)
|
||||
else:
|
||||
message = _(
|
||||
"You cannot add/modify entries for the journal '%s' "
|
||||
"prior to and inclusive of the lock date %s. "
|
||||
"Check the Journal settings or ask someone "
|
||||
"with the 'Adviser' role"
|
||||
) % (move.journal_id.display_name, lock_date)
|
||||
raise JournalLockDateError(message)
|
||||
return res
|
||||
|
8
account_journal_lock_date/readme/CONFIGURE.rst
Normal file
8
account_journal_lock_date/readme/CONFIGURE.rst
Normal file
@ -0,0 +1,8 @@
|
||||
To configure this module, you need to:
|
||||
|
||||
#. Go to *Invoicing > Configuration > Journals*
|
||||
#. Open a Journal and set the 'Lock Date' and the 'Lock Date for Non-Advisers'
|
||||
in the' Advanced Settings' tab of the form view or select several
|
||||
Journals in the list view and click on the action menu
|
||||
'Update journals lock dates' to update those dates for the selected
|
||||
journals at the same time.
|
@ -8,3 +8,4 @@
|
||||
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||
|
||||
* Pedro M. Baeza
|
||||
* Ernesto Tejeda
|
||||
|
@ -1,12 +1,7 @@
|
||||
Lock each accounting journal independently.
|
||||
|
||||
In addition to the lock dates provided by standard Odoo and
|
||||
account_permanent_lock_move, provide a per journal lock date.
|
||||
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.
|
||||
|
||||
Note: this module depends on account_permanent_lock_move because it
|
||||
implements stricter checks than standard Odoo, such as verifying that
|
||||
one cannot create draft moves before the lock date.
|
||||
|
||||
Note: the journal lock date is ignored for users that are part of
|
||||
the Adviser group. This rule can be adapted by overriding method
|
||||
`_can_bypass_journal_lock_date` of `account.journal`.
|
||||
This module also adds a wizard that allows you to update the 'Lock Date'
|
||||
and the 'Lock Date for Non-Advisers' for several Journals at the same time.
|
||||
|
@ -1,3 +1,2 @@
|
||||
* a wizard to set the lock date on several journals could be nice to have
|
||||
* the module does not check that all moves prior the lock date are posted, this could be
|
||||
made as part of the wizard
|
7
account_journal_lock_date/readme/USAGE.rst
Normal file
7
account_journal_lock_date/readme/USAGE.rst
Normal file
@ -0,0 +1,7 @@
|
||||
If the logged-in user has the access group 'Adviser', he/she will
|
||||
not be able to create a journal entry if the 'Lock Date' of the
|
||||
journal is greater than or equal to the journal entry.
|
||||
|
||||
If the logged-in user has not the access group 'Adviser', he/she will
|
||||
not be able to create a journal entry if the 'Lock Date for Non-Advisers'
|
||||
of the journal is greater than or equal to the journal entry.
|
@ -3,7 +3,7 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
|
||||
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
|
||||
<title>Account Journal Lock Date</title>
|
||||
<style type="text/css">
|
||||
|
||||
@ -369,37 +369,55 @@ ul.auto-toc {
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" 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" 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" href="https://github.com/OCA/account-financial-tools/tree/12.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" href="https://translation.odoo-community.org/projects/account-financial-tools-12-0/account-financial-tools-12-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" href="https://runbot.odoo-community.org/runbot/92/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>Lock each accounting journal independently.</p>
|
||||
<p>In addition to the lock dates provided by standard Odoo and
|
||||
account_permanent_lock_move, provide a per journal lock date.</p>
|
||||
<p>Note: this module depends on account_permanent_lock_move because it
|
||||
implements stricter checks than standard Odoo, such as verifying that
|
||||
one cannot create draft moves before the lock date.</p>
|
||||
<p>Note: the journal lock date is ignored for users that are part of
|
||||
the Adviser group. This rule can be adapted by overriding method
|
||||
<cite>_can_bypass_journal_lock_date</cite> of <cite>account.journal</cite>.</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>
|
||||
<p>This module also adds a wizard that allows you to update the ‘Lock Date’
|
||||
and the ‘Lock Date for Non-Advisers’ for several Journals at the same time.</p>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
<div class="contents local topic" id="contents">
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#known-issues-roadmap" id="id1">Known issues / Roadmap</a></li>
|
||||
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li>
|
||||
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
|
||||
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
|
||||
<li><a class="reference internal" href="#usage" id="id2">Usage</a></li>
|
||||
<li><a class="reference internal" href="#known-issues-roadmap" id="id3">Known issues / Roadmap</a></li>
|
||||
<li><a class="reference internal" href="#bug-tracker" id="id4">Bug Tracker</a></li>
|
||||
<li><a class="reference internal" href="#credits" id="id5">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="id6">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="id7">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="id8">Maintainers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="configuration">
|
||||
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
|
||||
<p>To configure this module, you need to:</p>
|
||||
<ol class="arabic simple">
|
||||
<li>Go to <em>Invoicing > Configuration > Journals</em></li>
|
||||
<li>Open a Journal and set the ‘Lock Date’ and the ‘Lock Date for Non-Advisers’
|
||||
in the’ Advanced Settings’ tab of the form view or select several
|
||||
Journals in the list view and click on the action menu
|
||||
‘Update journals lock dates’ to update those dates for the selected
|
||||
journals at the same time.</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="section" id="usage">
|
||||
<h1><a class="toc-backref" href="#id2">Usage</a></h1>
|
||||
<p>If the logged-in user has the access group ‘Adviser’, he/she will
|
||||
not be able to create a journal entry if the ‘Lock Date’ of the
|
||||
journal is greater than or equal to the journal entry.</p>
|
||||
<p>If the logged-in user has not the access group ‘Adviser’, he/she will
|
||||
not be able to create a journal entry if the ‘Lock Date for Non-Advisers’
|
||||
of the journal is greater than or equal to the journal entry.</p>
|
||||
</div>
|
||||
<div class="section" id="known-issues-roadmap">
|
||||
<h1><a class="toc-backref" href="#id1">Known issues / Roadmap</a></h1>
|
||||
<h1><a class="toc-backref" href="#id3">Known issues / Roadmap</a></h1>
|
||||
<ul class="simple">
|
||||
<li>a wizard to set the lock date on several journals could be nice to have</li>
|
||||
<li>the module does not check that all moves prior the lock date are posted, this could be
|
||||
made as part of the wizard</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
|
||||
<h1><a class="toc-backref" href="#id4">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 smashing it by providing a detailed and welcomed
|
||||
@ -407,15 +425,15 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
<h1><a class="toc-backref" href="#id3">Credits</a></h1>
|
||||
<h1><a class="toc-backref" href="#id5">Credits</a></h1>
|
||||
<div class="section" id="authors">
|
||||
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
|
||||
<h2><a class="toc-backref" href="#id6">Authors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>ACSONE SA/NV</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="contributors">
|
||||
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
|
||||
<h2><a class="toc-backref" href="#id7">Contributors</a></h2>
|
||||
<ul class="simple">
|
||||
<li><a class="reference external" href="https://www.akretion.com">Akretion</a>:<ul>
|
||||
<li>Benoît GUILLOT <<a class="reference external" href="mailto:benoit.guillot@akretion.com">benoit.guillot@akretion.com</a>></li>
|
||||
@ -426,12 +444,13 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
</li>
|
||||
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
|
||||
<li>Pedro M. Baeza</li>
|
||||
<li>Ernesto Tejeda</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
|
||||
<h2><a class="toc-backref" href="#id8">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>
|
||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
from datetime import date, timedelta
|
||||
|
||||
from odoo import fields, tools
|
||||
from odoo import tools
|
||||
from odoo.modules import get_module_resource
|
||||
from odoo.tests import common
|
||||
|
||||
@ -39,7 +39,7 @@ class TestJournalLockDate(common.TransactionCase):
|
||||
|
||||
# create a move and post it
|
||||
move = self.account_move_obj.create({
|
||||
'date': fields.Date.today(),
|
||||
'date': date.today(),
|
||||
'journal_id': self.journal.id,
|
||||
'line_ids': [(0, 0, {
|
||||
'account_id': self.account.id,
|
||||
@ -52,14 +52,12 @@ class TestJournalLockDate(common.TransactionCase):
|
||||
})]
|
||||
})
|
||||
move.post()
|
||||
|
||||
# lock journal
|
||||
self.journal.journal_lock_date = fields.Date.today()
|
||||
|
||||
# lock journal, set 'Lock Date for Non-Advisers'
|
||||
self.journal.period_lock_date = (date.today() + timedelta(days=2))
|
||||
# Test that the move cannot be created, written, or cancelled
|
||||
with self.assertRaises(JournalLockDateError):
|
||||
self.account_move_obj.create({
|
||||
'date': fields.Date.today(),
|
||||
'date': date.today(),
|
||||
'journal_id': self.journal.id,
|
||||
'line_ids': [(0, 0, {
|
||||
'account_id': self.account.id,
|
||||
@ -80,10 +78,9 @@ class TestJournalLockDate(common.TransactionCase):
|
||||
with self.assertRaises(JournalLockDateError):
|
||||
move.button_cancel()
|
||||
|
||||
# create a move after the lock date and post it
|
||||
tomorrow = date.today() + timedelta(days=1)
|
||||
# create a move after the 'Lock Date for Non-Advisers' and post it
|
||||
move3 = self.account_move_obj.create({
|
||||
'date': tomorrow,
|
||||
'date': self.journal.period_lock_date + timedelta(days=3),
|
||||
'journal_id': self.journal.id,
|
||||
'line_ids': [(0, 0, {
|
||||
'account_id': self.account.id,
|
||||
@ -104,13 +101,9 @@ class TestJournalLockDate(common.TransactionCase):
|
||||
})
|
||||
self.assertTrue(self.env.user.has_group(
|
||||
'account.group_account_manager'))
|
||||
|
||||
# lock journal
|
||||
self.journal.journal_lock_date = fields.Date.today()
|
||||
|
||||
# advisers can create moves before or on the lock date
|
||||
self.account_move_obj.create({
|
||||
'date': fields.Date.today(),
|
||||
# create a move and post it
|
||||
move = self.account_move_obj.create({
|
||||
'date': date.today(),
|
||||
'journal_id': self.journal.id,
|
||||
'line_ids': [(0, 0, {
|
||||
'account_id': self.account.id,
|
||||
@ -122,3 +115,46 @@ class TestJournalLockDate(common.TransactionCase):
|
||||
'name': 'Debit line',
|
||||
})]
|
||||
})
|
||||
move.post()
|
||||
# lock journal. Set 'Lock Date'
|
||||
self.journal.fiscalyear_lock_date = date.today() + timedelta(days=2)
|
||||
# lock journal. Set 'Lock Date for Non-Advisers'
|
||||
self.journal.period_lock_date = date.today() + timedelta(days=4)
|
||||
# Advisers cannot create, write, or cancel moves before 'Lock Date'
|
||||
with self.assertRaises(JournalLockDateError):
|
||||
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',
|
||||
})]
|
||||
})
|
||||
with self.assertRaises(JournalLockDateError):
|
||||
move.write({'name': 'TEST'})
|
||||
# allow cancel posted move
|
||||
self.journal.update_posted = True
|
||||
with self.assertRaises(JournalLockDateError):
|
||||
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)
|
||||
move3 = 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',
|
||||
})]
|
||||
})
|
||||
move3.post()
|
||||
|
@ -10,8 +10,9 @@
|
||||
<field name="model">account.journal</field>
|
||||
<field name="inherit_id" ref="account.view_account_journal_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="type" position="after">
|
||||
<field name="journal_lock_date"/>
|
||||
<field name="account_control_ids" position="after">
|
||||
<field name="fiscalyear_lock_date"/>
|
||||
<field name="period_lock_date"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@ -23,7 +24,8 @@
|
||||
<field name="inherit_id" ref="account.view_account_journal_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="type" position="after">
|
||||
<field name="journal_lock_date"/>
|
||||
<field name="fiscalyear_lock_date"/>
|
||||
<field name="period_lock_date"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
3
account_journal_lock_date/wizards/__init__.py
Normal file
3
account_journal_lock_date/wizards/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import update_journal_lock_dates
|
@ -0,0 +1,30 @@
|
||||
# Copyright 2020 Tecnativa - Ernesto Tejeda
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import _, fields, models, SUPERUSER_ID
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class UpdateJournalLockDatesWizard(models.TransientModel):
|
||||
_name = 'update.journal.lock.dates.wizard'
|
||||
_description = 'Mass Update Journal Lock Dates Wizard'
|
||||
|
||||
period_lock_date = fields.Date(string="Lock Date for Non-Advisers")
|
||||
fiscalyear_lock_date = fields.Date(string="Lock Date")
|
||||
|
||||
def _check_execute_allowed(self):
|
||||
self.ensure_one()
|
||||
has_adviser_group = self.env.user.has_group(
|
||||
'account.group_account_manager')
|
||||
if not (has_adviser_group or self.env.uid == SUPERUSER_ID):
|
||||
raise UserError(_("You are not allowed to execute this action."))
|
||||
|
||||
def action_update_lock_dates(self):
|
||||
self.ensure_one()
|
||||
self._check_execute_allowed()
|
||||
self.env['account.journal'].browse(
|
||||
self.env.context.get('active_ids')
|
||||
).write({
|
||||
'period_lock_date': self.period_lock_date,
|
||||
'fiscalyear_lock_date': self.fiscalyear_lock_date,
|
||||
})
|
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright 2020 Tecnativa - Ernesto Tejeda
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
|
||||
<odoo>
|
||||
<record id="update_journal_lock_dates_wizard_view_form" model="ir.ui.view">
|
||||
<field name="name">update.journal.lock.dates.wizard.form</field>
|
||||
<field name="model">update.journal.lock.dates.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<group>
|
||||
<group>
|
||||
<field name="fiscalyear_lock_date"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="period_lock_date"/>
|
||||
</group>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="action_update_lock_dates"
|
||||
string="Update"
|
||||
type="object"
|
||||
class="btn-primary"/>
|
||||
<button string="Cancel"
|
||||
class="btn-secondary"
|
||||
special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<act_window id="update_journal_lock_dates_wizard_action"
|
||||
name="Update journals lock dates"
|
||||
src_model="account.journal"
|
||||
res_model="update.journal.lock.dates.wizard"
|
||||
view_type="form"
|
||||
view_mode="form"
|
||||
key2="client_action_multi"
|
||||
target="new"
|
||||
multi="True"/>
|
||||
</odoo>
|
Loading…
Reference in New Issue
Block a user