From ff4ca4fa9030bda07f81d6a09b820ac1ff8bb98b Mon Sep 17 00:00:00 2001 From: David Beguin Date: Thu, 16 Sep 2021 09:25:08 +0000 Subject: [PATCH] [IMP] sale: apply salesman group on utm campagins counter and apply compute sudo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The goal is that the counter on the smart button can display the conmplete information ("this campaing generated 500k€, no matter if you can acces or not the records behind this number"). Once the user clicks on the smart button, them can only see the records he has access to. Task-2516278 COM PR: odoo/odoo#76934 ENT PR: odoo/enterprise#21055 Signed-off-by: Thibault Delavallee (tde) --- addons/sale/models/utm_campaign.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/sale/models/utm_campaign.py b/addons/sale/models/utm_campaign.py index 902856e8788..720b4024a57 100644 --- a/addons/sale/models/utm_campaign.py +++ b/addons/sale/models/utm_campaign.py @@ -7,8 +7,10 @@ class UtmCampaign(models.Model): _inherit = 'utm.campaign' _description = 'UTM Campaign' - quotation_count = fields.Integer('Quotation Count', groups='sales_team.group_sale_salesman', compute="_compute_quotation_count") - invoiced_amount = fields.Integer(default=0, compute="_compute_sale_invoiced_amount", string="Revenues generated by the campaign") + quotation_count = fields.Integer('Quotation Count', + compute="_compute_quotation_count", compute_sudo=True, groups='sales_team.group_sale_salesman') + invoiced_amount = fields.Integer(string="Revenues generated by the campaign", + compute="_compute_sale_invoiced_amount", compute_sudo=True, groups='sales_team.group_sale_salesman') company_id = fields.Many2one('res.company', string='Company', readonly=True, states={'draft': [('readonly', False)], 'refused': [('readonly', False)]}, default=lambda self: self.env.company) currency_id = fields.Many2one('res.currency', related='company_id.currency_id', string='Currency')