From 00dc06ba1edd1e0a2478259080daac666d9b6d28 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Thu, 16 Jun 2022 14:31:01 +0200 Subject: [PATCH] Clear purchase lines when copying works issue11546 review421291003 --- work.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/work.py b/work.py index ea798851d6..2d399447be 100644 --- a/work.py +++ b/work.py @@ -209,3 +209,14 @@ class Work(metaclass=PoolMeta): return time = Category(ModelData.get_id('product', 'uom_cat_time')) return self.product.default_uom_category == time + + @classmethod + def copy(cls, records, default=None): + if default is None: + default = {} + else: + default = default.copy() + if hasattr(cls, 'purchase_lines'): + # Do not copy purchase lines if purchase is activated + default.setdefault('purchase_lines', None) + return super().copy(records, default=default)