This question has been flagged
3950 Views

Hello, I want to use def __init__ () method to call a method when object initialization but when I run my code
my browser shows me 
The page isn’t redirecting properly 
Version 8.0

this is my code 

class myobject(models.Model):
_name = 'myobject'
name = fields.Char('Title', required=True, track_visibility="always")
def __init__(self, cr, uid):
self._cr=uid
self._cr=cr
manager_ref = self.pool.get('ir.model.data').get_object_reference(cr,1, 'mymodule', 'xml_name')[1]
cr.execute("SELECT uid from res_groups_users_rel where gid=%s", (manager_ref,))
list_manager=cr.fetchall()
for manger_id in list_manager:
cr.execute("""
INSERT INTO
myobject SELECT DISTINCT
id,partner_id,create_uid,create_date,login,write_uid,write_date
FROM
res_users
WHERE id=%s and id NOT IN (SELECT id
FROM
myobject ) """,(manger_id[0],))
super(myobject, self).__init__(self,cr, uid,context)
How to Fix that .
Avatar
Discard