Translated fields no longer use the model ir.translation. Instead they store
all their values as JSON, and store them into JSONB columns in the model's
table. The field's column value is either NULL or a JSON dict mapping language
codes to text (the field's value in the corresponding language), and must
contain an entry for key 'en_US' (as it is used as a fallback for all other
languages). Empty text is allowed in translation values, but not NULL.
Here are examples for a field with translate=True:
NULL
{"en_US": "Foo"}
{"en_US": "Foo", "fr_FR": "Bar", "nl_NL": "Baz"}
{"en_US": "Foo", "fr_FR": "", "nl_NL": "Baz"}
Like before, writing False to the field makes it NULL, i.e., False in all
languages. However, writing "" to the field makes its value empty in the
current language, but does not discard the values in the other languages.
Here are examples for a field with translate=xml_translate:
NULL
{"en_US": "<div>Foo<p>Bar</p></div>", "fr_FR": "<div>Fou<p>Barre</p></div>"}
Change for callable(translate) fields: one can now write any value in any
language on such a field. The new value will be adapted in all languages, based
on the mapping of terms between languages in the old values. Basically the
structure of the value must remain the same in all languages, like before.
Reading a translated field is now both simpler and faster than the former
implementation. We fetch the value of the field in the current language by
coalescing its value with the 'en_US' value of the field:
SELECT id, COALESCE(name->>'fr_FR', name->>'en_US') AS name ...
The raw cache of the field contains either None or a dict which is conceptually
a subset of the JSON value in database (except for missing languages). For the
sake of simplicity, most cache operations deal with the dict and return the text
value in the current language.
Trigram indexes have been adapted to the new storing strategy, and should enable
to search in any language. Before this change, only the source value of the
field ('en_US') could be indexed.
Computed stored translated fields are not supported by the framework, because of
the complexity of the computation itself: the field would need to be computed in
all active languages. We chose to not provide any hook to compute a field in
all languages at once, and the framework always invokes a compute method once to
recompute it.
Code translations are no longer stored into the database. They become static,
and are extracted from the PO files when needed. The worker simply uses a cache
with extracted code translations for performance. This is reasonable, since
fr_FR code translations for all modules takes around 2MB of memory, and the
cache can be shared among all registries in the worker. Changing code
translations requires to update the corresponding PO file and reloading the
worker(s).
Performance summary:
(+) reading 'model' translated fields is faster
(+) reading 'model_terms' translated fields is much faster (no need to inject
translations into the source value)
(+) searching translated fields with operator 'ilike' is much faster when the
field is indexed with 'trigram'
(+) updating translated fields requires less ORM flushing
(-) importing translations from PO files is 2x slower
Some extra fixes:
- make field 'name' of ir.actions.actions translated; because of the PG
inheritance, this is necessary to make the column definition consistent in
all models that inherit from ir.actions.actions.
- add some backend API for the web/website client for editing translations
- move methods get_field_string() to model ir.model.fields
- move _load_module_terms to model ir.module.module
- adapt tests in test_impex, test_new_api
- because env.lang is injected into SQL queries, its returned value is
now guaranteed to correspond to a valid active language or None
- remove wizard to insert missing translations (no longer makes sense)
task-id: 2081307
Co-authored-by: Fabien Pinckaers <fp@openerp.com>
Co-authored-by: Raphael Collet <rco@odoo.com>
14 KiB
14 KiB
| 1 | id | name | model_id:id | group_id:id | perm_read | perm_write | perm_create | perm_unlink |
|---|---|---|---|---|---|---|---|---|
| 2 | access_decimal_precision_config | decimal.precision configuration | model_decimal_precision | group_system | 1 | 1 | 0 | 0 |
| 3 | access_ir_attachment_group_user | ir_attachment group_user | model_ir_attachment | group_user | 1 | 1 | 1 | 1 |
| 4 | access_ir_attachment_group_portal_public | ir_attachment group_portal_public | model_ir_attachment | 0 | 0 | 0 | 0 | |
| 5 | access_ir_cron_group_cron | ir_cron group_cron | model_ir_cron | group_system | 1 | 1 | 1 | 1 |
| 6 | access_ir_cron_trigger_group_cron | ir_cron_trigger group_cron | model_ir_cron_trigger | group_system | 1 | 1 | 1 | 1 |
| 7 | access_ir_exports_group_system | ir_exports group_system | model_ir_exports | base.group_allow_export | 1 | 1 | 1 | 1 |
| 8 | access_ir_exports_line_group_system | ir_exports_line group_system | model_ir_exports_line | base.group_user | 1 | 1 | 1 | 1 |
| 9 | access_ir_model_group_erp_manager | ir_model group_erp_manager | model_ir_model | group_erp_manager | 1 | 1 | 1 | 1 |
| 10 | access_ir_model_constraint_group_erp_manager | ir_model_constraint group_erp_manager | model_ir_model_constraint | group_erp_manager | 1 | 1 | 1 | 1 |
| 11 | access_ir_model_relation_group_erp_manager | ir_model_relation group_erp_manager | model_ir_model_relation | group_erp_manager | 1 | 1 | 1 | 1 |
| 12 | access_ir_model_access_group_erp_manager | ir_model_access_group_erp_manager | model_ir_model_access | group_erp_manager | 1 | 1 | 1 | 1 |
| 13 | access_ir_model_data_group_erp_manager | ir_model_data group_erp_manager | model_ir_model_data | group_erp_manager | 1 | 1 | 1 | 1 |
| 14 | access_ir_model_fields_group_erp_manager | ir_model_fields group_erp_manager | model_ir_model_fields | group_erp_manager | 1 | 1 | 1 | 1 |
| 15 | access_ir_model_fields_selection_group_erp_manager | ir_model_fields_selection group_erp_manager | model_ir_model_fields_selection | group_erp_manager | 1 | 1 | 1 | 1 |
| 16 | access_ir_model_user | ir_model_all | model_ir_model | base.group_user | 0 | 0 | 0 | 0 |
| 17 | access_ir_model_data_user | ir_model_data user | model_ir_model_data | base.group_user | 0 | 0 | 0 | 0 |
| 18 | access_ir_model_fields_user | ir_model_fields all | model_ir_model_fields | base.group_user | 0 | 0 | 0 | 0 |
| 19 | access_ir_model_fields_selection_user | ir_model_fields_selection all | model_ir_model_fields_selection | base.group_user | 0 | 0 | 0 | 0 |
| 20 | access_ir_module_category_group_user | ir_module_category group_user | model_ir_module_category | group_erp_manager | 1 | 0 | 0 | 0 |
| 21 | access_ir_module_module_group_user | ir_module_module group_user | model_ir_module_module | group_system | 1 | 1 | 1 | 1 |
| 22 | access_ir_module_module_dependency_group_system | ir_module_module_dependency group_system | model_ir_module_module_dependency | group_system | 1 | 1 | 1 | 1 |
| 23 | access_ir_module_module_exclusion_group_system | ir_module_module_exclusion group_system | model_ir_module_module_exclusion | group_system | 1 | 1 | 1 | 1 |
| 24 | access_ir_property_group_user | ir_property group_user | model_ir_property | 0 | 0 | 0 | 0 | |
| 25 | access_ir_property_group_system | ir_property group_system | model_ir_property | base.group_system | 1 | 1 | 1 | 0 |
| 26 | access_ir_rule_group_erp_manager | ir_rule group_erp_manager | model_ir_rule | group_erp_manager | 1 | 1 | 1 | 1 |
| 27 | access_ir_sequence_group_user | ir_sequence group_user | model_ir_sequence | group_user | 1 | 0 | 0 | 0 |
| 28 | access_ir_sequence_group_system | ir_sequence group_system | model_ir_sequence | group_system | 1 | 1 | 1 | 1 |
| 29 | access_ir_sequence_date_range_group_user | ir_sequence_date_range group_user | model_ir_sequence_date_range | group_user | 1 | 0 | 0 | 0 |
| 30 | access_ir_sequence_date_range_group_system | ir_sequence_date_range group_system | model_ir_sequence_date_range | group_system | 1 | 1 | 1 | 1 |
| 31 | access_ir_ui_menu_group_user | ir_ui_menu group_user | model_ir_ui_menu | base.group_user | 1 | 0 | 0 | 0 |
| 32 | access_ir_ui_menu_group_system | ir_ui_menu group_system | model_ir_ui_menu | group_system | 1 | 1 | 1 | 1 |
| 33 | access_ir_ui_view_group_user | ir_ui_view group_user | model_ir_ui_view | 0 | 0 | 0 | 0 | |
| 34 | access_ir_ui_view_group_system | ir_ui_view group_system | model_ir_ui_view | group_system | 1 | 1 | 1 | 1 |
| 35 | access_reset_view_arch_wizard_group_system | reset_view_arch_wizard group_system | model_reset_view_arch_wizard | group_system | 1 | 1 | 1 | 0 |
| 36 | access_ir_ui_view_custom_group_user | ir_ui_view_custom_group_user | model_ir_ui_view_custom | 1 | 1 | 1 | 1 | |
| 37 | access_ir_default_all | ir_default all | model_ir_default | 1 | 0 | 0 | 0 | |
| 38 | access_ir_default_group_user | ir_default group_user | model_ir_default | group_user | 1 | 1 | 1 | 1 |
| 39 | access_ir_default_group_system | ir_default group_system | model_ir_default | group_system | 1 | 1 | 1 | 1 |
| 40 | access_res_company_group_erp_manager | res_company group_erp_manager | model_res_company | group_erp_manager | 1 | 1 | 1 | 1 |
| 41 | access_res_company_group_user | res_company group_user | model_res_company | 1 | 0 | 0 | 0 | |
| 42 | access_res_country_group_all | res_country group_user_all | model_res_country | 1 | 0 | 0 | 0 | |
| 43 | access_res_country_state_group_all | res_country_state group_user_all | model_res_country_state | 1 | 0 | 0 | 0 | |
| 44 | access_res_country_group_group_all | res_country_group group_user_all | model_res_country_group | 1 | 0 | 0 | 0 | |
| 45 | access_res_country_group_user | res_country group_user | model_res_country | group_partner_manager | 1 | 0 | 0 | 0 |
| 46 | access_res_country_group_system | res_country_group_system | model_res_country | group_system | 1 | 1 | 1 | 1 |
| 47 | access_res_country_state_group_user | res_country_state group_user | model_res_country_state | group_partner_manager | 1 | 1 | 1 | 1 |
| 48 | access_res_country_group_group_user | res_country_group group_user | model_res_country_group | group_partner_manager | 1 | 1 | 1 | 1 |
| 49 | access_res_currency_group_all | res_currency group_all | model_res_currency | 1 | 0 | 0 | 0 | |
| 50 | access_res_currency_rate_group_all | res_currency_rate group_all | model_res_currency_rate | 1 | 0 | 0 | 0 | |
| 51 | access_res_currency_group_system | res_currency group_system | model_res_currency | group_system | 1 | 1 | 1 | 1 |
| 52 | access_res_currency_rate_group_system | res_currency_rate group_system | model_res_currency_rate | group_system | 1 | 1 | 1 | 1 |
| 53 | access_res_groups_group_erp_manager | res_groups group_erp_manager | model_res_groups | group_erp_manager | 1 | 1 | 1 | 1 |
| 54 | access_res_groups_group_user | res_groups group_user | model_res_groups | group_user | 1 | 0 | 0 | 0 |
| 55 | access_res_lang_group_all | res_lang group_all | model_res_lang | 1 | 0 | 0 | 0 | |
| 56 | access_res_lang_group_user | res_lang group_user | model_res_lang | group_system | 1 | 1 | 1 | 1 |
| 57 | access_res_partner_public | res_partner group_public | model_res_partner | group_public | 1 | 0 | 0 | 0 |
| 58 | access_res_partner_portal | res_partner group_portal | model_res_partner | group_portal | 1 | 0 | 0 | 0 |
| 59 | access_res_partner_group_partner_manager | res_partner group_partner_manager | model_res_partner | group_partner_manager | 1 | 1 | 1 | 1 |
| 60 | access_res_partner_group_user | res_partner group_user | model_res_partner | group_user | 1 | 0 | 0 | 0 |
| 61 | access_res_partner_bank_group_user | res_partner_bank group_user | model_res_partner_bank | group_user | 1 | 0 | 0 | 0 |
| 62 | access_res_partner_bank_group_partner_manager | res_partner_bank group_partner_manager | model_res_partner_bank | group_partner_manager | 1 | 1 | 1 | 1 |
| 63 | access_res_partner_category_group_user | res_partner_category group_user | model_res_partner_category | group_user | 1 | 0 | 0 | 0 |
| 64 | access_res_partner_category_group_partner_manager | res_partner_category group_partner_manager | model_res_partner_category | group_partner_manager | 1 | 1 | 1 | 1 |
| 65 | access_res_partner_industry_group_user | res_partner_industry group_user | model_res_partner_industry | group_user | 1 | 0 | 0 | 0 |
| 66 | access_res_partner_industry_group_system | res_partner_industry group_system | model_res_partner_industry | group_system | 1 | 1 | 1 | 1 |
| 67 | access_res_partner_title_group_user | res_partner_title group_partner_manager | model_res_partner_title | group_partner_manager | 1 | 1 | 1 | 1 |
| 68 | access_res_partner_title_group_partner_manager | res_partner_title group_user | model_res_partner_title | 1 | 0 | 0 | 0 | |
| 69 | access_res_users_all | res_users all | model_res_users | 1 | 0 | 0 | 0 | |
| 70 | access_res_users_group_erp_manager | res_users group_erp_manager | model_res_users | group_erp_manager | 1 | 1 | 1 | 1 |
| 71 | access_res_users_deletion_all | res_users_deletion all | model_res_users_deletion | 0 | 0 | 0 | 0 | |
| 72 | access_res_users_deletion_group_erp_manager | res_users_deletion group_erp_manager | model_res_users_deletion | group_erp_manager | 1 | 1 | 1 | 1 |
| 73 | access_res_users_log_all | res_users_log_all | model_res_users_log | 1 | 0 | 1 | 0 | |
| 74 | access_res_users_identitycheck_employee | id check employees | model_res_users_identitycheck | group_user | 1 | 1 | 1 | 0 |
| 75 | access_res_users_identitycheck_portal | id check portal | model_res_users_identitycheck | group_portal | 1 | 1 | 1 | 0 |
| 76 | access_res_users_apikeys_access_employee | API keys access employees | model_res_users_apikeys | group_user | 1 | 0 | 0 | 0 |
| 77 | access_res_users_apikeys_access_portal | API keys access portal | model_res_users_apikeys | group_portal | 1 | 0 | 0 | 0 |
| 78 | access_res_users_apikeys_description_employee | API key wizard employees | model_res_users_apikeys_description | group_user | 1 | 0 | 1 | 0 |
| 79 | access_res_users_apikeys_description_portal | API key wizard | model_res_users_apikeys_description | group_portal | 1 | 0 | 1 | 0 |
| 80 | access_res_users_apikeys_show_employee | API key result employees | model_res_users_apikeys_show | group_user | 1 | 0 | 1 | 0 |
| 81 | access_ir_asset_group_system | ir_asset_group_system | model_ir_asset | group_system | 1 | 1 | 1 | 1 |
| 82 | access_ir_actions_group_system | ir_actions_group_system | model_ir_actions_actions | group_system | 1 | 1 | 1 | 1 |
| 83 | access_ir_actions_act_window_system | ir_actions_act_window_system | model_ir_actions_act_window | group_system | 1 | 1 | 1 | 1 |
| 84 | access_ir_actions_act_window_close_group_system | ir_actions_act_window_close_group_system | model_ir_actions_act_window_close | group_system | 1 | 1 | 1 | 1 |
| 85 | access_ir_actions_report_group_system | ir_actions_report_group_system | model_ir_actions_report | group_system | 1 | 1 | 1 | 1 |
| 86 | access_ir_actions_todo_group_system | ir_actions_todo group system | model_ir_actions_todo | group_system | 1 | 1 | 1 | 1 |
| 87 | access_ir_actions_act_window_view_group_system | ir_actions_act_window_view_group_system | model_ir_actions_act_window_view | group_system | 1 | 1 | 1 | 1 |
| 88 | access_ir_actions_act_url_group_system | ir_actions_act_url_group_system | model_ir_actions_act_url | group_system | 1 | 1 | 1 | 1 |
| 89 | access_ir_server_object_lines_group_system | ir_server_object_lines_group_system | model_ir_server_object_lines | group_system | 1 | 1 | 1 | 1 |
| 90 | access_ir_actions_server_group_system | ir_actions_server_group_system | model_ir_actions_server | group_system | 1 | 1 | 1 | 1 |
| 91 | access_ir_actions_client | ir_actions_client all | model_ir_actions_client | group_system | 1 | 1 | 1 | 1 |
| 92 | access_res_bank_group_system | res_bank_group_system | model_res_bank | group_system | 1 | 1 | 1 | 1 |
| 93 | access_res_bank_group_partner_manager | res_bank_group_partner_manager | model_res_bank | group_partner_manager | 1 | 1 | 1 | 1 |
| 94 | access_res_bank_user | res_bank user | model_res_bank | group_user | 1 | 0 | 0 | 0 |
| 95 | access_ir_filter_erp_manager | ir_filters all | model_ir_filters | group_erp_manager | 1 | 1 | 1 | 1 |
| 96 | access_ir_filter_user | ir_filters all | model_ir_filters | group_user | 1 | 1 | 1 | 1 |
| 97 | access_ir_filter_portal | ir_filters all | model_ir_filters | group_portal | 1 | 1 | 1 | 1 |
| 98 | access_ir_filter_public | ir_filters all | model_ir_filters | group_public | 1 | 1 | 1 | 1 |
| 99 | access_ir_config_parameter_system | ir_config_parameter_system | model_ir_config_parameter | group_system | 1 | 1 | 1 | 1 |
| 100 | access_ir_mail_server | ir_mail_server | model_ir_mail_server | group_system | 1 | 1 | 1 | 1 |
| 101 | access_ir_logging | ir_logging admin | model_ir_logging | group_erp_manager | 1 | 1 | 1 | 1 |
| 102 | paperformat_access_portal | ir_actions_report_paperformat group_portal | model_report_paperformat | 1 | 0 | 0 | 0 | |
| 103 | paperformat_access_employee | ir_actions_report_paperformat group_system | model_report_paperformat | group_system | 1 | 1 | 1 | 1 |
| 104 | access_report_layout | access_report_layout | model_report_layout | 1 | 1 | 1 | 1 | |
| 105 | access_wizard_ir_model_menu_create | access.wizard.ir.model.menu.create | model_wizard_ir_model_menu_create | base.group_system | 1 | 1 | 1 | 0 |
| 106 | access_reset_view_arch_wizard | access.reset.view.arch.wizard | model_reset_view_arch_wizard | base.group_erp_manager | 1 | 1 | 1 | 0 |
| 107 | access_ir_demo | access.ir.demo | model_ir_demo | base.group_system | 1 | 1 | 1 | 0 |
| 108 | access_ir_demo_failure | access.ir.demo_failure | model_ir_demo_failure | base.group_system | 1 | 1 | 1 | 0 |
| 109 | access_ir_demo_failure_wizard | access.ir.demo_failure.wizard | model_ir_demo_failure_wizard | base.group_system | 1 | 1 | 1 | 0 |
| 110 | access_res_config | access.res.config | model_res_config | base.group_system | 1 | 1 | 1 | 0 |
| 111 | access_res_config_installer | access.res.config.installer | model_res_config_installer | base.group_system | 1 | 1 | 1 | 0 |
| 112 | access_res_config_settings | access.res.config.settings | model_res_config_settings | base.group_system | 1 | 1 | 1 | 0 |
| 113 | access_change_password_wizard | access.change.password.wizard | model_change_password_wizard | base.group_erp_manager | 1 | 1 | 1 | 0 |
| 114 | access_change_password_user | access.change.password.user | model_change_password_user | base.group_erp_manager | 1 | 1 | 1 | 0 |
| 115 | access_change_password_own | access.change.password.own | model_change_password_own | base.group_user | 1 | 1 | 1 | 1 |
| 116 | access_base_module_update | access.base.module.update | model_base_module_update | base.group_system | 1 | 1 | 1 | 0 |
| 117 | access_base_language_install | access.base.language.install | model_base_language_install | base.group_system | 1 | 1 | 1 | 0 |
| 118 | access_base_language_import | access.base.language.import | model_base_language_import | base.group_system | 1 | 1 | 1 | 0 |
| 119 | access_base_module_upgrade | access.base.module.upgrade | model_base_module_upgrade | base.group_system | 1 | 1 | 1 | 0 |
| 120 | access_base_module_uninstall | access.base.module.uninstall | model_base_module_uninstall | base.group_system | 1 | 1 | 1 | 0 |
| 121 | access_base_language_export | access.base.language.export | model_base_language_export | base.group_user | 1 | 1 | 1 | 0 |
| 122 | access_base_partner_merge_line | access.base.partner.merge.line | model_base_partner_merge_line | base.group_partner_manager | 1 | 1 | 1 | 1 |
| 123 | access_base_partner_merge_automatic_wizard | access.base.partner.merge.automatic.wizard | model_base_partner_merge_automatic_wizard | base.group_partner_manager | 1 | 1 | 1 | 0 |
| 124 | access_ir_profile | ir_profile | model_ir_profile | group_system | 1 | 1 | 1 | 1 |
| 125 | access_base_enable_profiling_wizard | access.base.enable.profiling.wizard | model_base_enable_profiling_wizard | group_system | 1 | 1 | 1 | 0 |