From d820c71fb761230bcc6aacbf7e3c39b6f70cce75 Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Thu, 1 Nov 2012 14:09:08 +0530 Subject: [PATCH 1/2] [FIX] crm : IntegrityError: duplicate key value violates unique constraint. bzr revid: mdi@tinyerp.com-20121101083908-xangf2ibmzctnvpl --- addons/crm/crm_segmentation.py | 9 ++++++--- addons/crm_profiling/crm_profiling.py | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/addons/crm/crm_segmentation.py b/addons/crm/crm_segmentation.py index 9cafe950410..b87d6a3b653 100644 --- a/addons/crm/crm_segmentation.py +++ b/addons/crm/crm_segmentation.py @@ -56,6 +56,7 @@ added to partners that match the segmentation criterions after computation.'), @param uid: the current user’s ID for security checks, @param ids: List of Process continue’s IDs""" + partner_obj = self.pool.get('res.partner') categs = self.read(cr, uid, ids, ['categ_id', 'exclusif', 'partner_id',\ 'sales_purchase_active', 'profiling_active']) for categ in categs: @@ -80,9 +81,11 @@ added to partners that match the segmentation criterions after computation.'), for pid in to_remove_list: partners.remove(pid) - for partner_id in partners: - cr.execute('insert into res_partner_res_partner_category_rel (category_id,partner_id) \ - values (%s,%s)', (categ['categ_id'][0], partner_id)) + for partner in partner_obj.browse(cr, uid, partners): + category_ids = [categ_id.id for categ_id in partner.category_id] + if categ['categ_id'][0] not in category_ids: + cr.execute('insert into res_partner_res_partner_category_rel (category_id,partner_id) \ + values (%s,%s)', (categ['categ_id'][0], partner.id)) self.write(cr, uid, [id], {'state':'not running', 'partner_id':0}) return True diff --git a/addons/crm_profiling/crm_profiling.py b/addons/crm_profiling/crm_profiling.py index 8f07dfcbdda..7dc72f80289 100644 --- a/addons/crm_profiling/crm_profiling.py +++ b/addons/crm_profiling/crm_profiling.py @@ -244,6 +244,7 @@ class crm_segmentation(osv.osv): @param uid: the current user’s ID for security checks, @param ids: List of crm segmentation’s IDs """ + partner_obj = self.pool.get('res.partner') categs = self.read(cr,uid,ids,['categ_id','exclusif','partner_id', \ 'sales_purchase_active', 'profiling_active']) for categ in categs: @@ -280,8 +281,10 @@ class crm_segmentation(osv.osv): for pid in to_remove_list: partners.remove(pid) - for partner_id in partners: - cr.execute('insert into res_partner_res_partner_category_rel (category_id,partner_id) values (%s,%s)', (categ['categ_id'][0],partner_id)) + for partner in partner_obj.browse(cr, uid, partners): + category_ids = [categ_id.id for categ_id in partner.category_id] + if categ['categ_id'][0] not in category_ids: + cr.execute('insert into res_partner_res_partner_category_rel (category_id,partner_id) values (%s,%s)', (categ['categ_id'][0],partner.id)) self.write(cr, uid, [id], {'state':'not running', 'partner_id':0}) return True From 90c7cfcf31c34e53b2d4840c626f5e7c5514d354 Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Thu, 1 Nov 2012 15:44:46 +0530 Subject: [PATCH 2/2] [FIX] event : Subscribe should open registrations filtered by the partner. bzr revid: mdi@tinyerp.com-20121101101446-23und8l0yi6k3n4w --- addons/event/event_view.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/event/event_view.xml b/addons/event/event_view.xml index 3face47de52..404d7c44de3 100644 --- a/addons/event/event_view.xml +++ b/addons/event/event_view.xml @@ -524,7 +524,7 @@ event.registration - + @@ -533,6 +533,7 @@ +