[FIX] util/pg: fix m2m doesn't exist - #500
Open
sagu-odoo wants to merge 1 commit into
Open
Conversation
When a custom field's relation model is renamed, the relation model is updated in ir_model_fields regardless of whether the field state is manual. However, when renaming the model, the related M2M tables and relation columns were updated only for manual fields. This could leave the relation inconsistent. The inconsistency could later cause the mock crawl to fail, as custom module fields are marked during the crawl. Remove the manual condition so that relation tables and columns are updated for all fields, preventing upgrade requests from failing due to inconsistent relation metadata. [condition]: https://github.com/odoo/upgrade-util/blob/ce76f4d2dafd6fe4c3b859548b9a2f8b5bdea408/src/util/models.py#L346 ``` ('hr_payroll_co.hr_contribution_form_menu_act', 362, 'Recursos Humanos > Autoliquidación > Planillas de aportes', 485): Traceback (most recent call last): File "/tmp/tmpfaiwjdd5/migrations/base/tests/test_mock_crawl.py", line 346, in crawl_menu self.mock_action(action_vals) File "/tmp/tmpfaiwjdd5/migrations/base/tests/test_mock_crawl.py", line 377, in mock_action return self.mock_act_window(action) File "/tmp/tmpfaiwjdd5/migrations/base/tests/test_mock_crawl.py", line 537, in mock_act_window mock_method(model, view, fields_list, domain, group_by) File "/tmp/tmpfaiwjdd5/migrations/base/tests/test_mock_crawl.py", line 570, in mock_view_form [data] = record.read(fields_list) File "/home/odoo/src/odoo/19.0/odoo/orm/models.py", line 3489, in read self._origin.fetch(fields) File "/home/odoo/src/odoo/19.0/odoo/orm/models.py", line 3812, in fetch fetched = self._fetch_query(query, fields_to_fetch) File "/home/odoo/src/odoo/19.0/odoo/orm/models.py", line 3940, in _fetch_query field.read(fetched) File "/home/odoo/src/odoo/19.0/odoo/orm/fields_relational.py", line 1396, in read for id1, id2 in records.env.execute_query(query.select(sql_id1, sql_id2)): File "/home/odoo/src/odoo/19.0/odoo/orm/environments.py", line 534, in execute_query self.cr.execute(query) File "/home/odoo/src/odoo/19.0/odoo/tests/test_cursor.py", line 79, in execute return self._cursor.execute(*args, **kwargs) File "/home/odoo/src/odoo/19.0/odoo/sql_db.py", line 440, in execute self._obj.execute(query, params) psycopg2.errors.UndefinedTable: relation "hr_contribution_form_hr_contract_rel" does not exist LINE 1: ...ract_rel"."hr_contract_id" FROM "hr_version" JOIN "hr_contri... ``` upg-4614063
Contributor
Contributor
|
Looks like a duplicate of #343 |
Contributor
|
The main difference being that #343 excludes standard fields. |
Contributor
Author
|
I wasn't aware of that fix. For me, the regex is quite restrictive when changing the relation table and retrieving the column as well. So, if we are sure about the change, why wait for the ORM to update it? Alternatively, if we are sure that the ORM will update the column in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

When a custom field's relation model is renamed,
the relation model is updated in ir_model_fields
regardless of whether the field state is manual condition.
However, when renaming the model, the related
M2M tables and relation columns were updated
only for manual fields. This could leave the
relation inconsistent.
The inconsistency could later cause the mock
crawl to fail, as custom module fields are marked
as manual during the crawl.
Remove the manual condition so that relation
tables and columns are updated for all fields,
preventing upgrade requests from failing due to
inconsistent relation.
upg-4614063