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

I'm using OpenERP V7,need some basic helps. Added a new icon in POLine ,When Click on this icon , need to display the popup screen for entering data.

Created new Xml,py file under Wizard in Purchase Module.

add.xml code:

<openerp>
<data>
    <record id="add_slab_form" model="ir.ui.view">
        <field name="name">Add Slab</field>
        <field name="model">add.slab</field>
        <field name="arch" type="xml">
            <form string="Add Slab" version="7.0">
                <group col="4" colspan="4">                                                                 
                    <field name="block_no"/>
                    <field name="product_id"/>
                    <field name="slab_qty"/>
                    <field name="price"/>
                    <field name="other_charges"/>
                </group>
                <separator string="Slab Dimensions"/>
                <group col="6" colspan="4">
                    <field name="length"/>
                    <field name="width"/>
                    <field name="uom"/>                     
                    <field name="sequence" invisible="1"/>
                </group>
                <footer>
                    <button name="add_slab_info" string="Add" type="object" class="oe_highlight"/>
                    or
                    <button string="Cancel" class="oe_link" special="cancel" />
                </footer>
            </form>             
        </field>
    </record>       
    <record id="add_slab_action" model="ir.actions.act_window">
        <field name="name">Add Slab</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">add.slab</field>
        <field name="view_type">form</field>
        <field name="view_mode">form</field>
        <field name="target">new</field>
        <field name="view_id" ref="add_slab_form"/>
    </record>               
</data>

</openerp> Form view get installed and i cant see the action view.

Button Action Code called in purchase_view.xml file

<button name="%(add_slab_action)d" icon="gtk-add"  string="Add Slab" type="action"/>

add.py

 def add_slab_action(self, cr, uid, ids, context=None):
    return {
           'type': 'ir.actions.act_window',
           'name': 'Add Slab',
           'view_mode': 'form',
           'view_type': 'form',
           'res_model': 'add.slab',
           'nodestroy': True,
           'target':'new',
           'context': context,
}

I got an error : ValueError: No such external ID currently defined in the system: purchase.add_slab_action

Button Action is not performing ,How do i resolve?

Avatar
Discard
Best Answer

Hello,

There are three kinds of types for button:

  • Types
    • object,
    • action &
    • workflow.

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

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

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".

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

Avatar
Discard
Author

<button name="%(add_slab_action)d" icon="gtk-add" string="Add Slab" type="action"/> , requesting about my error

Actually you are using type="action" that means action is used if you want to call any action which is written in .xml file. in your code you are using "add_slab_action" so system will try to find related named xml id and there is no any xml id present so its give you error.

You can do it by simply , <button name="add_slab_action" icon="gtk-add" string="Add Slab" type="object"/>

Author

I changed to Object , throws AttributeError: 'purchase.order.line' object has no attribute 'add_slab_action'

Related Posts Replies Views Activity
1
Sep 25
526
2
Aug 25
655
1
Sep 25
586
1
Sep 25
580
0
Aug 25
490