From 89d5f0510f79a206ea285d9a36a7d04de104e532 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 --- invoice.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/invoice.py b/invoice.py index 2168c52fe4..ae0fbd3d3a 100644 --- a/invoice.py +++ b/invoice.py @@ -47,6 +47,7 @@ class Invoice(metaclass=PoolMeta): def copy(cls, invoices, default=None): if default is None: default = {} - default = default.copy() - default['open_date'] = None + else: + default = default.copy() + default.setdefault('open_date', None) return super(Invoice, cls).copy(invoices, default=default)