Skip to content

Conversation

@SupportSNDC
Copy link

Description

Fix AttributeError: 'SQL' object has no attribute 'replace' when using
mail_activity_done on Odoo 16.0 and accessing views with activity
progress bars (e.g. project task Kanban with activities).

Root cause

In Odoo 16.0, SQL queries are psycopg.sql.SQL / Composed objects
instead of plain strings, so calling .replace() on them fails.

Technical details

In mail_activity_done/models/mail_activity.py:

  • In _read_progress_bar(), override execute() to:

    • convert the SQL object to a string via as_string(self._cr._cnx)
      when available, or fallback to str(query),
    • only perform replace() on the string when the expected pattern
      (WHERE res_model = ...) is present,
    • otherwise, call the original execute() with the unmodified query.
  • Apply the same pattern in _search_activity_state() for its own
    SQL pattern, avoiding .replace() on the raw SQL object.

This preserves behaviour on earlier versions while making the module
compatible with Odoo 16.0.

Related issue

Fixes #1747

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant