[FIX] crm: merge partner

It is not allowed to merge a partner with one of his parent.

opw:673104
This commit is contained in:
Goffin Simon 2016-03-30 14:16:00 +02:00
parent 6e07ae5a5c
commit bbb317c547
2 changed files with 12 additions and 0 deletions

View File

@ -300,6 +300,12 @@ class MergePartnerAutomatic(osv.TransientModel):
if len(partner_ids) > 3:
raise osv.except_osv(_('Error'), _("For safety reasons, you cannot merge more than 3 contacts together. You can re-open the wizard several times if needed."))
child_ids = set()
for partner_id in partner_ids:
child_ids = child_ids.union(set(proxy.search(cr, uid, [('id', 'child_of', [partner_id])])) - set([partner_id]))
if set(partner_ids).intersection(child_ids):
raise osv.except_osv(_('Error'), _("You cannot merge a contact with one of his parent."))
if openerp.SUPERUSER_ID != uid and len(set(partner.email for partner in proxy.browse(cr, uid, partner_ids, context=context))) > 1:
raise osv.except_osv(_('Error'), _("All contacts must have the same email. Only the Administrator can merge contacts with different emails."))

View File

@ -3056,6 +3056,12 @@ msgid "You are already at the top level of your sales-team category.\n"
"Therefore you cannot escalate furthermore."
msgstr ""
#. module: crm
#: code:addons/crm/base_partner_merge.py:310
#, python-format
msgid "You cannot merge a contact with one of his parent."
msgstr ""
#. module: crm
#: code:addons/crm/base_partner_merge.py:446
#, python-format