From 89581abf145fa593439aacb67f5fa77c334fe619 Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert Date: Tue, 21 Mar 2017 09:45:03 +0100 Subject: [PATCH] [FIX] account: field commercial_partner_id should be compute_related=True OPW: 716163 This is needed to fix the following problem: adding a partner to res_partner.child_ids will mark all element of child_ids as 'todo' and trigger a write on res_parner.commercial_partner_id for all element of the child_ids and then on the related field account_invoice.commercial_partner_id. This can cause problem if partner in child_ids belong to different company and have invoices. This will throw a read access error when doing the _write method of account_invoice. Adding the compute_related=True to account_invoice.commercial_partner_id ensure that the _write on that field is done in sudo. --- addons/account/models/account_invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 044e5b8d85b..fdc5bf4c031 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -313,7 +313,7 @@ class AccountInvoice(models.Model): default=lambda self: self.env.user) fiscal_position_id = fields.Many2one('account.fiscal.position', string='Fiscal Position', oldname='fiscal_position', readonly=True, states={'draft': [('readonly', False)]}) - commercial_partner_id = fields.Many2one('res.partner', string='Commercial Entity', + commercial_partner_id = fields.Many2one('res.partner', string='Commercial Entity', compute_sudo=True, related='partner_id.commercial_partner_id', store=True, readonly=True, help="The commercial entity that will be used on Journal Entries for this invoice")