[FIX] base: fix write deny while creating new contact

How to reproduce
================

1. Create a user with lower privileges then admin
2. Add a new company and a new contact of that company in the contact
   app at the sametime
3. Manually save

This will result in a write access denied

opw-3127591

closes odoo/odoo#112595

X-original-commit: 93a37df79fc30c2f9ac31d60dc897452851fd5bd
Signed-off-by: John Laterre (jol) <jol@odoo.com>
This commit is contained in:
Jordan D. (Joda)
2023-02-14 10:02:30 +01:00
parent c7360ebcab
commit b12e8fd338
+2 -2
View File
@@ -600,10 +600,10 @@ class Partner(models.Model):
if self.commercial_partner_id == self:
commercial_fields = self._commercial_fields()
if any(field in values for field in commercial_fields):
self._commercial_sync_to_children()
self.sudo()._commercial_sync_to_children()
for child in self.child_ids.filtered(lambda c: not c.is_company):
if child.commercial_partner_id != self.commercial_partner_id:
self._commercial_sync_to_children()
self.sudo()._commercial_sync_to_children()
break
# 2b. Address fields: sync if address changed
address_fields = self._address_fields()