From 0c5b530e84350fbdb19c35c449bfce69a3b13295 Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Fri, 25 Nov 2022 17:57:35 +0100 Subject: [PATCH] [MIG] account_journal_lock_date: Migration to 16.0 --- account_journal_lock_date/__manifest__.py | 2 +- account_journal_lock_date/models/account_move.py | 12 ++++++------ account_journal_lock_date/readme/CONTRIBUTORS.rst | 4 ++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/account_journal_lock_date/__manifest__.py b/account_journal_lock_date/__manifest__.py index 40898486..d64a71dc 100644 --- a/account_journal_lock_date/__manifest__.py +++ b/account_journal_lock_date/__manifest__.py @@ -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", diff --git a/account_journal_lock_date/models/account_move.py b/account_journal_lock_date/models/account_move.py index 1d12981c..b194168e 100644 --- a/account_journal_lock_date/models/account_move.py +++ b/account_journal_lock_date/models/account_move.py @@ -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) diff --git a/account_journal_lock_date/readme/CONTRIBUTORS.rst b/account_journal_lock_date/readme/CONTRIBUTORS.rst index a644f445..b58874ab 100644 --- a/account_journal_lock_date/readme/CONTRIBUTORS.rst +++ b/account_journal_lock_date/readme/CONTRIBUTORS.rst @@ -9,3 +9,7 @@ * Pedro M. Baeza * Ernesto Tejeda + +* `Factor Libre `_: + + * Rodrigo Bonilla Martinez