The import logging (ish) assumes that if an exception has at least 2 args the second arg is metadata added by the callee. As it turns out, `UnicodeEncodeError` has *five* arguments, none of which is added by us. So if encoding something fails during the process (e.g. because the file contains a lone surrogate, which leads to the database insert failing when psycopg2 tries to encode the query to UTF8), then the `_log` function itself will fail, yielding a very unhelpful error of: dictionary update sequence element #0 has length 1; 2 is required (because we tried to update a dict using a string). This issue occurs only during *field conversion* and most fields have no need to interact with the database (so don't need to encode the value, which is what fails), however it is a problem when the invalid string is used as a record name to look for (e.g. an m2o). Further improve the experience by converting the UnicodeEncodeError to a ValueError using the stringified UEE: `_log` assumes the first argument to the exception is an error message of some sort, but for UnicodeError subclasses it's just the encoding involved in the error (here `utf-8`), which doesn't really serve as an error message. Stringifying the exception generates a complete error message which is quite a bit more helpful. Specific update notes: * avoid modifying the exception in-place, doesn't seem useful * not sure why `field_name` was added as part of the augmentation rather than up-front when `record` is created Issue 2480064 closes odoo/odoo#72517 X-original-commit: 6c3c500929cd463cd3a1749f4ede8f3a8afd5748 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2.6 KiB
2.6 KiB
| 1 | id | name | model_id:id | group_id:id | perm_read | perm_write | perm_create | perm_unlink |
|---|---|---|---|---|---|---|---|---|
| 2 | access_export_boolean | access_export_boolean | model_export_boolean | 1 | 1 | 1 | 1 | |
| 3 | access_export_integer | access_export_integer | model_export_integer | 1 | 1 | 1 | 1 | |
| 4 | access_export_float | access_export_float | model_export_float | 1 | 1 | 1 | 1 | |
| 5 | access_export_decimal | access_export_decimal | model_export_decimal | 1 | 1 | 1 | 1 | |
| 6 | access_export_string_bounded | access_export_string_bounded | model_export_string_bounded | 1 | 1 | 1 | 1 | |
| 7 | access_export_string_required | access_export_string_required | model_export_string_required | 1 | 1 | 1 | 1 | |
| 8 | access_export_string | access_export_string | model_export_string | 1 | 1 | 1 | 1 | |
| 9 | access_export_date | access_export_date | model_export_date | 1 | 1 | 1 | 1 | |
| 10 | access_export_datetime | access_export_datetime | model_export_datetime | 1 | 1 | 1 | 1 | |
| 11 | access_export_text | access_export_text | model_export_text | 1 | 1 | 1 | 1 | |
| 12 | access_export_selection | access_export_selection | model_export_selection | 1 | 1 | 1 | 1 | |
| 13 | access_export_selection_function | access_export_selection_function | model_export_selection_function | 1 | 1 | 1 | 1 | |
| 14 | access_export_many2one | access_export_many2one | model_export_many2one | 1 | 1 | 1 | 1 | |
| 15 | access_export_one2many | access_export_one2many | model_export_one2many | 1 | 1 | 1 | 1 | |
| 16 | access_export_many2many | access_export_many2many | model_export_many2many | 1 | 1 | 1 | 1 | |
| 17 | access_export_function | access_export_function | model_export_function | 1 | 1 | 1 | 1 | |
| 18 | access_export_one2many_child | access_export_one2many_child | model_export_one2many_child | 1 | 1 | 1 | 1 | |
| 19 | access_export_one2many_multiple | access_export_one2many_multiple | model_export_one2many_multiple | 1 | 1 | 1 | 1 | |
| 20 | access_export_one2many_multiple_child | access_export_one2many_multiple_child | model_export_one2many_multiple_child | 1 | 1 | 1 | 1 | |
| 21 | access_export_one2many_child_1 | access_export_one2many_child_1 | model_export_one2many_child_1 | 1 | 1 | 1 | 1 | |
| 22 | access_export_one2many_child_2 | access_export_one2many_child_2 | model_export_one2many_child_2 | 1 | 1 | 1 | 1 | |
| 23 | access_export_many2many_other | access_export_many2many_other | model_export_many2many_other | 1 | 1 | 1 | 1 | |
| 24 | access_export_selection_withdefault | access_export_selection_withdefault | model_export_selection_withdefault | 1 | 1 | 1 | 1 | |
| 25 | access_export_one2many_recursive | access_export_one2many_recursive | model_export_one2many_recursive | 1 | 1 | 1 | 1 | |
| 26 | access_export_unique | access_export_unique | model_export_unique | 1 | 1 | 1 | 1 | |
| 27 | access_export_inherits_parent | access_export_inherits_parent | model_export_inherits_parent | 1 | 1 | 1 | 1 | |
| 28 | access_export_inherits_child | access_export_inherits_child | model_export_inherits_child | 1 | 1 | 1 | 1 | |
| 29 | access_export_m2o_str | access_export_m2o_str | model_export_m2o_str | 1 | 1 | 1 | 1 | |
| 30 | access_export_m2o_str_child | access_export_m2o_str_child | model_export_m2o_str_child | 1 | 1 | 1 | 1 |