[FIX] account, sale: avoid error when internal user (no accounting

permissions) edit information at /my/account

Issue:
Internal user cannot edit their information (email, street,...) at
portal without permissions in the accounting

Analyze:
Because the method `can_edit_vat` has a search from the account.move
model, it causes an error

Fix:
Use sudo to avoid error when searching

closes odoo/odoo#138291

X-original-commit: eb9505375483d18cf21fbaf8e5a60398d5c041c5
Signed-off-by: Laurent Smet (las) <las@odoo.com>
This commit is contained in:
Roy Le
2023-10-13 11:46:18 +00:00
committed by Laurent Smet
parent 631ae1c4d8
commit bb323e3989
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -658,7 +658,7 @@ class ResPartner(models.Model):
def _has_invoice(self):
self.ensure_one()
invoice = self.env['account.move'].search([
invoice = self.env['account.move'].sudo().search([
('move_type', 'in', ['out_invoice', 'out_refund']),
('partner_id', 'child_of', self.commercial_partner_id.id),
('state', '=', 'posted')
+1 -1
View File
@@ -38,7 +38,7 @@ class ResPartner(models.Model):
def _has_order(self):
self.ensure_one()
sale_order = self.env['sale.order'].search([
sale_order = self.env['sale.order'].sudo().search([
('partner_id', 'child_of', self.commercial_partner_id.id),
('state', 'in', ['sent', 'sale'])
], limit=1)