[FIX] base: handle correctly "False" values in properties
bzr revid: chs@openerp.com-20100610162017-96jdxc8bdf7993ya
This commit is contained in:
parent
96570d318e
commit
c646a365ca
|
@ -60,7 +60,6 @@ class ir_property(osv.osv):
|
|||
'value_binary' : fields.binary('Value'),
|
||||
'value_reference': fields.reference('Value', selection=_models_get2, size=128),
|
||||
'value_datetime' : fields.datetime('Value'),
|
||||
'value_boolean': fields.boolean('Value'),
|
||||
|
||||
'type' : fields.selection([('char', 'Char'),
|
||||
('float', 'Float'),
|
||||
|
@ -86,7 +85,15 @@ class ir_property(osv.osv):
|
|||
value = values.pop('value', None)
|
||||
if not value:
|
||||
return values
|
||||
type_ = values.get('type', 'many2one')
|
||||
|
||||
prop = None
|
||||
type_ = values.get('type')
|
||||
if not type_:
|
||||
if not ids:
|
||||
raise ValueError()
|
||||
prop = self.browse(cr, uid, ids[0])
|
||||
type_ = prop.type
|
||||
|
||||
type2field = {
|
||||
'char': 'value_text',
|
||||
'float': 'value_float',
|
||||
|
@ -109,9 +116,9 @@ class ir_property(osv.osv):
|
|||
elif isinstance(value, (int, long)):
|
||||
field_id = values.get('fields_id')
|
||||
if not field_id:
|
||||
if not ids:
|
||||
if not prop:
|
||||
raise ValueError()
|
||||
field_id = self.browse(cr, uid, ids[0]).fields_id
|
||||
field_id = prop.fields_id
|
||||
else:
|
||||
field_id = self.pool.get('ir.model.fields').browse(cr, uid, field_id)
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<field name="company_id" select="1" groups="base.group_multi_company"/>
|
||||
<field colspan="4" name="fields_id" select="1"/>
|
||||
<field colspan="4" name="type"/>
|
||||
<group colspan="4" attrs="{'invisible' : [('type', 'not in', ('integer', 'integer_big'))]}">
|
||||
<group colspan="4" attrs="{'invisible' : [('type', 'not in', ('integer', 'integer_big', 'boolean'))]}">
|
||||
<field colspan="4" name="value_integer" widget="integer"/>
|
||||
</group>
|
||||
<group colspan="4" attrs="{'invisible' : [('type', '!=', 'float')]}">
|
||||
|
|
|
@ -874,12 +874,17 @@ class serialized(_column):
|
|||
class property(function):
|
||||
|
||||
def _get_default(self, obj, cr, uid, prop_name, context=None):
|
||||
from orm import browse_record
|
||||
prop = obj.pool.get('ir.property')
|
||||
domain = prop._get_domain_default(cr, uid, prop_name, obj._name, context)
|
||||
ids = prop.search(cr, uid, domain, order='company_id', context=context)
|
||||
if not ids:
|
||||
return False
|
||||
return prop.get_by_id(cr, uid, ids, context=context)
|
||||
|
||||
default_value = prop.get_by_id(cr, uid, ids, context=context)
|
||||
if isinstance(default_value, browse_record):
|
||||
return default_value.id
|
||||
return default_value
|
||||
|
||||
def _get_by_id(self, obj, cr, uid, prop_name, ids, context=None):
|
||||
prop = obj.pool.get('ir.property')
|
||||
|
@ -903,7 +908,7 @@ class property(function):
|
|||
|
||||
default_val = self._get_default(obj, cr, uid, prop_name, context)
|
||||
|
||||
if id_val and id_val != default_val:
|
||||
if id_val is not default_val:
|
||||
def_id = self._field_get(cr, uid, obj._name, prop_name)
|
||||
company = obj.pool.get('res.company')
|
||||
cid = company._company_default_get(cr, uid, obj._name, def_id,
|
||||
|
@ -924,23 +929,16 @@ class property(function):
|
|||
|
||||
def _fnct_read(self, obj, cr, uid, ids, prop_name, obj_dest, context=None):
|
||||
from orm import browse_record
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
property = obj.pool.get('ir.property')
|
||||
properties = obj.pool.get('ir.property')
|
||||
|
||||
default_val = self._get_default(obj, cr, uid, prop_name, context)
|
||||
if isinstance(default_val, browse_record):
|
||||
default_val = default_val.id
|
||||
else:
|
||||
default_val = False
|
||||
|
||||
nids = self._get_by_id(obj, cr, uid, prop_name, ids, context)
|
||||
|
||||
res = {}
|
||||
for id in ids:
|
||||
res[id] = default_val
|
||||
for prop in property.browse(cr, uid, nids):
|
||||
for prop in properties.browse(cr, uid, nids):
|
||||
value = prop.get_by_id(context=context)
|
||||
if isinstance(value, browse_record):
|
||||
if not value.exists():
|
||||
|
|
Loading…
Reference in New Issue