Se rendre au contenu
Menu
Cette question a été signalée
6 Réponses
181 Vues

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
Ignorer
Meilleure réponse

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
Ignorer
Meilleure réponse

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
Ignorer
Meilleure réponse

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

Avatar
Ignorer
Auteur Meilleure réponse

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
Ignorer
Meilleure réponse

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
Ignorer
Publications associées Réponses Vues Activité
0
mars 25
1414
0
janv. 25
3493
1
août 23
14849
1
août 23
13499
1
juil. 23
10480