2
0

[MIG] account_journal_lock_date: Migration to 16.0

This commit is contained in:
Rodrigo 2022-11-25 17:57:35 +01:00
parent 7826f7b9fd
commit 0c5b530e84
3 changed files with 11 additions and 7 deletions

View File

@ -4,7 +4,7 @@
{
"name": "Account Journal Lock Date",
"summary": "Lock each journal independently",
"version": "15.0.1.0.1",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV, Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-financial-tools",

View File

@ -1,9 +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 _, models
from odoo import _, fields, models
from odoo.exceptions import UserError
from odoo.tools.misc import format_date
@ -21,13 +19,15 @@ class AccountMove(models.Model):
res = super()._check_fiscalyear_lock_date()
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"):
lock_date = move.journal_id.fiscalyear_lock_date or date.min
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,
move.journal_id.period_lock_date or date_min,
move.journal_id.fiscalyear_lock_date or date_min,
)
if move.date <= lock_date:
lock_date = format_date(self.env, lock_date)

View File

@ -9,3 +9,7 @@
* Pedro M. Baeza
* Ernesto Tejeda
* `Factor Libre <https://www.factorlibre.com>`_:
* Rodrigo Bonilla Martinez <rodrigo.bonilla@factorlibre.com>