[FIX] account: Access error when opening a partner
If a user can read account.analytic.account but not the account.move.line, when he tried to open a partner, there were an raise AccessDenied errors. opw:782961
This commit is contained in:
committed by
Goffin Simon
parent
8b854ab660
commit
f7e80442d1
@@ -298,10 +298,16 @@ class ResPartner(models.Model):
|
||||
partner.total_invoiced = sum(price['total'] for price in price_totals if price['partner_id'] in child_ids)
|
||||
|
||||
@api.multi
|
||||
def _journal_item_count(self):
|
||||
def _compute_journal_item_count(self):
|
||||
AccountMoveLine = self.env['account.move.line']
|
||||
for partner in self:
|
||||
partner.journal_item_count = self.env['account.move.line'].search_count([('partner_id', '=', partner.id)])
|
||||
partner.contracts_count = self.env['account.analytic.account'].search_count([('partner_id', '=', partner.id)])
|
||||
partner.journal_item_count = AccountMoveLine.search_count([('partner_id', '=', partner.id)])
|
||||
|
||||
@api.multi
|
||||
def _compute_contracts_count(self):
|
||||
AccountAnalyticAccount = self.env['account.analytic.account']
|
||||
for partner in self:
|
||||
partner.contracts_count = AccountAnalyticAccount.search_count([('partner_id', '=', partner.id)])
|
||||
|
||||
def get_followup_lines_domain(self, date, overdue_only=False, only_unblocked=False):
|
||||
domain = [('reconciled', '=', False), ('account_id.deprecated', '=', False), ('account_id.internal_type', '=', 'receivable'), '|', ('debit', '!=', 0), ('credit', '!=', 0), ('company_id', '=', self.env.user.company_id.id)]
|
||||
@@ -383,9 +389,8 @@ class ResPartner(models.Model):
|
||||
groups='account.group_account_invoice')
|
||||
currency_id = fields.Many2one('res.currency', compute='_get_company_currency', readonly=True,
|
||||
string="Currency", help='Utility field to express amount currency')
|
||||
|
||||
contracts_count = fields.Integer(compute='_journal_item_count', string="Contracts", type='integer')
|
||||
journal_item_count = fields.Integer(compute='_journal_item_count', string="Journal Items", type="integer")
|
||||
contracts_count = fields.Integer(compute='_compute_contracts_count', string="Contracts", type='integer')
|
||||
journal_item_count = fields.Integer(compute='_compute_journal_item_count', string="Journal Items", type="integer")
|
||||
issued_total = fields.Monetary(compute='_compute_issued_total', string="Journal Items")
|
||||
property_account_payable_id = fields.Many2one('account.account', company_dependent=True,
|
||||
string="Account Payable", oldname="property_account_payable",
|
||||
|
||||
Reference in New Issue
Block a user