Skip to content
Snippets Groups Projects
Commit 99052611 authored by Martin Trigaux's avatar Martin Trigaux
Browse files

[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
parent 74e52a9c
No related branches found
No related tags found
No related merge requests found
......@@ -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):
......
......@@ -103,6 +103,21 @@
context="{'partner_id': active_id}">
<field string="Meetings" name="meeting_count" widget="statinfo"/>
</button>
</xpath>
</data>
</field>
</record>
<!-- second view due to access rights required to compute phonecall_count -->
<record id="view_partners_form_crm_calls" model="ir.ui.view">
<field name="name">view.res.partner.form.crm.inherited.calls</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="groups_id" eval="[(4, ref('base.group_sale_manager')), (4, ref('base.group_partner_manager'))]"/>
<field eval="18" name="priority"/>
<field name="arch" type="xml">
<data>
<xpath expr="//div[@name='buttons']" position="inside">
<button class="oe_inline oe_stat_button" type="action"
name="%(crm.crm_case_categ_phone_incoming0)d"
icon="fa-phone"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment