Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
6 Odgovori
195 Prikazi

hello guys!!!

please who can explain to me how to create a button that opens a new view please.

Thanks a lot in advance

Avatar
Opusti
Best Answer

Dear Abdelwahed,

Its very simple to create button in view.

Example

<button name="your_method_name" type="object" string="label"/>

Hope this helpfully for you

Thanks & Regards

Ankit H Gandhi

Avatar
Opusti
Best Answer

Hello,

For Example:- The action is defined like this,


 <record id="calculate_marks_action" model="ir.actions.act_window">
<field name = "name">Result</field>
<field name = "res_model">calculate.marks</field>
<field name = "view_type">form</field>
<field name = "view_mode">form,tree</field>
</record>


Then to trigger this action and open its view you need to define the button as:-


<button type='action' name='%(calculate_marks_action)d' string="Button A" />


Hence the general syntax for the button to open a new view can be:-


<button type='action' name='%(your_action_id)d' string="Button Text" />


Hope this helps,


Thank You.

Avatar
Opusti
Best Answer

button name="%(action_account_invoice_payment)d" type="action" states="open" string="Register Payment" groups="account.group_account_invoice" class="oe_highlight"

Avatar
Opusti
Avtor Best Answer

Thanks a lot for your answer. But, my question was how to create a button that make you open a new view defined in an other class!!

Avatar
Opusti
Best Answer

Create Forms for Your Model and add like below code in xml


<record id="view_employee_form_loan" model="ir.ui.view">

<field name="name">hr.employee.loan.form</field>

<field name="model">hr.employee</field>

<field name="inherit_id" ref="hr.view_employee_form"/>

<field name="arch" type="xml">

<data>

<button name="%(act_hr_employee_loan_request)d" string="Check Loan" class="oe_inline oe_stat_button" icon="fa-book" type="action" groups="base.group_hr_user"/>

</data>

</field>

</record>



<record id="act_hr_employee_loan_request" model="ir.actions.act_window">

<field name="name">Loans</field>

<field name="type">ir.actions.act_window</field>

<field name="res_model">hr.employee.loan</field>

<field name="view_type">form</field>

<field name="view_mode">tree,form</field>

<field name="context">{'search_default_employee_id': [active_id], 'default_employee_id': active_id}</field>

</record>

Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
0
mar. 25
1414
0
jan. 25
3493
1
avg. 23
14852
1
avg. 23
13503
1
jul. 23
10483