Skip to Content
Menu
This question has been flagged
1 Reply
31274 Views

Hi to all . I have been working on developing openerp v-7 module . I have put a button along with fields , and have also created an action to the button . But on clicking the button , it is doing nothing.

here is myform.py

from osv import fields, osv import time

class my_form(osv.osv):

_name = "my.form"
_description = 'Formview Module'
_columns = {
    'name': fields.char('Name', size=64),
    'project': fields.char('Project', size=64),
    'image': fields.binary('Image'),
    'file':fields.binary('attach file')
}

class my_form2(osv.osv):

_name="my.form2"
_description="new form"
_columns={
          'add':fields.char('Address',size=64)
          }

here is myform_view.xml

<openerp> <data>

    <record model="ir.ui.view" id="from_view_form">
        <field name="name">form.view.form</field>
        <field name="model">my.form</field>
        <field name="arch" type="xml">
            <form string="Form" version="7.0">
                <group>
                    <field name="name" />
                    <field name="project" />
                    <button id="add_field" string="Add Field" type="action" />
                </group>
            </form>
        </field>
    </record>



    <record model="ir.ui.view" id="from_view_form2">
        <field name="name">form.view.form</field>
        <field name="model">my.form</field>
        <field name="arch" type="xml">
            <form string="Form" version="7.0">
               <group>
                   <field name="name"/>
               </group>
            </form>
        </field>
    </record>





    <record model="ir.ui.view" id="from_view_tree">
        <field name="name">form.view.tree</field>
        <field name="model">my.form</field>
        <field name="arch" type="xml">
            <tree string="Form">
                <field name="name" />
            </tree>
        </field>
    </record>    

    <record model='ir.actions.act_window' id='add_field'>
        <field name="name">Form</field>
        <field name="res_model">my.form</field>
        <field name="view_type">form</field>
        <field name="view_mode">form</field>
        <field name="context">{}</field>
        <field name="help" type="html">
            <p class="oe_view_nocontent_create">
                Click to create a new record.
            </p>
            <p>This is a test class developed to learn Openerp.</p>
        </field>
    </record>




    <record model='ir.actions.act_window' id='form_view_action'>
        <field name="name">Form</field>
        <field name="res_model">my.form</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="context">{}</field>
        <field name="help" type="html">
            <p class="oe_view_nocontent_create">
                Click to create a new record.
            </p>
            <p>This is a test class developed to learn Openerp.</p>
        </field>
    </record>

    <menuitem id="myform_ID" name="myforms" />

    <menuitem id="myform_menu_ID" name="myform" parent="myform_ID"  />

    <menuitem id="myform_menu2_ID" name="myform" parent="myform_menu_ID"  action='form_view_action' />

</data>

</openerp>

Avatar
Discard
Best Answer

You should use name attribute instead of id in your button

name='%(add_field)d'
Avatar
Discard

This answer is backed up by the official documentation. See http://openerp-server.readthedocs.org/en/latest/03_module_dev_03.html#button and https://doc.openerp.com/trunk/server/form-view-guidelines/

Related Posts Replies Views Activity
0
Mar 15
3421
1
Mar 15
9054
0
Mar 15
4040
1
Mar 15
4863
0
Mar 15
2880