[MERGE] orm: delete a record properties when deleting the record.
bzr revid: vmt@openerp.com-20120110160933-cjmk63dtb27rb0qp
This commit is contained in:
+8
-2
@@ -3685,13 +3685,19 @@ class BaseModel(object):
|
||||
|
||||
self.check_unlink(cr, uid)
|
||||
|
||||
properties = self.pool.get('ir.property')
|
||||
ir_property = self.pool.get('ir.property')
|
||||
|
||||
# Check if the records are used as default properties.
|
||||
domain = [('res_id', '=', False),
|
||||
('value_reference', 'in', ['%s,%s' % (self._name, i) for i in ids]),
|
||||
]
|
||||
if properties.search(cr, uid, domain, context=context):
|
||||
if ir_property.search(cr, uid, domain, context=context):
|
||||
raise except_orm(_('Error'), _('Unable to delete this document because it is used as a default property'))
|
||||
|
||||
# Delete the records' properties.
|
||||
property_ids = ir_property.search(cr, uid, [('res_id', 'in', ['%s,%s' % (self._name, i) for i in ids])], context=context)
|
||||
ir_property.unlink(cr, uid, property_ids, context=context)
|
||||
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for oid in ids:
|
||||
wf_service.trg_delete(uid, self._name, oid, cr)
|
||||
|
||||
Reference in New Issue
Block a user