From 367a85c669ffedca43038805f1c18c835e87fc7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Alix?= Date: Fri, 22 Sep 2023 13:24:47 +0200 Subject: [PATCH] password_security: enable module on existing companies --- password_security/__manifest__.py | 2 +- .../migrations/15.0.1.2.0/post-migration.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 password_security/migrations/15.0.1.2.0/post-migration.py diff --git a/password_security/__manifest__.py b/password_security/__manifest__.py index a5408f9614..de5e4f4f80 100644 --- a/password_security/__manifest__.py +++ b/password_security/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Password Security", "summary": "Allow admin to set password security requirements.", - "version": "15.0.1.1.4", + "version": "15.0.1.2.0", "author": "LasLabs, " "Onestein, " "Kaushal Prajapati, " diff --git a/password_security/migrations/15.0.1.2.0/post-migration.py b/password_security/migrations/15.0.1.2.0/post-migration.py new file mode 100644 index 0000000000..6345ae26ba --- /dev/null +++ b/password_security/migrations/15.0.1.2.0/post-migration.py @@ -0,0 +1,17 @@ +# Copyright 2023 Camptocamp SA +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl) + +import logging + +from odoo import SUPERUSER_ID, api + +_logger = logging.getLogger(__name__) + + +def migrate(cr, version): + if not version: + return + env = api.Environment(cr, SUPERUSER_ID, {}) + companies = env["res.company"].with_context(active_test=False).search([]) + _logger.info("Enable the password policy on %s companies", len(companies)) + companies.write({"password_policy_enabled": True})