diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index a4049242c22..55e25e4001c 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -34,8 +34,6 @@ class one2many_mod2(fields.one2many): if values is None: values = {} - res = {}.fromkeys(ids, []) - # dict: # {idn: (date_current, user_id), ... # 1: ('2010-08-15', 1)} @@ -59,9 +57,13 @@ class one2many_mod2(fields.one2many): ids2 = obj.pool.get(self._obj).search(cr, user, dom, limit=self._limit) + res = {} + for i in ids: + res[i] = [] + for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'): if r[self._fields_id]: - res.setdefault(r[self._fields_id][0], []).append(r['id']) + res[r[self._fields_id][0]].append(r['id']) return res @@ -82,7 +84,6 @@ class one2many_mod(fields.one2many): if values is None: values = {} - res = {}.fromkeys(ids, []) res5 = obj.read(cr, user, ids, ['date_current', 'user_id'], context=context) res6 = {} @@ -96,11 +97,13 @@ class one2many_mod(fields.one2many): dom = [('date', '=', res6[id][0]), ('user_id', '=', res6[id][1])] ids2.extend(obj.pool.get(self._obj).search(cr, user, dom, limit=self._limit)) - + res = {} + for i in ids: + res[i] = [] for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'): if r[self._fields_id]: - res.setdefault(r[self._fields_id][0], []).append(r['id']) + res[r[self._fields_id][0]].append(r['id']) return res diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 87dfe8dd670..33828840eeb 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -357,7 +357,9 @@ class many2many_domain(fields.many2many): context = {} move_obj = obj.pool.get('stock.move') - res = {}.fromkeys(ids, []) + res = {} + for i in ids: + res[i] = [] valid_move_ids = move_obj.search(cr, user, self._domain) # move ids relative to domain argument cr.execute("SELECT production_id, move_id from mrp_production_move_ids where production_id in %s and move_id in %s", [tuple(ids), tuple(valid_move_ids)]) @@ -377,7 +379,9 @@ class one2many_domain(fields.one2many): context = {} move_obj = obj.pool.get('stock.move') - res = {}.fromkeys(ids, []) + res = {} + for i in ids: + res[i] = [] move_ids = move_obj.search(cr, user, self._domain+[('production_id', 'in', tuple(ids))], context=context) related_move_dict = dict([(o.production_id.id, [o.id]) for o in move_obj.browse(cr, user, move_ids, context=context)]) res.update(related_move_dict)