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.

2

AttributeError: 'student_detail' object has no attribute '775'? [Closed]

By
evon_dun
on 6/5/13, 8:45 AM 1,930 views

The Question has been closed

by
Sudhir Arya (SA)
on 06/12/2013 07:53:24

I created a very small and simple module and created wizard in it. When i updated my module and try to use my wizard on the button call i got this error: AttributeError: 'student_detail' object has no attribute '775' for no reason. I searched all my module if there is mistyping or something but i am now not able to find out what went wrong. Kindly help if someone knows about this weird error.

here is my main model:

class student_detail(osv.osv):
    _name   =   'student.detail'
    _description    =   'Students'
    _columns    ={
            'fname':fields.char('First Name',size=64),
                    'lname':fields.char('Last Name', size=64),
                    'dob':fields.date('Date of Birth', required=True),
                    'stu_id':fields.char('Roll No.',size=24,required=True),
                    'city':fields.char('City',size=24,required=True),
                    'phone':fields.char('Contact',size=16),
                    'active': fields.boolean('Active')
            }
    _defaults = {
                'active': lambda *a: True,
                }
    def confirm(self, cr, uid, ids,Context=None):
                student = self.pool.get('student.detail')
                new_id = student.create(cr, uid, {'fname': student.fname,
                            'lname':student.fname,
                            'dob':student.dob,
                            'stu_id':student.stu_id,
                            'city':student.city,
                            'phone':student.phone,
                            'active':True,
                            })
                self.write(cr, uid, [student.id], {'student': new_id})
                return {}

    def action_cancel(self,cr,uid,ids,context=None):
        return {'type': 'ir.actions.act_window_close'} 

student_detail()

main view:

<?xml version="1.0"?>
<openerp>
    <data>
        <!-- TREE -->
        <record model="ir.ui.view" id="student_detail_tree_view">
            <field name="name">student.tree </field>
            <field name="model">student.detail</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Students">
                    <field name="fname"/>
                    <field name="lname"/>
                    <field name="dob"/>                 
                    <field name="stu_id"/>
                    <field name="city"/>
                </tree>
            </field>
        </record>
        <!-- FORM -->
        <record model="ir.ui.view" id="student_detail_form_view">
            <field name="name">student.form</field>
            <field name="model">student.detail</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Student Form">
                  <group colspan="4" col="6">
                    <field name="fname"/>
                    <field name="lname"/>
                    <field name="dob"/>                 
                    <field name="stu_id"/>
                    <field name="active"/>
                    <field name="city"/>
                    <field name="phone"/>
                  </group>
                    <separator colspan="4" col="2"/>
                    <button name="%(action_confirm_registration)d" string="Register" icon="gtk-ok" type="object" groups="base.group_user"/>
                    <button name="action_cancel" string="Cancel" special="cancel" type="object" icon="gtk-cancel" groups="base.group_user"/>
                </form>
            </field>
        </record>

        <record model="ir.actions.act_window" id="action_student_detail_form">
            <field name="name">Students</field>
            <field name="res_model">student.detail</field>
        </record>

        <menuitem name="Students" id="menu_student" action="action_student_detail_form" />
        <menuitem name="Student Info" id="menu_student_detail" parent="menu_student" action="action_student_detail_form" />



    </data>
</openerp>

wizard.py:

from osv import fields, osv

class confirm_registration(osv.osv_memory):

    _name = "confirm.registration"
    _description = "confirm registration"

    _columns = {
        'confirm_student':fields.many2one('student.detail', 'Student', required=True),
    }

    def confirm(self, cr, uid, ids, context=None):        
        if context is None:
            context = {}
        data = context and context.get('active_ids', []) or []
        stu_ref = self.pool.get('student.detail')

        for confirm_obj in self.browse(cr, uid, ids, context=context):
            stu_ref.confirm(cr, uid, data, confirm_obj.confirm_student.id, context)
            return {'type': 'ir.actions.act_window_close'}

confirm_registration()

and wizard view:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>

<!-- confirm student  -->

    <record id="view_confirm_registration" model="ir.ui.view">
            <field name="name">confirm.registration.form</field>
            <field name="model">confirm.registration</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Register">
                    <group colspan="4" >
                         <separator string="Registration Confirmation" colspan="4"/>
                         <field name="confirm_student"/>
                         <newline/>
                    </group>
                        <separator string="" colspan="4" />
                    <group colspan="4" col="6">
                        <button  icon="gtk-cancel" special="cancel" string="Cancel"/>
                        <button  icon="gtk-ok" name="confirm" string="Confirm" type="object"/>
                   </group>
               </form>
            </field>
        </record>

        <record id="action_confirm_registration" model="ir.actions.act_window">
            <field name="name">Confirm Student</field>
            <field name="res_model">confirm.registration</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
           <field name="view_id" ref="view_confirm_registration"/>
           <field name="target">new</field>
        </record>

        <act_window id="action_confirm_registration_values"
            key2="client_action_multi" name="Confirm Student"
            res_model="confirm.registration" src_model="student.detail"
            view_mode="form" target="new" view_type="form"/>

    </data>
</openerp>
5

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 6/5/13, 8:52 AM

It seems problem is here:

stu_ref.confirm(cr, uid, data, confirm_obj.confirm_student.id, context)

You either need to pass data or confirm_obj.confirm_student.id because in confirm() method you have cr, uid, ids, context as parameters.

Try this.

Hope this will solve your problem.

hey m getting confused do i need to pass only confirm_student.id??

evon_dun
on 6/5/13, 9:05 AM

It's up to you what you want to do.

Sudhir Arya (SA)
on 6/5/13, 9:10 AM

If you want to do changes on selected student in wizard then pass confirm_student.id.

Sudhir Arya (SA)
on 6/5/13, 9:11 AM

I too have this error, but not because I don't pass anything. I simply cannot launch my wizard without getting the same error (different number though). Does this have to do with the dynamic XML ID reference?

David Brilliant
on 9/17/13, 12:19 PM

About This Community

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

Question tools

0 follower(s)

Stats

Asked: 6/5/13, 8:45 AM
Seen: 1930 times
Last updated: 3/16/15, 8:10 AM