How to change the priority of an existing view

In the post The importance of correctly setting priority on inherited views we have already discussed the importance of the priority​ field in the inherited views and why it needs to have the right value. 

However, in some cases, it may be needed to update the priority of an existing view to meet certain requirements. The simplest case for that can be a request to change the primary view for a model that has multiple views from the same type.

The code sample below presents a way to modify the priority for an existing view from the codebase. In the particular example, the priority of the  view_order_tree​ view in the sale module is updated to value 5​. 


<function model="ir.ui.view" name="write" eval="[ref('sale.view_order_tree')], {'priority': 5}"/>

That would mean that in the system the list view with the biggest priority for the sale.order​ model will be view_quotation_tree​, which has a priority of 4​, and that one will be used always when the list view is not explicitly specified in the action.