@@ -29,80 +29,80 @@ def model_filter(self, prefix="", placeholder="%s"):
29
29
# By default, there is no `res_id`, no `res_model_id` and it is deleted when the linked model is removed
30
30
# warning: defaults are from the last fields in the namedtuple
31
31
IndirectReference .__new__ .__defaults__ = (None , None , False , None ) # https://stackoverflow.com/a/18348004
32
+ _IR = IndirectReference
33
+
34
+ INDIRECT_REFERENCES = [
35
+ _IR ("ir_attachment" , "res_model" , "res_id" ),
36
+ _IR ("ir_cron" , "model" , None , set_unknown = True ),
37
+ _IR ("ir_act_report_xml" , "model" , None , set_unknown = True ),
38
+ _IR ("ir_act_window" , "res_model" , "res_id" ),
39
+ _IR ("ir_act_window" , "res_model" , None ),
40
+ _IR ("ir_act_window" , "src_model" , None ),
41
+ _IR ("ir_act_server" , "wkf_model_name" , None ),
42
+ _IR ("ir_act_server" , "crud_model_name" , None ),
43
+ _IR ("ir_act_server" , "model_name" , None , "model_id" , set_unknown = True ),
44
+ _IR ("ir_act_client" , "res_model" , None , set_unknown = True ),
45
+ _IR ("ir_embedded_actions" , "parent_res_model" , "parent_res_id" ),
46
+ _IR ("ir_model" , "model" , None ),
47
+ _IR ("ir_model_fields" , "model" , None ),
48
+ _IR ("ir_model_fields" , "relation" , None ), # destination of a relation field
49
+ _IR ("ir_model_data" , "model" , "res_id" ),
50
+ _IR ("ir_filters" , "model_id" , None , set_unknown = True ), # YUCK!, not an id
51
+ # duplicated for versions where the `res_id` column does not exists
52
+ _IR ("ir_filters" , "model_id" , "embedded_parent_res_id" ),
53
+ _IR ("ir_exports" , "resource" , None ),
54
+ _IR ("ir_ui_view" , "model" , None , set_unknown = True ),
55
+ _IR ("ir_values" , "model" , "res_id" ),
56
+ _IR ("wkf_transition" , "trigger_model" , None ),
57
+ _IR ("wkf_triggers" , "model" , None ),
58
+ _IR ("ir_model_fields_anonymization" , "model_name" , None ),
59
+ _IR ("ir_model_fields_anonymization_migration_fix" , "model_name" , None ),
60
+ _IR ("base_import_mapping" , "res_model" , None ),
61
+ _IR ("calendar_event" , "res_model" , "res_id" ), # new in saas~18
62
+ _IR ("data_cleaning_model" , "res_model_name" , None ),
63
+ _IR ("data_cleaning_record" , "res_model_name" , "res_id" ),
64
+ _IR ("data_cleaning_rule" , "res_model_name" , None ),
65
+ _IR ("data_merge_group" , "res_model_name" , None ),
66
+ _IR ("data_merge_model" , "res_model_name" , None ),
67
+ _IR ("data_merge_record" , "res_model_name" , "res_id" ),
68
+ _IR ("documents_document" , "res_model" , "res_id" ),
69
+ _IR ("email_template" , "model" , None , set_unknown = True ), # stored related
70
+ _IR ("iap_extracted_words" , "res_model" , "res_id" ),
71
+ _IR ("mail_template" , "model" , None , set_unknown = True ), # model renamed in saas~6
72
+ _IR ("mail_activity" , "res_model" , "res_id" , "res_model_id" ),
73
+ _IR ("mail_activity_type" , "res_model" , None ),
74
+ _IR ("mail_alias" , None , "alias_force_thread_id" , "alias_model_id" ),
75
+ _IR ("mail_alias" , None , "alias_parent_thread_id" , "alias_parent_model_id" ),
76
+ _IR ("mail_followers" , "res_model" , "res_id" ),
77
+ _IR ("mail_message_subtype" , "res_model" , None ),
78
+ _IR ("mail_message" , "model" , "res_id" ),
79
+ _IR ("mail_compose_message" , "model" , "res_id" ),
80
+ _IR ("mail_wizard_invite" , "res_model" , "res_id" ),
81
+ _IR ("mail_mail_statistics" , "model" , "res_id" ),
82
+ _IR ("mailing_trace" , "model" , "res_id" ),
83
+ _IR ("mail_mass_mailing" , "mailing_model" , None , "mailing_model_id" , set_unknown = True ),
84
+ _IR ("mailing_mailing" , None , None , "mailing_model_id" , set_unknown = True ),
85
+ _IR ("marketing_campaign" , "model_name" , None , set_unknown = True ), # stored related
86
+ _IR ("marketing_participant" , "model_name" , "res_id" , "model_id" , set_unknown = True ),
87
+ _IR ("payment_transaction" , None , "callback_res_id" , "callback_model_id" ),
88
+ _IR ("project_project" , "alias_model" , None , set_unknown = True ),
89
+ # IR("pos_blackbox_be_log", "model_name", None), # ACTUALLY NOT. We need to keep records intact, even when renaming a model # noqa: ERA001
90
+ _IR ("quality_point" , "worksheet_model_name" , None ),
91
+ _IR ("rating_rating" , "res_model" , "res_id" , "res_model_id" ),
92
+ _IR ("rating_rating" , "parent_res_model" , "parent_res_id" , "parent_res_model_id" ),
93
+ _IR ("snailmail_letter" , "model" , "res_id" , set_unknown = True ),
94
+ _IR ("sms_template" , "model" , None ),
95
+ _IR ("studio_approval_rule" , "model_name" , None ),
96
+ _IR ("spreadsheet_revision" , "res_model" , "res_id" ),
97
+ _IR ("studio_approval_entry" , "model" , "res_id" ),
98
+ _IR ("timer_timer" , "res_model" , "res_id" ),
99
+ _IR ("timer_timer" , "parent_res_model" , "parent_res_id" ),
100
+ _IR ("worksheet_template" , "res_model" , None ),
101
+ ]
32
102
33
103
34
104
def indirect_references (cr , bound_only = False ):
35
- IR = IndirectReference
36
- each = [
37
- IR ("ir_attachment" , "res_model" , "res_id" ),
38
- IR ("ir_cron" , "model" , None , set_unknown = True ),
39
- IR ("ir_act_report_xml" , "model" , None , set_unknown = True ),
40
- IR ("ir_act_window" , "res_model" , "res_id" ),
41
- IR ("ir_act_window" , "res_model" , None ),
42
- IR ("ir_act_window" , "src_model" , None ),
43
- IR ("ir_act_server" , "wkf_model_name" , None ),
44
- IR ("ir_act_server" , "crud_model_name" , None ),
45
- IR ("ir_act_server" , "model_name" , None , "model_id" , set_unknown = True ),
46
- IR ("ir_act_client" , "res_model" , None , set_unknown = True ),
47
- IR ("ir_embedded_actions" , "parent_res_model" , "parent_res_id" ),
48
- IR ("ir_model" , "model" , None ),
49
- IR ("ir_model_fields" , "model" , None ),
50
- IR ("ir_model_fields" , "relation" , None ), # destination of a relation field
51
- IR ("ir_model_data" , "model" , "res_id" ),
52
- IR ("ir_filters" , "model_id" , None , set_unknown = True ), # YUCK!, not an id
53
- # duplicated for versions where the `res_id` column does not exists
54
- IR ("ir_filters" , "model_id" , "embedded_parent_res_id" ),
55
- IR ("ir_exports" , "resource" , None ),
56
- IR ("ir_ui_view" , "model" , None , set_unknown = True ),
57
- IR ("ir_values" , "model" , "res_id" ),
58
- IR ("wkf_transition" , "trigger_model" , None ),
59
- IR ("wkf_triggers" , "model" , None ),
60
- IR ("ir_model_fields_anonymization" , "model_name" , None ),
61
- IR ("ir_model_fields_anonymization_migration_fix" , "model_name" , None ),
62
- IR ("base_import_mapping" , "res_model" , None ),
63
- IR ("calendar_event" , "res_model" , "res_id" ), # new in saas~18
64
- IR ("data_cleaning_model" , "res_model_name" , None ),
65
- IR ("data_cleaning_record" , "res_model_name" , "res_id" ),
66
- IR ("data_cleaning_rule" , "res_model_name" , None ),
67
- IR ("data_merge_group" , "res_model_name" , None ),
68
- IR ("data_merge_model" , "res_model_name" , None ),
69
- IR ("data_merge_record" , "res_model_name" , "res_id" ),
70
- IR ("documents_document" , "res_model" , "res_id" ),
71
- IR ("email_template" , "model" , None , set_unknown = True ), # stored related
72
- IR ("iap_extracted_words" , "res_model" , "res_id" ),
73
- IR ("mail_template" , "model" , None , set_unknown = True ), # model renamed in saas~6
74
- IR ("mail_activity" , "res_model" , "res_id" , "res_model_id" ),
75
- IR ("mail_activity_type" , "res_model" , None ),
76
- IR ("mail_alias" , None , "alias_force_thread_id" , "alias_model_id" ),
77
- IR ("mail_alias" , None , "alias_parent_thread_id" , "alias_parent_model_id" ),
78
- IR ("mail_followers" , "res_model" , "res_id" ),
79
- IR ("mail_message_subtype" , "res_model" , None ),
80
- IR ("mail_message" , "model" , "res_id" ),
81
- IR ("mail_compose_message" , "model" , "res_id" ),
82
- IR ("mail_wizard_invite" , "res_model" , "res_id" ),
83
- IR ("mail_mail_statistics" , "model" , "res_id" ),
84
- IR ("mailing_trace" , "model" , "res_id" ),
85
- IR ("mail_mass_mailing" , "mailing_model" , None , "mailing_model_id" , set_unknown = True ),
86
- IR ("mailing_mailing" , None , None , "mailing_model_id" , set_unknown = True ),
87
- IR ("marketing_campaign" , "model_name" , None , set_unknown = True ), # stored related
88
- IR ("marketing_participant" , "model_name" , "res_id" , "model_id" , set_unknown = True ),
89
- IR ("payment_transaction" , None , "callback_res_id" , "callback_model_id" ),
90
- IR ("project_project" , "alias_model" , None , set_unknown = True ),
91
- # IR("pos_blackbox_be_log", "model_name", None), # ACTUALLY NOT. We need to keep records intact, even when renaming a model # noqa: ERA001
92
- IR ("quality_point" , "worksheet_model_name" , None ),
93
- IR ("rating_rating" , "res_model" , "res_id" , "res_model_id" ),
94
- IR ("rating_rating" , "parent_res_model" , "parent_res_id" , "parent_res_model_id" ),
95
- IR ("snailmail_letter" , "model" , "res_id" , set_unknown = True ),
96
- IR ("sms_template" , "model" , None ),
97
- IR ("studio_approval_rule" , "model_name" , None ),
98
- IR ("spreadsheet_revision" , "res_model" , "res_id" ),
99
- IR ("studio_approval_entry" , "model" , "res_id" ),
100
- IR ("timer_timer" , "res_model" , "res_id" ),
101
- IR ("timer_timer" , "parent_res_model" , "parent_res_id" ),
102
- IR ("worksheet_template" , "res_model" , None ),
103
- ]
104
-
105
- for ir in each :
105
+ for ir in INDIRECT_REFERENCES :
106
106
if bound_only and not ir .res_id :
107
107
continue
108
108
if ir .res_id and not column_exists (cr , ir .table , ir .res_id ):
@@ -130,7 +130,7 @@ def indirect_references(cr, bound_only=False):
130
130
""" ,
131
131
)
132
132
for model_name , column_name , comodel_name in cr .fetchall ():
133
- yield IR (table_of_model (cr , model_name ), None , column_name , company_dependent_comodel = comodel_name )
133
+ yield _IR (table_of_model (cr , model_name ), None , column_name , company_dependent_comodel = comodel_name )
134
134
135
135
# XXX Once we will get the model field of `many2one_reference` fields in the database, we should get them also
136
136
# (and filter the one already hardcoded)
0 commit comments