Skip to content

Commit

Permalink
[FIX] ir.values: remove redundant deduplication logic
Browse files Browse the repository at this point in the history
Handling update/create of existing values is already
handled by ir.values.set() itself.
  • Loading branch information
odony committed Feb 2, 2016
1 parent 72983ca commit 000c681
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions openerp/addons/base/ir/ir_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,29 +1009,8 @@ def _update(self,cr, uid, model, module, values, xml_id=False, store=True, noupd
return res_id

def ir_set(self, cr, uid, key, key2, name, models, value, replace=True, isobject=False, meta=None, xml_id=False):
if isinstance(models[0], (list, tuple)):
model,res_id = models[0]
else:
res_id=None
model = models[0]

if res_id:
where = ' and res_id=%s' % (res_id,)
else:
where = ' and (res_id is null)'

if key2:
where += ' and key2=\'%s\'' % (key2,)
else:
where += ' and (key2 is null)'

cr.execute('select * from ir_values where model=%s and key=%s and name=%s'+where,(model, key, name))
res = cr.fetchone()
if not res:
ir_values_obj = pooler.get_pool(cr.dbname).get('ir.values')
ir_values_obj.set(cr, uid, key, key2, name, models, value, replace, isobject, meta)
elif xml_id:
cr.execute('UPDATE ir_values set value=%s WHERE model=%s and key=%s and name=%s'+where,(value, model, key, name))
ir_values_obj = pooler.get_pool(cr.dbname)['ir.values']
ir_values_obj.set(cr, uid, key, key2, name, models, value, replace, isobject, meta)
return True

def _module_data_uninstall(self, cr, uid, modules_to_remove, context=None):
Expand Down

0 comments on commit 000c681

Please sign in to comment.