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

[ADD] Add view autofix functions #31911

Closed
wants to merge 3 commits into from

Conversation

Projects
None yet
6 participants
@nvn-odoo
Copy link
Contributor

nvn-odoo commented Mar 18, 2019

Those functions are never called from odoo but allows to be called externally.
(server actions, migrations, ...)

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@nvn-odoo nvn-odoo requested review from ALE-Odoo and dbo-odoo Mar 18, 2019

@robodoo robodoo added the CI 🤖 label Mar 18, 2019

@C3POdoo C3POdoo added the RD label Mar 18, 2019

@nvn-odoo nvn-odoo force-pushed the odoo-dev:12.0-automatic-view-testing2-nvn branch from 8f4f7d3 to d84020c Mar 19, 2019

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Mar 19, 2019

[ADD] Add view autofix functions
Those functions are never called from odoo but allows to be called externally.
(server actions, migrations, ...)

@nvn-odoo nvn-odoo force-pushed the odoo-dev:12.0-automatic-view-testing2-nvn branch from d84020c to aec1f3d Mar 22, 2019

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Mar 22, 2019

Show resolved Hide resolved odoo/addons/base/models/ir_ui_view.py
Show resolved Hide resolved odoo/addons/base/models/ir_ui_view.py Outdated
Show resolved Hide resolved odoo/addons/base/models/ir_ui_view.py Outdated
Show resolved Hide resolved odoo/addons/base/models/ir_ui_view.py Outdated
Show resolved Hide resolved odoo/addons/base/models/ir_ui_view.py Outdated
Show resolved Hide resolved odoo/addons/base/models/ir_ui_view.py Outdated
_logger.warning("Issue occurs: The proposition made to fix the view %s (disable/delete %s) is not recommended" % (view,faulty_views))
# should not happend

def _get_faulty_views(self,parent_view, disabled_views):

This comment has been minimized.

Copy link
@dbo-odoo

dbo-odoo Apr 4, 2019

Contributor

You could do

def _get_faulty_views(self,parent_view=None):
if parent_view is None:
    parent_view = self
    self._cr.execute('SAVEPOINT test_fix_views')

weird to pass empty recordset as arg

This comment has been minimized.

Copy link
@dbo-odoo

dbo-odoo Apr 4, 2019

Contributor

to check:
avoid savepoint and only work in cache with update({})?

This comment has been minimized.

Copy link
@nvn-odoo

nvn-odoo Apr 4, 2019

Author Contributor

Not really motivated to do it:
I don't really know from where this will be called. (from saas-migration but not only) if called from a custom server action, I prefer be sure that we rollback to savepoint instead of using updating only the cache and the issue that comes with it.

This comment has been minimized.

Copy link
@nvn-odoo

nvn-odoo Apr 10, 2019

Author Contributor

not done

Show resolved Hide resolved odoo/addons/base/models/ir_ui_view.py Outdated
Show resolved Hide resolved odoo/addons/base/models/ir_ui_view.py Outdated

@robodoo robodoo removed the CI 🤖 label Apr 4, 2019

@nvn-odoo nvn-odoo force-pushed the odoo-dev:12.0-automatic-view-testing2-nvn branch from 6854853 to 7c3d92e Apr 4, 2019

@robodoo robodoo added the CI 🤖 label Apr 4, 2019

@nvn-odoo

This comment has been minimized.

Copy link
Contributor Author

nvn-odoo commented Apr 4, 2019

I think I've updated the code. just let me know if i missed some points.
Thank you very much for your review and your patience. :-)

@nvn-odoo nvn-odoo requested a review from lcontzen Apr 8, 2019

@dbo-odoo dbo-odoo self-assigned this Apr 9, 2019

# should not happend

def _get_faulty_views(self,parent_view=None):
""" Returns the faulty views

This comment has been minimized.

Copy link
@dbo-odoo

dbo-odoo Apr 9, 2019

Contributor

/python nazi on
PEP 257 for docstrings: https://www.python.org/dev/peps/pep-0257/

    def _get_faulty_views(self,parent_view=None):
        """Returns faulty views in the view's inheritance architecture.

            To determine the faulty views, we travel the tree recursively by first
            disabling all children, then re-enabling them one by one and check
            view validity. If there is an issue, the activated node or at least one
            of its children is faulty - disable faulty node and continue recursion.
    usage:
        view1._get_faulty_views()
        """

+ adapt content of docstring if you use the thing i said below to find the parent automatically (even if the view on which this code is called is not a primary view)
/python nazi off

This comment has been minimized.

Copy link
@nvn-odoo

nvn-odoo Apr 10, 2019

Author Contributor

I hope this is solved, I manually adapt it and also run a auto PEP8 on my code

@robodoo robodoo removed the CI 🤖 label Apr 10, 2019

@robodoo robodoo added the CI 🤖 label Apr 10, 2019

@nvn-odoo nvn-odoo force-pushed the odoo-dev:12.0-automatic-view-testing2-nvn branch from 4a688ea to 52f804b Apr 10, 2019

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Apr 10, 2019

@nvn-odoo

This comment has been minimized.

Copy link
Contributor Author

nvn-odoo commented Apr 10, 2019

Another try :-)

@nvn-odoo

This comment has been minimized.

Copy link
Contributor Author

nvn-odoo commented Apr 16, 2019

task cancelled, will be handled by another task more generic

@nvn-odoo nvn-odoo closed this Apr 16, 2019

@robodoo robodoo added closed 💔 and removed CI 🤖 labels Apr 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.