Help

-1

Add button to form view

Avatar
mohamed

Hello

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

please see the picture in this link :http://i58.tinypic.com/v8k9xx.png

1 Comment
Avatar
Discard
Avatar
Gavin Yap
-

your url is not visible

3 Answers
2
Avatar
Rihene
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:

https://www.odoo.com/fr_FR/forum/help-1/question/opening-new-window-with-button-in-openerp-23833

https://answers.launchpad.net/openobject-client-web/+question/112492

Regards.


Avatar
Discard
1
Avatar
Tarek Mohamed Ibrahim
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


Avatar
Discard
0
Avatar
MUHAMMAD Imran
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">

          <header>

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

        </header>

 </form>

</field>

</record>
Avatar
Discard