[FIX] O2M should check existing relations for its concerned M2O
lp bug: https://launchpad.net/bugs/456978 fixed bzr revid: jvo@tinyerp.com-20100121145807-ixlsuj3xakibd753
This commit is contained in:
parent
57cc12f1e8
commit
5f34983f0b
|
@ -1765,6 +1765,12 @@ class orm(orm_template):
|
|||
|
||||
if isinstance(f, fields.one2many):
|
||||
cr.execute("SELECT relname FROM pg_class WHERE relkind='r' AND relname=%s", (f._obj,))
|
||||
|
||||
if self.pool.get(f._obj):
|
||||
if f._fields_id not in self.pool.get(f._obj)._columns.keys():
|
||||
if not self.pool.get(f._obj)._inherits or (f._fields_id not in self.pool.get(f._obj)._inherit_fields.keys()):
|
||||
raise except_orm('Programming Error', ("There is no reference field '%s' found for '%s'") % (f._fields_id,f._obj,))
|
||||
|
||||
if cr.fetchone():
|
||||
cr.execute("SELECT count(1) as c FROM pg_class c,pg_attribute a WHERE c.relname=%s AND a.attname=%s AND c.oid=a.attrelid", (f._obj, f._fields_id))
|
||||
res = cr.fetchone()[0]
|
||||
|
|
Loading…
Reference in New Issue