upgrade-util
upgrade-util copied to clipboard
[FIX]util/models: improve query for custom fields
When utilizing 'def remove_inherit_from_model' method, it removes fields to disconnect two models, eliminating all custom fields created by customers. To prevent this, adding one condition.
Recentally i saw that issue here Here he tries to remove the connection between base.automation and ir.act.server. If customers have created custom fields using the studio in the base.automation model, this method will remove all custom fields during migration.
This patch doesn't look correct.
This query selects the fields on the base models (ir.act.server and its parents). So it will not remove the custom fields on the base.automation model.
This patch doesn't look correct. This query selects the fields on the base models (
ir.act.serverand its parents). So it will not remove the custom fields on thebase.automationmodel.
Here i tried with the demo database and you can see the result of it.
This is version 16 database where I created a field using studio in the 'base.automation' model.
test_16=> select * from ir_model_data where name = 'new_text_automated_a_3c6a273f-0881-458c-a527-585b4d43aece';
-[ RECORD 1 ]----------------------------------------------------------
id | 15362
create_uid | 2
create_date | 2024-05-20 05:12:00.047701
write_date | 2024-05-20 05:12:15.751808
write_uid | 2
res_id | 4677
noupdate | t
name | new_text_automated_a_3c6a273f-0881-458c-a527-585b4d43aece
module | studio_customization
model | ir.model.fields
studio | t
test_16=> select * from ir_model_fields where id = 4677;
-[ RECORD 1 ]-----+---------------------------
id | 4677
relation_field_id |
model_id | 343
related_field_id |
size |
create_uid | 2
write_uid | 2
name | x_studio_company
complete_name |
model | base.automation
relation |
relation_field |
ttype | char
related |
state | manual
on_delete |
domain | []
relation_table |
column1 |
column2 |
depends |
field_description | {"en_US": "Company"}
help |
compute |
copied | t
required | f
readonly | f
index | f
translate | f
group_expand |
selectable | t
store | t
create_date | 2024-05-20 05:12:00.047701
write_date | 2024-05-20 05:12:15.751808
tracking |
Here is a log of upgrades.
2024-05-20 05:22:03,604 26 INFO test_16_17.0 odoo.modules.migration: module base_automation: Running migration [>saas~16.5.1.0] pre-migrate
*************** [(4677,)]
2024-05-20 05:22:18,576 26 INFO test_16_17.0 odoo.upgrade.util.records: remove deprecated built-in view studio_customization.odoo_studio_automati_27a748b6-ec61-499a-912a-e97119b79097 (ID 711) as parent view base_automation.view_base_automation_form (ID 352) is going to be removed
2024-05-20 05:22:18,641 26 INFO test_16_17.0 odoo.upgrade.util.records: remove deprecated built-in view base_automation.view_base_automation_form (ID 352)
############# []
After completing the migration, that field was removed from the 'ir.model.fields'.
test_16_17.0=> select * from ir_model_data where name = 'new_text_automated_a_3c6a273f-0881-458c-a527-585b4d43aece';
-[ RECORD 1 ]----------------------------------------------------------
id | 15362
create_uid | 2
create_date | 2024-05-20 05:12:00.047701
write_date | 2024-05-20 05:12:15.751808
write_uid | 2
res_id | 4677
noupdate | t
name | new_text_automated_a_3c6a273f-0881-458c-a527-585b4d43aece
module | studio_customization
model | ir.model.fields
studio | t
test_16_17.0=> select * from ir_model_fields where id = 4677;
(0 rows)
After investigation, I finally found the issue. There is indeed a problem in this function, but not in this query.
When removing the ir.actions.server inherit from base.automation, it removes the many2many field webhook_field_ids, it will remove all the ir_model_fields link to the model base.automation.
@robodoo r+