[16.0][FIX] mail_activity_done: handle SQL queries without .replace() #1759
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fix
AttributeError: 'SQL' object has no attribute 'replace'when usingmail_activity_doneon Odoo 16.0 and accessing views with activityprogress bars (e.g. project task Kanban with activities).
Root cause
In Odoo 16.0, SQL queries are
psycopg.sql.SQL/Composedobjectsinstead of plain strings, so calling
.replace()on them fails.Technical details
In
mail_activity_done/models/mail_activity.py:In
_read_progress_bar(), overrideexecute()to:as_string(self._cr._cnx)when available, or fallback to
str(query),replace()on the string when the expected pattern(
WHERE res_model = ...) is present,execute()with the unmodifiedquery.Apply the same pattern in
_search_activity_state()for its ownSQL 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