Odoo恢复数据库报错:unaccent_schema.unaccent函数不存在
Odoo恢复数据库后unaccent函数报错解决方案
问题现象
本地数据库运行正常,但恢复数据库后触发QWeb模板渲染错误,具体报错如下:
odoo.addons.base.models.ir_qweb.QWebException: Error while render the template UndefinedFunction: function unaccent_schema.unaccent(unknown, text) does not exist LINE 2: SELECT unaccent_schema.unaccent('unaccent_sc... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. QUERY: SELECT unaccent_schema.unaccent('unaccent_schema.unaccent', $1) CONTEXT: SQL function "unaccent" during inlining Template: web.frontend_layout
已在PostgreSQL中创建unaccent扩展,但问题仍未解决。
排查与解决步骤
确认unaccent扩展的安装schema
登录PostgreSQL数据库,执行以下SQL查询扩展所在schema:SELECT n.nspname AS schema_name, e.extname AS extension_name FROM pg_extension e JOIN pg_namespace n ON e.extnamespace = n.oid WHERE e.extname = 'unaccent';若扩展不在
unaccent_schema(或Odoo配置指定的schema),需将扩展迁移至对应schema,或调整Odoo配置项。重建指定参数类型的unaccent函数
报错核心是参数类型不匹配,手动创建符合要求的函数:CREATE OR REPLACE FUNCTION unaccent_schema.unaccent(regdictionary, text) RETURNS text AS '$libdir/unaccent', 'unaccent_dict' LANGUAGE c IMMUTABLE STRICT; CREATE OR REPLACE FUNCTION unaccent_schema.unaccent(text) RETURNS text AS $$ SELECT unaccent_schema.unaccent('unaccent_schema.unaccent', $1) $$ LANGUAGE sql IMMUTABLE STRICT;检查Odoo的unaccent配置
打开Odoo配置文件(odoo.conf),确认是否存在正确的schema配置:unaccent = unaccent_schema若无此配置,添加后重启Odoo服务。
清除Odoo缓存
开启开发者模式后,进入「设置」-「技术」-「缓存管理」,执行「清除缓存」操作,或直接重启Odoo服务。重装unaccent扩展
若上述步骤无效,尝试卸载并重新安装扩展:DROP EXTENSION IF EXISTS unaccent; CREATE EXTENSION unaccent SCHEMA unaccent_schema;
内容的提问来源于stack exchange,提问作者Sneha Vora
相关产品推荐
相关产品推荐

