[FIX] ir_attachment: attachements removed on record unlink
This commit is contained in:
parent
8dff247096
commit
2459cd5dd1
|
@ -4050,6 +4050,7 @@ class BaseModel(object):
|
|||
self.check_access_rights(cr, uid, 'unlink')
|
||||
|
||||
ir_property = self.pool.get('ir.property')
|
||||
ir_attachment_obj = self.pool.get('ir.attachment')
|
||||
|
||||
# Check if the records are used as default properties.
|
||||
domain = [('res_id', '=', False),
|
||||
|
@ -4088,6 +4089,13 @@ class BaseModel(object):
|
|||
if ir_value_ids:
|
||||
ir_values_obj.unlink(cr, uid, ir_value_ids, context=context)
|
||||
|
||||
# For the same reason, removing the record relevant to ir_attachment
|
||||
# The search is performed with sql as the search method of ir_attachment is overridden to hide attachments of deleted records
|
||||
cr.execute('select id from ir_attachment where res_model = %s and res_id in %s', (self._name, sub_ids))
|
||||
ir_attachment_ids = [ir_attachment[0] for ir_attachment in cr.fetchall()]
|
||||
if ir_attachment_ids:
|
||||
ir_attachment_obj.unlink(cr, uid, ir_attachment_ids, context=context)
|
||||
|
||||
for order, object, store_ids, fields in result_store:
|
||||
if object == self._name:
|
||||
effective_store_ids = list(set(store_ids) - set(ids))
|
||||
|
|
Loading…
Reference in New Issue