Skip to content

[FIX] base_dynamic_message: Add unique field descriptions to avoid warnings#269

Closed
ced-adhoc wants to merge 1 commit intoingadhoc:18.0from
adhoc-dev:18.0-t-55020-ced
Closed

[FIX] base_dynamic_message: Add unique field descriptions to avoid warnings#269
ced-adhoc wants to merge 1 commit intoingadhoc:18.0from
adhoc-dev:18.0-t-55020-ced

Conversation

@ced-adhoc
Copy link
Copy Markdown
Contributor

  • Include record ID in field descriptions to prevent duplicate "Dynamic Message" descriptions
  • Add migration script to update existing fields with generic descriptions
  • Version bump to 18.0.1.1.0

This prevents warnings about duplicate field descriptions by making each dynamic message field have a unique description like "Dynamic Message 1", "Dynamic Message 2", etc.

@roboadhoc
Copy link
Copy Markdown
Contributor

Pull request status dashboard

Comment on lines +9 to +27
fields_to_update = env["ir.model.fields"].search(
[
("field_description", "=like", "Dynamic Message%"),
("name", "=like", "x_dynamic_message_%"),
("field_description", "not ilike", "Dynamic Message %"), # Exclude those already with ID
]
)

for field in fields_to_update:
# Extract the ID from the field name (x_dynamic_message_123 -> 123)
if field.name.startswith("x_dynamic_message_"):
try:
dynamic_message_id = field.name.split("_")[-1]
if dynamic_message_id.isdigit():
new_description = "Dynamic Message %s" % dynamic_message_id
field.write({"field_description": new_description})
except (IndexError, ValueError):
# Skip if we can't extract a valid ID
continue
Copy link
Copy Markdown
Contributor

@vib-adhoc vib-adhoc Aug 29, 2025

Choose a reason for hiding this comment

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

Suggested change
fields_to_update = env["ir.model.fields"].search(
[
("field_description", "=like", "Dynamic Message%"),
("name", "=like", "x_dynamic_message_%"),
("field_description", "not ilike", "Dynamic Message %"), # Exclude those already with ID
]
)
for field in fields_to_update:
# Extract the ID from the field name (x_dynamic_message_123 -> 123)
if field.name.startswith("x_dynamic_message_"):
try:
dynamic_message_id = field.name.split("_")[-1]
if dynamic_message_id.isdigit():
new_description = "Dynamic Message %s" % dynamic_message_id
field.write({"field_description": new_description})
except (IndexError, ValueError):
# Skip if we can't extract a valid ID
continue
fields_to_update = env["ir.model.fields"].search([("field_description", "=", "Dynamic Message")])
for field in fields_to_update:
field.write({"field_description": "Dynamic Message %s" % field.id})

@vib-adhoc
Copy link
Copy Markdown
Contributor

@ced-adhoc Hola Celi, te dejé una sugerencia para simplificar el script, decime qué te parece o lo podemos charlar esta tarde. No lo probé, es solo una sugerencia

Copilot AI review requested due to automatic review settings September 10, 2025 17:15
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds unique field descriptions to dynamic message fields to prevent Odoo warnings about duplicate field descriptions. Instead of all dynamic message fields having the generic "Dynamic Message" description, they now include their record ID to create unique descriptions.

  • Updates field creation logic to include record ID in field descriptions
  • Adds migration script to update existing fields with generic descriptions
  • Version bump to support the migration

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
base_dynamic_message/models/ir_model_dynamic_message.py Updates field description format to include record ID
base_dynamic_message/migrations/18.0.1.1.0/post-migration.py Migration script to update existing fields with generic descriptions
base_dynamic_message/manifest.py Version bump to trigger migration

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread base_dynamic_message/migrations/18.0.1.1.0/post-migration.py Outdated
@vib-adhoc
Copy link
Copy Markdown
Contributor

@roboadhoc r+

roboadhoc pushed a commit that referenced this pull request Oct 8, 2025
…rnings

closes #269

Signed-off-by: Virginia Bonservizi <vib@adhoc.com.ar>
@roboadhoc roboadhoc closed this Oct 8, 2025
@roboadhoc roboadhoc deleted the 18.0-t-55020-ced branch October 8, 2025 17:10
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.

4 participants