From 629faa7e3bbaaa3e84ef5d76d6c6c02f0d4de0ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 1 Sep 2018 01:02:03 +0200 Subject: [PATCH] Improve ModelStorage.copy * Allow callable in copy default * Support dotted notation in copy default * Use setdefault in copy * Copy default when needed * Do not set default state in copy * Use callable and dotted notation in copy default issue5576 issue7648 review72291002 --- party.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/party.py b/party.py index b108e6f34d..21d0b2adb4 100644 --- a/party.py +++ b/party.py @@ -189,8 +189,9 @@ class Party(DeactivableMixin, ModelSQL, ModelView, MultiValueMixin): def copy(cls, parties, default=None): if default is None: default = {} - default = default.copy() - default['code'] = None + else: + default = default.copy() + default.setdefault('code', None) return super(Party, cls).copy(parties, default=default) @classmethod