It is currently Wed May 23, 2012 3:03 pm

All times are UTC + 2 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: TypeError: super(type, obj): obj must be an instance or subt
PostPosted: Thu Aug 18, 2011 5:26 am 
Offline

Joined: Wed Dec 01, 2010 11:38 am
Posts: 52
Hi,
My python version- 2.7 and Operation System Ubuntu version - 11

how to solve this type error:
----------------------
TypeError: super(type, obj): obj must be an instance or subtype of type

this error ll be displayed this line
----------------------------
return super(employee_role_project, self).create(cr, uid, vals, context=context)


any reply...


Top
 Profile  
 
 Post subject: Re: TypeError: super(type, obj): obj must be an instance or
PostPosted: Thu Aug 18, 2011 6:20 am 
Offline

Joined: Wed Jan 27, 2010 6:21 pm
Posts: 797
Location: Auckland, NZ
make sure the second argument (currently self) of the super call is an instance or subtype of employee_role_project

_________________
Graeme


Top
 Profile  
 
 Post subject: Re: TypeError: super(type, obj): obj must be an instance or
PostPosted: Thu Aug 18, 2011 9:00 am 
Offline

Joined: Wed Dec 01, 2010 11:38 am
Posts: 52
thx..


Top
 Profile  
 
 Post subject: Re: TypeError: super(type, obj): obj must be an instance or
PostPosted: Thu Aug 18, 2011 9:00 am 
Offline

Joined: Wed Dec 01, 2010 11:38 am
Posts: 52
gdaddy wrote:
make sure the second argument (currently self) of the super call is an instance or subtype of employee_role_project


thanks


Top
 Profile  
 
 Post subject: Re: TypeError: super(type, obj): obj must be an instance or
PostPosted: Thu Aug 18, 2011 9:04 am 
Offline

Joined: Wed Dec 01, 2010 11:38 am
Posts: 52
This is the source with error.. Kindly review and get back to me ... Thanks in advance ...

Code:
class employee_role_project(osv.osv):
   _name = 'custom.user.project.acces'
   _description = "Custom User Project Acces"
   _columns = {
      'div_code_id': fields.many2one('custom.project.division', 'Division Name',required=True, domain="[('name','!=',''),('isdefault','!=',1)]"),
      'project_id': fields.many2one('project.project', 'Project Name', required=True, domain="[('div_code_id','=',div_code_id)]"),
      'role_id': fields.many2one('custom.user.details', 'Project Name',ondelete='cascade'),
   }
   
   def create(self, cr, uid, vals, context=None):
      project_pool = self.pool.get('project.structure')
      aprt_type_pool = self.pool.get('custom.apartment.type')
      price_list_type_pool = self.pool.get('custom.price.list.type')
      price_list_pool = self.pool.get('custom.price.list')
      cpss_pool = self.pool.get('custom.payment.schedule.stages')
      cpsh_pool = self.pool.get('custom.payment.schedule.header')
      user_pool = self.pool.get('custom.user.details')
      acc_vou_pool = self.pool.get('account.voucher')
      acc_mov_pool = self.pool.get('account.move')
      acc_journal_pool = self.pool.get('account.journal')
      acc_batch_pool = self.pool.get('custom.voucher.batch.hdr')
      usr_ids = user_pool.search(cr, uid, [('id','=',vals.get('role_id'))])
      div_ids = self.search(cr, uid, [('div_code_id','=',vals.get('div_code_id')),('project_id','=',vals.get('project_id')),('role_id','=',vals.get('role_id'))])
      if div_ids:
         raise osv.except_osv(_('Invalid!'), _('Division and Project Should be unique for a User!'))
      for s in user_pool.browse(cr, uid, usr_ids, context):
         if div_ids:
            raise osv.except_osv(_('Invalid!'), _('Division and Project Should be unique for a User!'))
         if s:
            cr.execute('select * from custom_division_user_rel where div_code_id=%s and uid=%s',(vals.get('div_code_id'),s.user_id.id))
            res = cr.fetchall();
            if not res:
               cr.execute('insert into custom_division_user_rel(div_code_id,uid) values(%s,%s)', (vals.get('div_code_id'),s.user_id.id))
            #pro_str_ids = project_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
            #for pro_str in project_pool.browse(cr, uid, pro_str_ids, context):
            #   cr.execute('insert into project_structure_user_rel(project_structure_id,uid) values(%s,%s)', (pro_str.id,s.user_id.id))
            pro_str_ids = project_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
            for pro_str in project_pool.browse(cr, uid, pro_str_ids, context):
               cr.execute('insert into project_structure_user_rel(project_structure_id,uid) values(%s,%s)', (pro_str.id,s.user_id.id))
                              
            aprt_type_ids = aprt_type_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
            for aprt_type in aprt_type_pool.browse(cr, uid, aprt_type_ids, context):               
               #raise osv.except_osv(_('Error!'), _('%s-%s')%(aprt_type.id,s.user_id.id,))
               cr.execute('insert into custom_apartment_type_user_rel(apartment_type_id,uid) values(%s,%s)', (aprt_type.id,s.user_id.id))
            
            price_list_type_ids = price_list_type_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
            for pri_lst_type in price_list_type_pool.browse(cr, uid, price_list_type_ids, context):               
               cr.execute('insert into custom_price_list_type_user_rel(price_list_type_id,uid) values(%s,%s)', (pri_lst_type.id,s.user_id.id))
            
            price_list_ids = price_list_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
            for pri_lst in price_list_pool.browse(cr, uid, price_list_ids, context):               
               cr.execute('insert into custom_price_list_user_rel(price_list_id,uid) values(%s,%s)', (pri_lst.id,s.user_id.id))
            
            cpss_ids = cpss_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
            for cps_stage in cpss_pool.browse(cr, uid, cpss_ids, context):               
               cr.execute('insert into custom_payment_schedule_stages_user_rel(payment_schedule_stage_id,uid) values(%s,%s)', (cps_stage.id,s.user_id.id))
            
            cpsh_ids = cpsh_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
            for cps_header in cpsh_pool.browse(cr, uid, cpsh_ids, context):               
               cr.execute('insert into custom_payment_schedule_header_user_rel(payment_schedule_header_id,uid) values(%s,%s)', (cps_header.id,s.user_id.id))
                              
            acv_ids = acc_vou_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
            for acv in acc_vou_pool.browse(cr, uid, acv_ids, context):               
               cr.execute('insert into account_voucher_rel(account_voucher_id,uid) values(%s,%s)', (acv.id,s.user_id.id))
                              
            acm_ids = acc_mov_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
            for acm in acc_mov_pool.browse(cr, uid, acm_ids, context):               
               cr.execute('insert into account_move_rel(account_move_id,uid) values(%s,%s)', (acm.id,s.user_id.id))
                              
            acj_ids = acc_journal_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
            for acj in acc_journal_pool.browse(cr, uid, acj_ids, context):               
               cr.execute('insert into account_journal_rel(account_journal_id,uid) values(%s,%s)', (acj.id,s.user_id.id))
                              
            batch_ids = acc_batch_pool.search(cr, uid, [('project_id','=',vals.get('project_id'))])
            for batch in acc_batch_pool.browse(cr, uid, batch_ids, context):               
               cr.execute('insert into custom_voucher_batch_hdr_rel(custom_voucher_batch_hdr_id,uid) values(%s,%s)', (batch.id,s.user_id.id))
                              
               #raise osv.except_osv(_('Invalid action !'), _('%s,%s')%(vals.get('project_id'),s.user_id.id))            
      return super(employee_role_project, self).create(cr, uid, vals, context=context)




Top
 Profile  
 
 Post subject: Re: TypeError: super(type, obj): obj must be an instance or
PostPosted: Tue Aug 23, 2011 11:51 pm 
Offline

Joined: Mon Aug 20, 2007 10:14 pm
Posts: 134
Location: Russia, Saint-Petersburg
How many lines of code...
1. Remove second `if div_ids: raise ...` (in for)
2. Repeated construction: `search-for-execute` place in one loop with names of objects
3. cr.execute? Way not write method?

Show printed results of next print statements:

Code:
   .....
   def create(self, cr, uid, vals, context=None):
      print 'self1', self, type(self)
      .............
      print 'self2', self, type(self)
      return super(employee_role_project, self).create(cr, uid, vals, context=context)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 2 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:

Protected by Anti-Spam ACP