From 79c62a9af6714e1a847be9273e9ec1040bc1800f Mon Sep 17 00:00:00 2001 From: Andrea Gidalti Date: Sun, 8 Oct 2023 02:17:57 +0000 Subject: [PATCH] [REF] account_move_name_sequence: rename hooks file Rename hooks file and use post_init_hook method to create journal sequences after module installation. --- account_move_name_sequence/__init__.py | 2 +- account_move_name_sequence/__manifest__.py | 4 ++-- account_move_name_sequence/{post_install.py => hooks.py} | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) rename account_move_name_sequence/{post_install.py => hooks.py} (92%) diff --git a/account_move_name_sequence/__init__.py b/account_move_name_sequence/__init__.py index f8149cf4..1d353d71 100644 --- a/account_move_name_sequence/__init__.py +++ b/account_move_name_sequence/__init__.py @@ -1,2 +1,2 @@ -from .post_install import create_journal_sequences +from .hooks import post_init_hook from . import models diff --git a/account_move_name_sequence/__manifest__.py b/account_move_name_sequence/__manifest__.py index e6914cde..483d5699 100644 --- a/account_move_name_sequence/__manifest__.py +++ b/account_move_name_sequence/__manifest__.py @@ -12,7 +12,7 @@ "license": "AGPL-3", "summary": "Generate journal entry number from sequence", "author": "Akretion,Vauxoo,Odoo Community Association (OCA)", - "maintainers": ["alexis-via", "moylop260", "frahikLV"], + "maintainers": ["alexis-via", "moylop260", "frahikLV", "luisg123v"], "website": "https://github.com/OCA/account-financial-tools", "depends": [ "account", @@ -22,6 +22,6 @@ "views/account_move.xml", "security/ir.model.access.csv", ], - "post_init_hook": "create_journal_sequences", + "post_init_hook": "post_init_hook", "installable": True, } diff --git a/account_move_name_sequence/post_install.py b/account_move_name_sequence/hooks.py similarity index 92% rename from account_move_name_sequence/post_install.py rename to account_move_name_sequence/hooks.py index 10a69f0e..d499c3c7 100644 --- a/account_move_name_sequence/post_install.py +++ b/account_move_name_sequence/hooks.py @@ -8,8 +8,12 @@ from odoo import SUPERUSER_ID, api -def create_journal_sequences(cr, registry): +def post_init_hook(cr, registry): env = api.Environment(cr, SUPERUSER_ID, {}) + create_journal_sequences(env) + + +def create_journal_sequences(env): journals = ( env["account.journal"] .with_context(active_test=False)