Skip to Content
Menu
This question has been flagged
2 Replies
4908 Views

hi,

I want to open a wizard, a new form when I click on this button in my purchase.order tree view:


  My Code looks like this: 

<button name="this_test" string="test Button" type="object"/> 


<record id="purchase_order_addon_form" model="ir.ui.view"> <field name="name">purchase.order.addon.form</field> <field name="model">purchase.order</field>  <field name="arch" type="xml"> <form string="testing"> <sheet> <div class="oe_title"> <h1> <!--<field name="name" readonly="1"/>--> </h1> </div>  </sheet>

</form> </field> </record>

@api.multi def this_test(self): view_id = self.env.ref('my_module.purchase_order_addon_form').id context = self._context.copy() return { 'name':'test123', 'view_type':'form', 'view_mode':'form', 'views' : [(view_id,'form')], 'res_model':'purchase.order', 'view_id':view_id, 'type':'ir.actions.act_window', 'res_id':self.id, 'target':'new', 'context':context, }

Now when I click the button, the wizard popups with my designed xml view.

My problem is, when I click not on the button, but on the record, the same view is called, and I don't understand why...

Do I need a new model for that, or is that another way to handle this issue?


Thank you

Avatar
Discard
Best Answer

You just need to change the "priority" of your custom form view.

EX:

<record id="test_id" model="ir.ui.view">
<field name="model">my.test.model</field>
<field name="name">test.form</field>
<field name="priority">100</field>
</record>

It is a priority for the views. Lower the number means higher the priority (priority 1 is higher than priority 10).

If there action is not bind to any view(s), system will automatically bind the views that has high priority.

Hope this will help you.

Sudhir Arya
ERP Harbor Consulting Services
skype: 
sudhir@erpharbor.com  website: http://www.erpharbor.com
Avatar
Discard
Author

thank you, I have fixed the issue with this: <field name="priority">100</field>

what is the meaning of priority in the views?

It is a priority for the views. Lower the number means higher the priority (priority 1 is higher than priority 10).

If there action is not bind to any view(s), system will automatically bind the views that has high priority.

Please accept the answer if it has solved your issue so that others can take it's reference.

It is a priority for the views. Lower the number means higher the priority (priority 1 is higher than priority 10).

If there action is not bind to any view(s), system will automatically bind the views that has high priority.

Best Answer

Try to bind your action with the form view like this.

<record id="ir_action_window_view2" model="ir.actions.act_window.view">
<field eval="2" name="sequence"/>
<field name="view_mode">form</field>
<field name="view_id" ref="view_window_action_form"/>
<field name="act_window_id" ref="ir_action_window"/>
</record>

Here replace the act_window_id with your action and view_id with your custom model. If this donts works then kindly comment your queries here.

Avatar
Discard
Related Posts Replies Views Activity
0
Oct 23
593
2
Dec 19
1648
0
Nov 18
2263
4
Oct 18
7107
3
Jun 18
5861