Skip to Content
Menu
This question has been flagged
1 Reply
2846 Views

in our custom-model we have 2 different form-views.

from treeview the user reaches the default form-view.

we also defined a special action associated to a menuitem, so the user can access  a special form-view:

<record id="action_go_to_specialview" model="ir.actions.server">
<field name="name">open Specialview</field>
<field name="condition">True</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="model_x_custompackage_custommodel" />
<field name="state">code</field>
<field name="code">action = model.get_specialview_action()</field>
</record>

the Method get_specialview_action returns an action as follows:

...
...
return {
'type': 'ir.actions.act_window',
'name': 'Message',
'res_model': 'x_custompackage.custommodel',
'view_type': 'form',
'view_mode': 'form',
'view_id' : view_id,
'target': 'current',
'flags': {'form': {'action_buttons': False, 'options': {'mode': 'view'}}},
'res_id': module_id
}

this works fine.

if a user opens this "Specialview" the alternateive special form-view will be shown.

BUT: if the user reloads the Page (Browser reload) instead of the special-form-view the default form-view will be rendered.

 


Avatar
Discard
Best Answer

Hi,

The idea was good. To create an action for call the form view. But here your issue is that the model is having another tree or form view. Thats why while reloading it is going to some other page.
First option is that setting a priority to the view.
The second one and the best will be mapping the tree and form view in the action. So that while refreshing also the same view will be loaded.
for eg: you need to set the view_ids
<record id="po_menu_action" model="ir.actions.act_window">
<field name="name">Purchase Order</field>
<field name="res_model">purchase.order</field>
<field name="view_mode">tree,form</field>
<field name="view_ids" eval="[(5, 0, 0),
(0, 0, {'view_mode': 'tree', 'view_id': ref('vendor_info.purchase_order_tree_view_for_vendor')}),
(0, 0, {'view_mode': 'form', 'view_id': ref('vendor_info.purchase_order_form_view_for_vendor')})]"/>
<field name="domain">[('partner_type','=','SUP')]</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">Create The First PO
</p>
</field>
</record>


Regards

Avatar
Discard