[FIX] account: Access error in multi companies

Steps to reproduce the bug:

- Let's consider two companies C1, C2 and a partner P in C2
- Let's consider an customner invoice I in C1 with P as customer
- Go to Accounting > Accounting > Partner Ledger and select I
- Click on Reconcie

Bug:

An access error was raised due to the ir.rule res.partner company

opw:2446242

closes odoo/odoo#69833

X-original-commit: 2279d84b4aefc8e488ccc33c30b816e988867589
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
This commit is contained in:
Goffin Simon
2021-04-26 10:42:22 +00:00
parent a0f2fbfce7
commit d14299bc7b
+2 -1
View File
@@ -2931,7 +2931,8 @@ class AccountMove(models.Model):
}
for line in preview_vals['items_vals']:
if 'partner_id' in line[2]:
line[2]['partner_id'] = self.env['res.partner'].browse(line[2]['partner_id']).display_name
# sudo is needed to compute display_name in a multi companies environment
line[2]['partner_id'] = self.env['res.partner'].browse(line[2]['partner_id']).sudo().display_name
line[2]['account_id'] = self.env['account.account'].browse(line[2]['account_id']).display_name or _('Destination Account')
line[2]['debit'] = currency_id and formatLang(self.env, line[2]['debit'], currency_obj=currency_id) or line[2]['debit']
line[2]['credit'] = currency_id and formatLang(self.env, line[2]['credit'], currency_obj=currency_id) or line[2]['debit']