From 99052611084eced10aec3fcdb9404a96e41e71ea Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 22 Jul 2015 14:52:39 +0100 Subject: [PATCH] [FIX] crm: permissions on computed field Accessing the phonecall and the lead do not require the same permissions so should not be computed in the same method. The effect of the multi was already lost as the phonecall_count was already computed in another loop. Add the phonecall_count button in a second view to make the computation only if the user has the requried access rights. Fixes #2458 --- addons/crm/res_partner.py | 8 ++++++-- addons/crm/res_partner_view.xml | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/addons/crm/res_partner.py b/addons/crm/res_partner.py index 25020fe16b9..c920379a3f7 100644 --- a/addons/crm/res_partner.py +++ b/addons/crm/res_partner.py @@ -41,8 +41,12 @@ class res_partner(osv.osv): } except: pass + return res + + def _phonecall_count(self, cr, uid, ids, field_name, arg, context=None): + res = {} for partner in self.browse(cr, uid, ids, context): - res[partner.id]['phonecall_count'] = len(partner.phonecall_ids) + res[partner.id] = len(partner.phonecall_ids) return res _columns = { @@ -55,7 +59,7 @@ class res_partner(osv.osv): 'Phonecalls'), 'opportunity_count': fields.function(_opportunity_meeting_phonecall_count, string="Opportunity", type='integer', multi='opp_meet'), 'meeting_count': fields.function(_opportunity_meeting_phonecall_count, string="# Meetings", type='integer', multi='opp_meet'), - 'phonecall_count': fields.function(_opportunity_meeting_phonecall_count, string="Phonecalls", type="integer", multi='opp_meet'), + 'phonecall_count': fields.function(_phonecall_count, string="Phonecalls", type="integer"), } def redirect_partner_form(self, cr, uid, partner_id, context=None): diff --git a/addons/crm/res_partner_view.xml b/addons/crm/res_partner_view.xml index 3b6c4dcaa87..006eb4602ad 100644 --- a/addons/crm/res_partner_view.xml +++ b/addons/crm/res_partner_view.xml @@ -103,6 +103,21 @@ context="{'partner_id': active_id}"> + + + + + + + + view.res.partner.form.crm.inherited.calls + res.partner + + + + + +