Trợ giúp


Add button to form view



i want to add button to form view (ir.ui.view model) like "create" button 

please see the picture in this link :

1 Bình luận
Ảnh đại diện
Huỷ bỏ
Gavin Yap

your url is not visible

3 Câu trả lời
Best Answer

There are three kinds of types for button: object, action & workflow. workflow is the default.

Now let's understand the meaning of these three types:

1.object is used if you want to call a method which is written in .py file.

2.action is used if you want to call any action which is written in .xml file. Let say if you want to open a wizard from button click then you can use type="action".

3.workflow (the default) is used if you want to call workflow.

<button name="%(action_view_sale_advance_payment_inv)d"  string="Create Invoice"  type="action">

when Create Invoice button is clicked, you will see a wizard.

<button name="278" string="Create Invoice" type="action">

Here 278 is an ID in postgresql database of action_view_sale_advance_payment_inv action.

Here some useful links as a beginner in this field:


Ảnh đại diện
Huỷ bỏ
Best Answer

check for example, openerp\addons\sale\sale_view.xml. . Search for the <button> tag.

If the button's response is a method in the related class of the view then it should has the type type="object"

if the button's response is an action then there must be an action defined in the module that the button will refer to and type="action"

If the button is a workflow button then type="workflow", and there should be a workflow action the button refers to

Ảnh đại diện
Huỷ bỏ
Best Answer

form view in create button 

view.xml  file 

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

      <field name="name">teachar.details.form</field>

     <field name="model">teachars.teacher</field>

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

    <form string="terchar.details">


               <button name="send_mail_template" string="Send e-mail" type="object" class="oe_highlight"/>




Ảnh đại diện
Huỷ bỏ