Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

OpenERPV7:Button Action in PO - Error:No such external ID currently defined in the system

By
Silviaa
on 1/3/14, 4:19 AM 1,018 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?

0
Pinakin Nayi (pna)
On 1/3/14, 4:55 AM

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.

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

Silviaa
on 1/3/14, 6:31 AM

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.

Pinakin Nayi (pna)
on 1/3/14, 8:14 AM

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

Pinakin Nayi (pna)
on 1/3/14, 8:16 AM

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

Silviaa
on 1/3/14, 8:32 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 1/3/14, 4:19 AM
Seen: 1018 times
Last updated: 3/16/15, 8:10 AM