[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
This commit is contained in:
Denis Ledoux 2015-04-09 17:19:09 +02:00
parent 6f35b0b3fa
commit 972d966554
1 changed files with 8 additions and 7 deletions

View File

@ -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):
'''