KERNEL: update relate fields

bzr revid: ced-c9c2e42c141209faeb0a106ce0aa6cda9a34f7b7
This commit is contained in:
ced 2007-02-21 12:50:58 +00:00
parent 133cc253ed
commit eb4e4b5056
1 changed files with 5 additions and 1 deletions

View File

@ -263,11 +263,15 @@ class orm(object):
for k in self._columns:
f = self._columns[k]
cr.execute("select id from ir_model_fields where model=%s and name=%s", (self._name,k))
cr.execute("select id, relate from ir_model_fields where model=%s and name=%s", (self._name,k))
if not cr.rowcount:
cr.execute("select id from ir_model where model='%s'" % self._name)
model_id = cr.fetchone()[0]
cr.execute("INSERT INTO ir_model_fields (model_id, model, name, field_description, ttype, relate,relation,group_name,view_load) VALUES (%d,%s,%s,%s,%s,%s,%s,%s,%s)", (model_id, self._name, k, f.string.replace("'", " "), f._type, (f.relate and 'True') or 'False', f._obj or 'NULL', f.group_name or '', (f.view_load and 'True') or 'False'))
else:
id, relate = cr.fetchone()
if relate != f.relate:
cr.execute("UPDATE ir_model_fields SET relate=%s WHERE id=%d", ((f.relate and 'True') or 'False', id))
cr.commit()
def _auto_init(self, cr):