Files
odoo_source/odoo/addons/test_impex/ir.model.access.csv
T
Xavier Morel 7ac3a391a1 [FIX] core: don't break import on files triggering UnicodeEncodeError
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>
2021-06-22 09:33:43 +00:00

2.6 KiB

1idnamemodel_id:idgroup_id:idperm_readperm_writeperm_createperm_unlink
2access_export_booleanaccess_export_booleanmodel_export_boolean1111
3access_export_integeraccess_export_integermodel_export_integer1111
4access_export_floataccess_export_floatmodel_export_float1111
5access_export_decimalaccess_export_decimalmodel_export_decimal1111
6access_export_string_boundedaccess_export_string_boundedmodel_export_string_bounded1111
7access_export_string_requiredaccess_export_string_requiredmodel_export_string_required1111
8access_export_stringaccess_export_stringmodel_export_string1111
9access_export_dateaccess_export_datemodel_export_date1111
10access_export_datetimeaccess_export_datetimemodel_export_datetime1111
11access_export_textaccess_export_textmodel_export_text1111
12access_export_selectionaccess_export_selectionmodel_export_selection1111
13access_export_selection_functionaccess_export_selection_functionmodel_export_selection_function1111
14access_export_many2oneaccess_export_many2onemodel_export_many2one1111
15access_export_one2manyaccess_export_one2manymodel_export_one2many1111
16access_export_many2manyaccess_export_many2manymodel_export_many2many1111
17access_export_functionaccess_export_functionmodel_export_function1111
18access_export_one2many_childaccess_export_one2many_childmodel_export_one2many_child1111
19access_export_one2many_multipleaccess_export_one2many_multiplemodel_export_one2many_multiple1111
20access_export_one2many_multiple_childaccess_export_one2many_multiple_childmodel_export_one2many_multiple_child1111
21access_export_one2many_child_1access_export_one2many_child_1model_export_one2many_child_11111
22access_export_one2many_child_2access_export_one2many_child_2model_export_one2many_child_21111
23access_export_many2many_otheraccess_export_many2many_othermodel_export_many2many_other1111
24access_export_selection_withdefaultaccess_export_selection_withdefaultmodel_export_selection_withdefault1111
25access_export_one2many_recursiveaccess_export_one2many_recursivemodel_export_one2many_recursive1111
26access_export_uniqueaccess_export_uniquemodel_export_unique1111
27access_export_inherits_parentaccess_export_inherits_parentmodel_export_inherits_parent1111
28access_export_inherits_childaccess_export_inherits_childmodel_export_inherits_child1111
29access_export_m2o_straccess_export_m2o_strmodel_export_m2o_str1111
30access_export_m2o_str_childaccess_export_m2o_str_childmodel_export_m2o_str_child1111