[FIX] models: update write_date when writing on inherited fields
When changing the field `image` on `res.users`, the `write_date` of the user is not updated because the field is inherited from `res.partner`. Related to Issue : 1839603
This commit is contained in:
@@ -315,6 +315,17 @@ class TestInherits(TransactionCase):
|
||||
self.assertEqual(user_bar.name, 'Bar', "name is given from specific partner")
|
||||
self.assertEqual(user_bar.signature, user_foo.signature, "signature should be copied")
|
||||
|
||||
@mute_logger('odoo.models')
|
||||
def test_write_date(self):
|
||||
""" modifying inherited fields must update write_date """
|
||||
user = self.env.user
|
||||
write_date_before = user.write_date
|
||||
|
||||
# write base64 image
|
||||
user.write({'image': 'R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='})
|
||||
write_date_after = user.write_date
|
||||
self.assertNotEqual(write_date_before, write_date_after)
|
||||
|
||||
|
||||
CREATE = lambda values: (0, False, values)
|
||||
UPDATE = lambda id, values: (1, id, values)
|
||||
|
||||
+1
-1
@@ -3102,7 +3102,7 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
|
||||
|
||||
with self.env.protecting(protected_fields, self):
|
||||
# write stored fields with (low-level) method _write
|
||||
if store_vals:
|
||||
if store_vals or inverse_vals or inherited_vals:
|
||||
self._write(store_vals)
|
||||
|
||||
# update parent records (after possibly updating parent fields)
|
||||
|
||||
Reference in New Issue
Block a user