Skip to content

[19.0][FIX] crm_phonecall: make the shared filters loadable again - #765

Merged
OCA-git-bot merged 1 commit into
OCA:19.0from
ForgeFlow:19.0-fix-crm_phonecall
Sep 16, 2026
Merged

OCA-git-bot merged 1 commit into
OCA:19.0from
ForgeFlow:19.0-fix-crm_phonecall

Conversation

@MiquelRForgeFlow

Copy link
Copy Markdown
Contributor

Odoo 19.0 validates shared filters on creation: ir.filters._sanitize_shared_context() runs ast.literal_eval() on the context, and that only strips spaces and tabs. The leading newline of a multi-line context therefore raises an IndentationError and the module fails to install.

Let's write the context of the three ir.filters records on a single line, as crm_claim already does.

Error detected in #764:

2026-09-16 10:21:37,382 324 WARNING odoo odoo.modules.loading: Transient module states were reset 
2026-09-16 10:21:37,383 324 ERROR odoo odoo.registry: Failed to load registry 
2026-09-16 10:21:37,383 324 CRITICAL odoo odoo.service.server: Failed to initialize database `odoo`. 
Traceback (most recent call last):
  File "/opt/odoo/odoo/tools/convert.py", line 608, in _tag_root
    f(rec)
  File "/opt/odoo/odoo/tools/convert.py", line 463, in _tag_record
    record = model._load_records([data], self.mode == 'update')
  File "/opt/odoo/odoo/orm/models.py", line 5209, in _load_records
    records = self._load_records_create([data['values'] for data in to_create])
  File "/opt/odoo/odoo/orm/models.py", line 5116, in _load_records_create
    records = self.create(vals_list)
  File "/opt/odoo/odoo/orm/decorators.py", line 369, in create
    return method(self, vals_list)
  File "/opt/odoo/odoo/addons/base/models/ir_filters.py", line 72, in create
    filters._sanitize_shared_context()
  File "/opt/odoo/odoo/addons/base/models/ir_filters.py", line 45, in _sanitize_shared_context
    context = ast.literal_eval(shared_filter.context)
  File "/opt/odoo/odoo/_monkeypatches/ast.py", line 28, in literal_eval
    return orig_literal_eval(expr)
  File "/usr/lib/python3.10/ast.py", line 64, in literal_eval
    node_or_string = parse(node_or_string.lstrip(" \t"), mode='eval')
  File "/usr/lib/python3.10/ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 2
    {'group_by': ['team_id'], 'pivot_measures': ['nbr_cases', 'duration']}
IndentationError: unexpected indent

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/odoo/odoo/service/server.py", line 1591, in preload_registries
    registry = Registry.new(dbname, update_module=update_module, install_modules=config['init'], upgrade_modules=config['update'], reinit_modules=config['reinit'])
  File "/opt/odoo/odoo/tools/func.py", line 88, in locked
    return func(inst, *args, **kwargs)
  File "/opt/odoo/odoo/orm/registry.py", line 189, in new
    load_modules(
  File "/opt/odoo/odoo/modules/loading.py", line 464, in load_modules
    load_module_graph(
  File "/opt/odoo/odoo/modules/loading.py", line 217, in load_module_graph
    load_data(env, idref, 'init', kind='data', package=package)
  File "/opt/odoo/odoo/modules/loading.py", line 59, in load_data
    convert_file(env, package.name, filename, idref, mode, noupdate=kind == 'demo')
  File "/opt/odoo/odoo/tools/convert.py", line 696, in convert_file
    convert_xml_import(env, module, fp, idref, mode, noupdate)
  File "/opt/odoo/odoo/tools/convert.py", line 795, in convert_xml_import
    obj.parse(doc.getroot())
  File "/opt/odoo/odoo/tools/convert.py", line 666, in parse
    self._tag_root(de)
  File "/opt/odoo/odoo/tools/convert.py", line 621, in _tag_root
    raise ParseError('while parsing %s:%s, somewhere inside\n%s' % (
odoo.tools.convert.ParseError: while parsing /__w/crm/crm/crm_phonecall/report/crm_phonecall_report_view.xml:28, somewhere inside
<record id="filter_crm_phonecall_sales_team" model="ir.filters">
        <field name="name">By Sales Team</field>
        <field name="model_id">crm.phonecall.report</field>
        <field name="domain">[('state','=','done')]</field>
        <field name="user_ids" eval="False"/>
        <field name="context">
            {'group_by': ['team_id'], 'pivot_measures': ['nbr_cases', 'duration']}
        </field>
    </record>

Odoo 19.0 validates shared filters on creation: ir.filters._sanitize_shared_context()
runs ast.literal_eval() on the context, and that only strips spaces and tabs. The
leading newline of a multi-line context therefore raises an IndentationError and the
module fails to install.

@GuillemCForgeFlow GuillemCForgeFlow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extremely easy review, thanks @MiquelRForgeFlow 🤖

@ValentinVinagre ValentinVinagre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏻

@pedrobaeza pedrobaeza added this to the 19.0 milestone Sep 16, 2026

@pedrobaeza pedrobaeza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, ugly bug...

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 19.0-ocabot-merge-pr-765-by-pedrobaeza-bump-patch, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit 931e7c6 into OCA:19.0 Sep 16, 2026
7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 6051e0b. Thanks a lot for contributing to OCA. ❤️

MiquelRForgeFlow referenced this pull request in odoo/odoo Sep 16, 2026
A shared filter's context must be cleaned, to prevent it from
polluting the contexts of other users who use the filter.

Task-6461702
@MiquelRForgeFlow
MiquelRForgeFlow deleted the 19.0-fix-crm_phonecall branch September 16, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants