From 49a059751f7b0bda3bb1fef19e7cb838d31dbf61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 1 Sep 2018 01:02:04 +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 --- work.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/work.py b/work.py index 85825b1198..11192ee7ca 100644 --- a/work.py +++ b/work.py @@ -194,9 +194,9 @@ class Work(DeactivableMixin, ModelSQL, ModelView): def copy(cls, works, default=None): if default is None: default = {} - default = default.copy() - if 'timesheet_lines' not in default: - default['timesheet_lines'] = None + else: + default = default.copy() + default.setdefault('timesheet_lines', None) return super(Work, cls).copy(works, default=default) @classmethod