[FIX] base: value = 0 for record ir_property
When a record is created with a field property of type integer or float equal to 0, there is no record created in ir_property for this field. Then for a search of a record with this type of field equal to 0, it must match all the records that have no corresponding property in the table "ir.property" for this field. ps: in 7.0, the function search_multi doesn't exist and the bug linked to cost price doesn't happen because it's a float field. opw:639746
This commit is contained in:
parent
a6cba47cd7
commit
6e06318828
|
@ -260,6 +260,7 @@ class ir_property(osv.osv):
|
||||||
def search_multi(self, name, model, operator, value):
|
def search_multi(self, name, model, operator, value):
|
||||||
""" Return a domain for the records that match the given condition. """
|
""" Return a domain for the records that match the given condition. """
|
||||||
default_matches = False
|
default_matches = False
|
||||||
|
include_zero = False
|
||||||
|
|
||||||
field = self.env[model]._fields[name]
|
field = self.env[model]._fields[name]
|
||||||
if field.type == 'many2one':
|
if field.type == 'many2one':
|
||||||
|
@ -281,6 +282,27 @@ class ir_property(osv.osv):
|
||||||
target_names = target.name_search(value, operator=operator, limit=None)
|
target_names = target.name_search(value, operator=operator, limit=None)
|
||||||
target_ids = map(itemgetter(0), target_names)
|
target_ids = map(itemgetter(0), target_names)
|
||||||
operator, value = 'in', map(makeref, target_ids)
|
operator, value = 'in', map(makeref, target_ids)
|
||||||
|
elif field.type in ('integer', 'float'):
|
||||||
|
# No record is created in ir.property if the field's type is float or integer with a value
|
||||||
|
# equal to 0. Then to match with the records that are linked to a property field equal to 0,
|
||||||
|
# the negation of the operator must be taken to compute the goods and the domain returned
|
||||||
|
# to match the searched records is just the opposite.
|
||||||
|
if value == 0 and operator == '=':
|
||||||
|
operator = '!='
|
||||||
|
include_zero = True
|
||||||
|
elif value <= 0 and operator == '>=':
|
||||||
|
operator = '<'
|
||||||
|
include_zero = True
|
||||||
|
elif value <= 0 and operator == '>':
|
||||||
|
operator = '<='
|
||||||
|
include_zero = True
|
||||||
|
elif value >= 0 and operator == '<=':
|
||||||
|
operator = '>'
|
||||||
|
include_zero = True
|
||||||
|
elif value >= 0 and operator == '<':
|
||||||
|
operator = '>='
|
||||||
|
include_zero = True
|
||||||
|
|
||||||
|
|
||||||
# retrieve the properties that match the condition
|
# retrieve the properties that match the condition
|
||||||
domain = self._get_domain(name, model)
|
domain = self._get_domain(name, model)
|
||||||
|
@ -297,7 +319,9 @@ class ir_property(osv.osv):
|
||||||
else:
|
else:
|
||||||
default_matches = True
|
default_matches = True
|
||||||
|
|
||||||
if default_matches:
|
if include_zero:
|
||||||
|
return [('id', 'not in', good_ids)]
|
||||||
|
elif default_matches:
|
||||||
# exclude all records with a property that does not match
|
# exclude all records with a property that does not match
|
||||||
all_ids = []
|
all_ids = []
|
||||||
props = self.search(domain + [('res_id', '!=', False)])
|
props = self.search(domain + [('res_id', '!=', False)])
|
||||||
|
|
Loading…
Reference in New Issue