Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
6 Răspunsuri
193 Vizualizări

hello guys!!!

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

Thanks a lot in advance

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Cel mai bun răspuns

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.

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Autor Cel mai bun răspuns

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!!

Imagine profil
Abandonează
Cel mai bun răspuns

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>

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
0
mar. 25
1414
0
ian. 25
3493
1
aug. 23
14852
1
aug. 23
13503
1
iul. 23
10483