[MERGE] merged removal of deprecated fields (integer_big, one2one, time).
bzr revid: vmt@openerp.com-20120323150105-gkhsjca5y70yta2x
This commit is contained in:
commit
ce6d28f22f
|
@ -55,7 +55,7 @@ class ir_property(osv.osv):
|
|||
'fields_id': fields.many2one('ir.model.fields', 'Field', ondelete='cascade', required=True, select=1),
|
||||
|
||||
'value_float' : fields.float('Value'),
|
||||
'value_integer' : fields.integer_big('Value'), # will contain (int, bigint)
|
||||
'value_integer' : fields.integer('Value'),
|
||||
'value_text' : fields.text('Value'), # will contain (char, text)
|
||||
'value_binary' : fields.binary('Value'),
|
||||
'value_reference': fields.reference('Value', selection=_models_get2, size=128),
|
||||
|
@ -65,7 +65,6 @@ class ir_property(osv.osv):
|
|||
('float', 'Float'),
|
||||
('boolean', 'Boolean'),
|
||||
('integer', 'Integer'),
|
||||
('integer_big', 'Integer Big'),
|
||||
('text', 'Text'),
|
||||
('binary', 'Binary'),
|
||||
('many2one', 'Many2One'),
|
||||
|
@ -100,7 +99,6 @@ class ir_property(osv.osv):
|
|||
'float': 'value_float',
|
||||
'boolean' : 'value_integer',
|
||||
'integer': 'value_integer',
|
||||
'integer_big': 'value_integer',
|
||||
'text': 'value_text',
|
||||
'binary': 'value_binary',
|
||||
'many2one': 'value_reference',
|
||||
|
@ -142,7 +140,7 @@ class ir_property(osv.osv):
|
|||
return record.value_float
|
||||
elif record.type == 'boolean':
|
||||
return bool(record.value_integer)
|
||||
elif record.type in ('integer', 'integer_big'):
|
||||
elif record.type == 'integer':
|
||||
return record.value_integer
|
||||
elif record.type == 'binary':
|
||||
return record.value_binary
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<separator colspan="4" string="Field Information"/>
|
||||
<field colspan="4" name="fields_id" select="1"/>
|
||||
<field colspan="4" name="type"/>
|
||||
<group colspan="4" attrs="{'invisible' : [('type', 'not in', ('integer', 'integer_big', 'boolean'))]}">
|
||||
<group colspan="4" attrs="{'invisible' : [('type', 'not in', ('integer', 'boolean'))]}">
|
||||
<field colspan="4" name="value_integer" widget="integer"/>
|
||||
</group>
|
||||
<group colspan="4" attrs="{'invisible' : [('type', '!=', 'float')]}">
|
||||
|
|
|
@ -159,32 +159,6 @@ class integer(_column):
|
|||
" `required` has no effect, as NULL values are "
|
||||
"automatically turned into 0.")
|
||||
|
||||
class integer_big(_column):
|
||||
"""Experimental 64 bit integer column type, currently unused.
|
||||
|
||||
TODO: this field should work fine for values up
|
||||
to 32 bits, but greater values will not fit
|
||||
in the XML-RPC int type, so a specific
|
||||
get() method is needed to pass them as floats,
|
||||
like what we do for integer functional fields.
|
||||
"""
|
||||
_type = 'integer_big'
|
||||
# do not reference the _symbol_* of integer class, as that would possibly
|
||||
# unbind the lambda functions
|
||||
_symbol_c = '%s'
|
||||
_symbol_f = lambda x: int(x or 0)
|
||||
_symbol_set = (_symbol_c, _symbol_f)
|
||||
_symbol_get = lambda self,x: x or 0
|
||||
_deprecated = True
|
||||
|
||||
def __init__(self, string='unknown', required=False, **args):
|
||||
super(integer_big, self).__init__(string=string, required=required, **args)
|
||||
if required:
|
||||
_logger.debug(
|
||||
"required=True is deprecated: making an integer_big field"
|
||||
" `required` has no effect, as NULL values are "
|
||||
"automatically turned into 0.")
|
||||
|
||||
class reference(_column):
|
||||
_type = 'reference'
|
||||
_classic_read = False # post-process to handle missing target
|
||||
|
@ -347,20 +321,6 @@ class datetime(_column):
|
|||
exc_info=True)
|
||||
return timestamp
|
||||
|
||||
class time(_column):
|
||||
_type = 'time'
|
||||
_deprecated = True
|
||||
@staticmethod
|
||||
def now( *args):
|
||||
""" Returns the current time in a format fit for being a
|
||||
default value to a ``time`` field.
|
||||
|
||||
This method should be proivided as is to the _defaults dict,
|
||||
it should not be called.
|
||||
"""
|
||||
return DT.datetime.now().strftime(
|
||||
tools.DEFAULT_SERVER_TIME_FORMAT)
|
||||
|
||||
class binary(_column):
|
||||
_type = 'binary'
|
||||
_symbol_c = '%s'
|
||||
|
@ -426,34 +386,6 @@ class selection(_column):
|
|||
# (4, ID) link
|
||||
# (5) unlink all (only valid for one2many)
|
||||
#
|
||||
#CHECKME: dans la pratique c'est quoi la syntaxe utilisee pour le 5? (5) ou (5, 0)?
|
||||
class one2one(_column):
|
||||
_classic_read = False
|
||||
_classic_write = True
|
||||
_type = 'one2one'
|
||||
_deprecated = True
|
||||
|
||||
def __init__(self, obj, string='unknown', **args):
|
||||
_logger.warning("The one2one field is deprecated and doesn't work anymore.")
|
||||
_column.__init__(self, string=string, **args)
|
||||
self._obj = obj
|
||||
|
||||
def set(self, cr, obj_src, id, field, act, user=None, context=None):
|
||||
if not context:
|
||||
context = {}
|
||||
obj = obj_src.pool.get(self._obj)
|
||||
self._table = obj_src.pool.get(self._obj)._table
|
||||
if act[0] == 0:
|
||||
id_new = obj.create(cr, user, act[1])
|
||||
cr.execute('update '+obj_src._table+' set '+field+'=%s where id=%s', (id_new, id))
|
||||
else:
|
||||
cr.execute('select '+field+' from '+obj_src._table+' where id=%s', (act[0],))
|
||||
id = cr.fetchone()[0]
|
||||
obj.write(cr, user, [id], act[1], context=context)
|
||||
|
||||
def search(self, cr, obj, args, name, value, offset=0, limit=None, uid=None, context=None):
|
||||
return obj.pool.get(self._obj).search(cr, uid, args+self._domain+[('name', 'like', value)], offset, limit, context=context)
|
||||
|
||||
|
||||
class many2one(_column):
|
||||
_classic_read = False
|
||||
|
@ -1079,7 +1011,7 @@ class function(_column):
|
|||
self._symbol_f = boolean._symbol_f
|
||||
self._symbol_set = boolean._symbol_set
|
||||
|
||||
if type in ['integer','integer_big']:
|
||||
if type == 'integer':
|
||||
self._symbol_c = integer._symbol_c
|
||||
self._symbol_f = integer._symbol_f
|
||||
self._symbol_set = integer._symbol_set
|
||||
|
@ -1119,7 +1051,7 @@ class function(_column):
|
|||
elif not context.get('bin_raw'):
|
||||
result = sanitize_binary_value(value)
|
||||
|
||||
if field_type in ("integer","integer_big") and value > xmlrpclib.MAXINT:
|
||||
if field_type == "integer" and value > xmlrpclib.MAXINT:
|
||||
# integer/long values greater than 2^31-1 are not supported
|
||||
# in pure XMLRPC, so we have to pass them as floats :-(
|
||||
# This is not needed for stored fields and non-functional integer
|
||||
|
@ -1588,7 +1520,7 @@ def field_to_dict(model, cr, user, field, context=None):
|
|||
else:
|
||||
# call the 'dynamic selection' function
|
||||
res['selection'] = field.selection(model, cr, user, context)
|
||||
if res['type'] in ('one2many', 'many2many', 'many2one', 'one2one'):
|
||||
if res['type'] in ('one2many', 'many2many', 'many2one'):
|
||||
res['relation'] = field._obj
|
||||
res['domain'] = field._domain
|
||||
res['context'] = field._context
|
||||
|
|
|
@ -413,7 +413,7 @@ class browse_record(object):
|
|||
for result_line in field_values:
|
||||
new_data = {}
|
||||
for field_name, field_column in fields_to_fetch:
|
||||
if field_column._type in ('many2one', 'one2one'):
|
||||
if field_column._type == 'many2one':
|
||||
if result_line[field_name]:
|
||||
obj = self._table.pool.get(field_column._obj)
|
||||
if isinstance(result_line[field_name], (list, tuple)):
|
||||
|
@ -544,10 +544,8 @@ def pg_varchar(size=0):
|
|||
FIELDS_TO_PGTYPES = {
|
||||
fields.boolean: 'bool',
|
||||
fields.integer: 'int4',
|
||||
fields.integer_big: 'int8',
|
||||
fields.text: 'text',
|
||||
fields.date: 'date',
|
||||
fields.time: 'time',
|
||||
fields.datetime: 'timestamp',
|
||||
fields.binary: 'bytea',
|
||||
fields.many2one: 'int4',
|
||||
|
@ -1527,11 +1525,11 @@ class BaseModel(object):
|
|||
for id, field, field_value in res:
|
||||
if field in fields_list:
|
||||
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 == 'many2one':
|
||||
obj = self.pool.get(fld_def._obj)
|
||||
if not obj.search(cr, uid, [('id', '=', field_value or False)]):
|
||||
continue
|
||||
if fld_def._type in ('many2many'):
|
||||
if fld_def._type == 'many2many':
|
||||
obj = self.pool.get(fld_def._obj)
|
||||
field_value2 = []
|
||||
for i in range(len(field_value)):
|
||||
|
@ -1540,18 +1538,18 @@ class BaseModel(object):
|
|||
continue
|
||||
field_value2.append(field_value[i])
|
||||
field_value = field_value2
|
||||
if fld_def._type in ('one2many'):
|
||||
if fld_def._type == 'one2many':
|
||||
obj = self.pool.get(fld_def._obj)
|
||||
field_value2 = []
|
||||
for i in range(len(field_value)):
|
||||
field_value2.append({})
|
||||
for field2 in field_value[i]:
|
||||
if field2 in obj._columns.keys() and obj._columns[field2]._type in ('many2one', 'one2one'):
|
||||
if field2 in obj._columns.keys() and obj._columns[field2]._type == 'many2one':
|
||||
obj2 = self.pool.get(obj._columns[field2]._obj)
|
||||
if not obj2.search(cr, uid,
|
||||
[('id', '=', field_value[i][field2])]):
|
||||
continue
|
||||
elif field2 in obj._inherit_fields.keys() and obj._inherit_fields[field2][2]._type in ('many2one', 'one2one'):
|
||||
elif field2 in obj._inherit_fields.keys() and obj._inherit_fields[field2][2]._type == 'many2one':
|
||||
obj2 = self.pool.get(obj._inherit_fields[field2][2]._obj)
|
||||
if not obj2.search(cr, uid,
|
||||
[('id', '=', field_value[i][field2])]):
|
||||
|
@ -4354,7 +4352,7 @@ class BaseModel(object):
|
|||
for v in value:
|
||||
if v not in val:
|
||||
continue
|
||||
if self._columns[v]._type in ('many2one', 'one2one'):
|
||||
if self._columns[v]._type == 'many2one':
|
||||
try:
|
||||
value[v] = value[v][0]
|
||||
except:
|
||||
|
@ -4376,7 +4374,7 @@ class BaseModel(object):
|
|||
if f in field_dict[r]:
|
||||
result.pop(r)
|
||||
for id, value in result.items():
|
||||
if self._columns[f]._type in ('many2one', 'one2one'):
|
||||
if self._columns[f]._type == 'many2one':
|
||||
try:
|
||||
value = value[0]
|
||||
except:
|
||||
|
@ -4653,7 +4651,7 @@ class BaseModel(object):
|
|||
data[f] = data[f] and data[f][0]
|
||||
except:
|
||||
pass
|
||||
elif ftype in ('one2many', 'one2one'):
|
||||
elif ftype == 'one2many':
|
||||
res = []
|
||||
rel = self.pool.get(fields[f]['relation'])
|
||||
if data[f]:
|
||||
|
@ -4704,7 +4702,7 @@ class BaseModel(object):
|
|||
translation_records = []
|
||||
for field_name, field_def in fields.items():
|
||||
# we must recursively copy the translations for o2o and o2m
|
||||
if field_def['type'] in ('one2one', 'one2many'):
|
||||
if field_def['type'] == 'one2many':
|
||||
target_obj = self.pool.get(field_def['relation'])
|
||||
old_record, new_record = self.read(cr, uid, [old_id, new_id], [field_name], context=context)
|
||||
# here we rely on the order of the ids to match the translations
|
||||
|
|
Loading…
Reference in New Issue