Initial commit: Odoo 18.0-20251222 extra-addons
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

This commit is contained in:
tocmo0nlord
2026-03-13 20:43:25 +00:00
parent 36e847a7df
commit adbe430761
9472 changed files with 1265727 additions and 0 deletions

20
pricelist_cache/hooks.py Executable file
View File

@@ -0,0 +1,20 @@
# 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})