partner-contact/partner_tier_validation/hooks.py

19 lines
587 B
Python
Raw Normal View History

2021-10-17 02:12:42 +00:00
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from flectra import SUPERUSER_ID
from flectra.api import Environment
from flectra.tools import config
def post_init_hook(cr, pool):
"""
We need to activate the rule only if we are not in a test environment.
"""
if not config["test_enable"]:
env = Environment(cr, SUPERUSER_ID, {})
tier_partner = env.ref(
"partner_tier_validation.partner_tier_definition_company_only"
)
tier_partner.write({"active": True})