parent
d02ffad04f
commit
a0b7a8f4e6
|
@ -308,12 +308,16 @@ class orm_template(object):
|
||||||
cr.execute('SELECT nextval(%s)', ('ir_model_id_seq',))
|
cr.execute('SELECT nextval(%s)', ('ir_model_id_seq',))
|
||||||
model_id = cr.fetchone()[0]
|
model_id = cr.fetchone()[0]
|
||||||
cr.execute("INSERT INTO ir_model (id,model, name, info,state) VALUES (%s, %s, %s, %s,%s)", (model_id, self._name, self._description, self.__doc__, 'base'))
|
cr.execute("INSERT INTO ir_model (id,model, name, info,state) VALUES (%s, %s, %s, %s,%s)", (model_id, self._name, self._description, self.__doc__, 'base'))
|
||||||
if 'module' in context:
|
|
||||||
cr.execute("INSERT INTO ir_model_data (name,date_init,date_update,module,model,res_id) VALUES (%s, now(), now(), %s, %s, %s)", \
|
|
||||||
('model_'+self._name.replace('.','_'), context['module'], 'ir.model', model_id)
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
model_id = cr.fetchone()[0]
|
model_id = cr.fetchone()[0]
|
||||||
|
if 'module' in context:
|
||||||
|
name_id = 'model_'+self._name.replace('.','_')
|
||||||
|
cr.execute('select * from ir_model_data where name=%s and res_id=%s', (name_id,model_id))
|
||||||
|
if not cr.rowcount:
|
||||||
|
cr.execute("INSERT INTO ir_model_data (name,date_init,date_update,module,model,res_id) VALUES (%s, now(), now(), %s, %s, %s)", \
|
||||||
|
(name_id, context['module'], 'ir.model', model_id)
|
||||||
|
)
|
||||||
|
|
||||||
cr.commit()
|
cr.commit()
|
||||||
|
|
||||||
cr.execute("SELECT * FROM ir_model_fields WHERE model=%s", (self._name,))
|
cr.execute("SELECT * FROM ir_model_fields WHERE model=%s", (self._name,))
|
||||||
|
|
Loading…
Reference in New Issue