diff --git a/trytond/trytond/tests/test_tryton.py b/trytond/trytond/tests/test_tryton.py index 3ca1c213f7..4113fa3dbb 100644 --- a/trytond/trytond/tests/test_tryton.py +++ b/trytond/trytond/tests/test_tryton.py @@ -887,6 +887,29 @@ class ModuleTestCase(_DBTestCase): if isinstance(state, StateAction): state.get_action() + @with_transaction() + def test_modelstorage_copy(self): + "Test copied default values" + with unittest.mock.patch.object(ModelStorage, 'copy') as copy: + for mname, model in Pool().iterobject(): + if not isregisteredby(model, self.module): + continue + if not issubclass(model, ModelStorage): + continue + with self.subTest(model=mname): + model.copy([]) + if copy.call_args: + args, kwargs = copy.call_args + if len(args) >= 2: + default = args[1] + else: + default = kwargs.get('default') + if default is not None: + fields = { + k.split('.', 1)[0] for k in default.keys()} + self.assertLessEqual(fields, model._fields.keys()) + copy.reset_mock() + @with_transaction() def test_selection_fields(self): 'Test selection values'