[FIX] base: delete parent partner reset use_parent_address
When deleting a partner with some contacts, if the contacts had selected the "use parent address" checkbox, the address of the contacts was stucked in readonly mode (no checkbox to disable it). Disable use_parent_address for orphan partners. Fixes #3611 #3613
This commit is contained in:
parent
fc85a7ee5c
commit
de07c642b6
|
@ -508,6 +508,14 @@ class res_partner(osv.osv, format_address):
|
|||
if not parent.is_company:
|
||||
parent.write({'is_company': True})
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
orphan_contact_ids = self.search(cr, uid,
|
||||
[('parent_id', 'in', ids), ('id', 'not in', ids), ('use_parent_address', '=', True)], context=context)
|
||||
if orphan_contact_ids:
|
||||
# no longer have a parent address
|
||||
self.write(cr, uid, orphan_contact_ids, {'use_parent_address': False}, context=context)
|
||||
return super(res_partner, self).unlink(cr, uid, ids, context=context)
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
if isinstance(ids, (int, long)):
|
||||
ids = [ids]
|
||||
|
|
Loading…
Reference in New Issue