Merge PR #3060 into 17.0

Signed-off-by pedrobaeza
pull/3062/head
OCA-git-bot 2024-10-09 08:36:03 +00:00
commit 5b1e6aa654
2 changed files with 15 additions and 1 deletions

View File

@ -6,6 +6,7 @@
from collections import defaultdict
from odoo import api, models, tools
from odoo.exceptions import AccessError
from ..tools import format_m2m
@ -120,7 +121,11 @@ class Base(models.AbstractModel):
values = initial_values.setdefault(record.id, {})
if values is not None:
for fname in fnames:
try:
values.setdefault(fname, record[fname])
except AccessError:
# User does not have access to the field (example with groups)
continue
def _tm_finalize_o2m_tracking(self):
initial_values = self.env.cr.precommit.data.pop(

View File

@ -1,4 +1,5 @@
# Copyright 2022 Akretion (https://www.akretion.com).
# Copyright 2024 Tecnativa - Víctor Martínez
# @author Kévin Roche <kevin.roche@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import Command
@ -270,3 +271,11 @@ class TestTrackingManager(TransactionCase):
self.assertEqual(len(self.messages), 1)
self.assertEqual(self.messages.body.count("Change"), 0)
self.assertEqual(self.messages.body.count("Delete"), 1)
def test_o2m_update_record(self):
self.env.ref("base.field_res_partner__child_ids").custom_tracking = True
child = self.env["res.partner"].create(
{"name": "Test child", "parent_id": self.partner.id}
)
child.write({"parent_id": False})
self.assertEqual(len(self.messages), 1)