Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0] openupgrade_framework: Crash on certain view validations #3060

Open
pedrobaeza opened this issue Jan 9, 2022 · 3 comments
Open

[14.0] openupgrade_framework: Crash on certain view validations #3060

pedrobaeza opened this issue Jan 9, 2022 · 3 comments
Labels
Milestone

Comments

@pedrobaeza
Copy link
Member

pedrobaeza commented Jan 9, 2022

Steps to reproduce the problem:

  • Have an old view with a tree with colors attribute.
  • Remove such view in v14 code.
  • Perform the migration to v14.

As a result, the migration process is aborted with this error:

Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 677, in _tag_root
    f(rec)
  File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 580, in _tag_record
    record = model._load_records([data], self.mode == 'update')
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4209, in _load_records
    data['record']._load_records_write(data['values'])
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_ui_view.py", line 1841, in _load_records_write
    super(View, self)._load_records_write(values)
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4146, in _load_records_write
    self.write(values)
  File "/opt/odoo/auto/addons/website/models/theme_models.py", line 267, in write
    res = super(IrUiView, other_views).write(vals)
  File "/opt/odoo/auto/addons/website/models/ir_ui_view.py", line 68, in write
    return super(View, self).write(vals)
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_ui_view.py", line 500, in write
    res = super(View, self).write(self._compute_defaults(vals))
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3704, in write
    fields[0].determine_inverse(real_recs)
  File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 1187, in determine_inverse
    getattr(records, self.inverse)()
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_ui_view.py", line 300, in _inverse_arch
    view.write(data)
  File "/opt/odoo/auto/addons/website/models/theme_models.py", line 267, in write
    res = super(IrUiView, other_views).write(vals)
  File "/opt/odoo/auto/addons/website/models/ir_ui_view.py", line 68, in write
    return super(View, self).write(vals)
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_ui_view.py", line 500, in write
    res = super(View, self).write(self._compute_defaults(vals))
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3694, in write
    real_recs._validate_fields(vals, inverse_fields)
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 1266, in _validate_fields
    check(self)
  File "/opt/odoo/auto/addons/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_ui_view.py", line 17, in _check_xml
    return View._check_xml._original_method(self)
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_ui_view.py", line 401, in _check_xml
    raise ValidationError(_(
odoo.exceptions.ValidationError: Vista no disponible ... (...) definición en ....xml

As the validation is performed before the cleaning of the views, the check is performed no matter if it's going to be removed later. Specifically, this is the exception risen:

https://github.com/odoo/odoo/blob/1ff58be8f19becb3436348ed6b44fe69247cd057/odoo/addons/base/models/ir_ui_view.py#L401

Current workaround:

  • Remove by hand the view in DB (DELETE FROM ir_ui_view WHERE id=...) before performing the upgrade.

@Tecnativa

@pedrobaeza pedrobaeza added the bug label Jan 9, 2022
@pedrobaeza pedrobaeza added this to the 14.0 milestone Jan 9, 2022
@legalsylvain legalsylvain removed their assignment Jun 14, 2022
@legalsylvain
Copy link
Contributor

Hi @pedrobaeza. Thanks for reporting.

If I understand correctly,

ir_ui_view._check_xml() function call tools.view_validation._valid_view(). the second function return True (all is OK, warning or False : KO). In odoo standard, _check_xml() will raise an error if _valid_view() return False.
see https://github.com/odoo/odoo/blob/14.0/odoo/addons/base/models/ir_ui_view.py#L398

In previous Openupgrade version, there was a change in the function tools.view_validation._valid_view to avoid to return False if the view was incorrect. (here : ca419f6#diff-a5bc4c4e6d38b528ce9e08db95e0054741ad80fc32b1ec484fa6c5a40f6ae091L10)
@StefanRijnhart : you removed that part during the final refactoring, do you remember why ?

I think that the current patch is not sufficient. https://github.com/OCA/OpenUpgrade/blob/14.0/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_ui_view.py#L14
It prevent log but doesn't catch errors.
Don't you think ?

kind regards.

@StefanRijnhart
Copy link
Member

Yes, you are right. At the time, I looked for individual calls to _check_xml and it seemed like they were all wrapped in try/except blocks that did not raise further (such as https://github.com/odoo/odoo/blob/14.0/odoo/addons/base/models/ir_ui_view.py#L1811-L1814), but I did not pay any attention to the fact that it is also a constraint method (https://github.com/odoo/odoo/blob/14.0/odoo/addons/base/models/ir_ui_view.py#L377-L378). So we need to catch the exceptions directly in our override of _check_xml.

@pedrobaeza
Copy link
Member Author

@StefanRijnhart @MiquelRForgeFlow do you see an easy patch on openupgrade_framework for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants