2175
2175
if fget[groupby]['type'] in ('date', 'datetime'):
2176
2176
flist = "to_char(%s,'yyyy-mm') as %s " % (qualified_groupby_field, groupby)
2177
2177
groupby = "to_char(%s,'yyyy-mm')" % (qualified_groupby_field)
2178
qualified_groupby_field = groupby
2179
2180
flist = qualified_groupby_field
2821
2822
'string': field['field_description'],
2822
2823
'required': bool(field['required']),
2823
2824
'readonly': bool(field['readonly']),
2824
'domain': field['domain'] or None,
2825
'domain': eval(field['domain']) if field['domain'] else None,
2825
2826
'size': field['size'],
2826
2827
'ondelete': field['on_delete'],
2827
2828
'translate': (field['translate']),
3078
3079
for group in groups:
3079
3080
module = group.split(".")[0]
3080
3081
grp = group.split(".")[1]
3081
cr.execute("select count(*) from res_groups_users_rel where gid IN (select res_id from ir_model_data where name=%s and module=%s and model=%s) and uid=%s" \
3082
cr.execute("select count(*) from res_groups_users_rel where gid IN (select res_id from ir_model_data where name=%s and module=%s and model=%s) and uid=%s", \
3082
3083
(grp, module, 'res.groups', user))
3083
3084
readonly = cr.fetchall()
3084
3085
if readonly[0][0] >= 1:
3229
3230
self.check_access_rule(cr, uid, ids, 'unlink', context=context)
3231
pool_model_data = self.pool.get('ir.model.data')
3232
pool_ir_values = self.pool.get('ir.values')
3230
3233
for sub_ids in cr.split_for_in_conditions(ids):
3231
3234
cr.execute('delete from ' + self._table + ' ' \
3232
3235
'where id IN %s', (sub_ids,))
3237
# Removing the ir_model_data reference if the record being deleted is a record created by xml/csv file,
3238
# as these are not connected with real database foreign keys, and would be dangling references.
3239
# Step 1. Calling unlink of ir_model_data only for the affected IDS.
3240
referenced_ids = pool_model_data.search(cr, uid, [('res_id','in',list(sub_ids)),('model','=',self._name)], context=context)
3241
# Step 2. Marching towards the real deletion of referenced records
3242
pool_model_data.unlink(cr, uid, referenced_ids, context=context)
3244
# For the same reason, removing the record relevant to ir_values
3245
ir_value_ids = pool_ir_values.search(cr, uid,
3246
['|',('value','in',['%s,%s' % (self._name, sid) for sid in sub_ids]),'&',('res_id','in',list(sub_ids)),('model','=',self._name)],
3249
pool_ir_values.unlink(cr, uid, ir_value_ids, context=context)
3233
3251
for order, object, store_ids, fields in result_store:
3234
3252
if object != self._name:
3235
3253
obj = self.pool.get(object)