summaryrefslogtreecommitdiff
path: root/odoo/addons/base
diff options
context:
space:
mode:
authorJinal Patel <jip@odoo.com>2019-04-29 04:47:58 +0000
committerXavier Morel <xmo@odoo.com>2020-03-23 11:51:30 +0000
commit8f8c93b68a640f1503aec2c7f9fa1255afbb8aad (patch)
tree2658e9764aea102691cb19e3c182557d2d08331f /odoo/addons/base
parent800db7405c1fca3d080902562eb62d5072b7d9bb (diff)
[IMP] base: display full name of the field in import warning
Before this change, if an error occurs while trying to match / import a sub-field e.g. order_line/product_id, only the name of the top-level field is showing when displaying the error e.g. "Order Line", which lacks precision and makes understanding and fixing the issue more complicated. After this change, the entire field path should be displayed, e.g. "Order Line / Product" in the example above. Task-1906700 closes odoo/odoo#33031 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com> Co-authored-by: Mohammed Shekha <msh@odoo.com>
Diffstat (limited to 'odoo/addons/base')
-rw-r--r--odoo/addons/base/models/ir_fields.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/odoo/addons/base/models/ir_fields.py b/odoo/addons/base/models/ir_fields.py
index b68aa7c48f5..ec535fb569a 100644
--- a/odoo/addons/base/models/ir_fields.py
+++ b/odoo/addons/base/models/ir_fields.py
@@ -452,10 +452,13 @@ class IrFieldsConverter(models.AbstractModel):
# [{subfield:ref1},{subfield:ref2},{subfield:ref3}]
records = ({subfield:item} for item in record[subfield].split(','))
- def log(_, e):
- if not isinstance(e, Warning):
- raise e
- warnings.append(e)
+ def log(f, exception):
+ if not isinstance(exception, Warning):
+ current_field_name = self.env[field.comodel_name]._fields[f].string
+ arg0 = exception.args[0] % {'field': '%(field)s/' + current_field_name}
+ exception.args = (arg0, *exception.args[1:])
+ raise exception
+ warnings.append(exception)
convert = self.for_model(self.env[field.comodel_name])