-
Notifications
You must be signed in to change notification settings - Fork 81
[ADD] util: view helper functions for active tag #364
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
base: master
Are you sure you want to change the base?
Conversation
Helper functions for activating and disabling views. Addition of two functions to simplify the manipulation of the active state of ir.ui.view records. Function call is done through a util.disable_views(cr, (view_ids)), with view_ids being a list. util.activate_views(cr, (view_ids)) works the same way.
| if isinstance(view_ids, int): | ||
| cr.execute("UPDATE ir_ui_view SET active='f' WHERE id = %s", [view_ids]) | ||
| else: | ||
| cr.execute("UPDATE ir_ui_view SET active='f' WHERE id IN %s", [view_ids]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestions ->
- there should probably also be a instance check for list/tuple in case of multiple view_ids
- both cases of single/multiple views can be handled with the IN operator, something like
| cr.execute("UPDATE ir_ui_view SET active='f' WHERE id IN %s", [view_ids]) | |
| if isinstance(view_ids, int): | |
| views_to_update = list(view_ids) | |
| if isinstance(view_ids,list): | |
| views_to_update = view_ids | |
| if views_to_update: | |
| cr.execute("UPDATE ir_ui_view SET active='f' WHERE id IN %s", [tuple(view_ids)]) |
- same comment for activate
|
I don't think we will add a util to wrap simple queries. ;) |
|
upgradeci retry with always only base |
These functions can be useful though! Some team members or mine and I find myself disabling and reactivating views quite often. Maybe we can put these functions in local_util then? Let me know! :) |
|
I fail to see any significant improvement in util.disable_views(cr, [1,2,3])vs cr.execute("UPDATE ir_ui_view SET active = False WHERE id = ANY(%s)", [[1, 2, 3]])We cannot wrap every query that we reuse in a util function. That's not the purpose of the utils. The functions here are meant to wrap more involved behavior. Maybe in local_utils is fine if you esteem that the rate of mistakes in the simple query above is too high. I'd still say that we should make reviewers pay attention to what they review instead ;) Anyway I don't want to impose my view. @KangOl up to you :) |

Helper functions for activating and disabling views.
Addition of two functions to simplify the manipulation of the active state of ir.ui.view records. Function call is done through a util.disable_views(cr, (view_ids)), with view_ids being a list.
util.activate_views(cr, (view_ids)) works the same way.