From 972d966554e57274edb5a3f63df984b8880789a9 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 9 Apr 2015 17:19:09 +0200 Subject: [PATCH] [FIX] account: ACLs contracts button in partner form contracts_count function field & journal_item_count function field used for the "contracts" and "journal items" buttons in the partner view are computed by the same method. But, this is possible that you have access to one without having access to the other. e.g., Project users not being salesman nor accountant must have access to the contract counts, but not to the journal items. Besides, these buttons are added to the partner form by two separated views, applied to analytic accounting group & accountant group, respectively. We therefore avoid to compute the journal items count when not needed, when not loaded in the partner view. We therefore prevent the access right issue, and provide a performance improvment at the same time. Yay. opw-632454 --- addons/account/partner.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/addons/account/partner.py b/addons/account/partner.py index 3df24382164..deff94d59e1 100644 --- a/addons/account/partner.py +++ b/addons/account/partner.py @@ -251,13 +251,14 @@ class res_partner(osv.osv): def _journal_item_count(self, cr, uid, ids, field_name, arg, context=None): MoveLine = self.pool('account.move.line') AnalyticAccount = self.pool('account.analytic.account') - return { - partner_id: { - 'journal_item_count': MoveLine.search_count(cr, uid, [('partner_id', '=', partner_id)], context=context), - 'contracts_count': AnalyticAccount.search_count(cr,uid, [('partner_id', '=', partner_id)], context=context) - } - for partner_id in ids - } + results = {} + for partner_id in ids: + results[partner_id] = {} + if 'contracts_count' in field_name: + results[partner_id]['contracts_count'] = AnalyticAccount.search_count(cr, uid, [('partner_id', '=', partner_id)], context=context) + if 'journal_item_count' in field_name: + results[partner_id]['journal_item_count'] = MoveLine.search_count(cr, uid, [('partner_id', '=', partner_id)], context=context) + return results def has_something_to_reconcile(self, cr, uid, partner_id, context=None): '''