Remove unused one2one field

This commit is contained in:
Cédric Krier committed 2008-06-23 14:21:07 +02:00
1 parent 047f445873
commit 3f10e57251
4 files changed
+7 -36

No files matched your search

-28
View File
@@ -300,34 +300,6 @@ class Selection(Column):
selection = Selection
class One2One(Column):
_classic_read = False
_classic_write = True
_type = 'one2one'
def __init__(self, obj, string='unknown', **args):
warnings.warn("The one2one field doesn't work anymore",
DeprecationWarning)
Column.__init__(self, string=string, **args)
self._obj = obj
def set(self, cursor, obj_src, src_id, field, act, user=None, context=None):
obj = obj_src.pool.get(self._obj)
if act[0] == 0:
id_new = obj.create(cursor, user, act[1])
cursor.execute('UPDATE "' + obj_src._table + '" ' \
'SET "' + field + '" = %s ' \
'WHERE id = %s', (id_new, src_id))
else:
cursor.execute('SELECT "' + field + '" ' \
'FROM "' + obj_src._table + '" ' \
'WHERE id = %s', (act[0],))
(obj_id,) = cursor.fetchone()
obj.write(cursor, user, [obj_id] , act[1], context=context)
one2one = One2One
class Many2One(Column):
_classic_read = False
_classic_write = True
+5 -6
View File
@@ -112,7 +112,7 @@ class BrowseRecord(object):
obj = self._table.pool.get(j._obj)
if not obj:
continue
if j._type in ('many2one', 'one2one'):
if j._type in ('many2one',):
if not j._classic_write and data[i]:
if isinstance(data[i][0], (list, tuple)):
ids2 = data[i][0][0]
@@ -1244,7 +1244,7 @@ class ORM(object):
if field in fields_names:
fld_def = (field in self._columns) and self._columns[field] \
or self._inherit_fields[field][2]
if fld_def._type in ('many2one', 'one2one'):
if fld_def._type in ('many2one',):
obj = self.pool.get(fld_def._obj)
if not obj.search(cursor, user, [('id', '=', field_value)]):
continue
@@ -1267,7 +1267,7 @@ class ORM(object):
field_value2.append({})
for field2 in field_value[i]:
if obj._columns[field2]._type \
in ('many2one', 'one2one'):
in ('many2one',):
obj2 = self.pool.get(obj._columns[field2]._obj)
if not obj2.search(cursor, user,
[('id', '=', field_value[i][field2])]):
@@ -1573,7 +1573,7 @@ class ORM(object):
for field in defaults.keys():
fld_def = (field in self._columns) and self._columns[field] \
or self._inherit_fields[field][2]
if fld_def._type in ('many2one', 'one2one'):
if fld_def._type in ('many2one',):
if isinstance(defaults[field], (list, tuple)):
vals[field] = defaults[field][0]
else:
@@ -1794,7 +1794,6 @@ class ORM(object):
'one2many',
'many2many',
'many2one',
'one2one',
):
res[field]['relation'] = self._columns[field]._obj
res[field]['domain'] = self._columns[field]._domain
@@ -2674,7 +2673,7 @@ class ORM(object):
data[field] = data[field] and data[field][0]
except:
pass
elif ftype in ('one2many', 'one2one'):
elif ftype in ('one2many',):
res = []
rel = self.pool.get(fields2[field]['relation'])
for rel_id in data[field]:
+1 -1
View File
@@ -174,7 +174,7 @@ class User(OSV):
else:
fields = self._preferences_fields + self._context_fields
for field in fields:
if self._columns[field]._type in ('many2one', 'one2one'):
if self._columns[field]._type in ('many2one',):
if field == 'language':
if user.language:
res['language'] = user.language.code
+1 -1
View File
@@ -465,7 +465,7 @@ class TrytondXmlHandler(sax.handler.ContentHandler):
if isinstance(ref_id, (list, tuple)):
ref_id = ref_id[0]
return ref_mode + ',' + str(ref_id)
elif field_type in ['one2one', 'one2many', "many2many"]:
elif field_type in ['one2many', 'many2many']:
raise Unhandled_field()
else:
return browse_record[key]