Files
tocmo0nlord adbe430761
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled
Initial commit: Odoo 18.0-20251222 extra-addons
2026-03-13 20:43:25 +00:00

21 lines
844 B
Python
Executable File

# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
def set_default_partner_product_filter(env):
"""This hook is here because we couldn't set the default filter
as a default value for partners.
When the module is installed, Odoo creates the new field and at the
same time tries to set the default value for all existing records in
the DB. However the XML data (and thus 'product_filter_default' filter)
is still not created at this stage.
"""
partners_to_update = (
env["res.partner"]
.with_context(active_test=False)
.search([("pricelist_cache_product_filter_id", "=", False)])
)
default_filter = env.ref("pricelist_cache.product_filter_default")
partners_to_update.write({"pricelist_cache_product_filter_id": default_filter.id})