Skip to Content
Menu
This question has been flagged
4379 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
Related Posts Replies Views Activity
4
Mar 18
5101
2
Feb 18
18851
1
Mar 15
20842
1
Nov 21
9933
0
Jan 17
1696