changeset a6db1fef7ce3 in modules/project_revenue:6.4
details: 
https://hg.tryton.org/modules/project_revenue?cmd=changeset&node=a6db1fef7ce3
description:
        Clear purchase lines when copying works

        issue11546
        review421291003
        (grafted from 555fdc46e8d1485a4da1b1cd970746f2bfd28fbe)
diffstat:

 work.py |  11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diffs (18 lines):

diff -r 4c6c1b286f04 -r a6db1fef7ce3 work.py
--- a/work.py   Mon May 02 17:25:08 2022 +0200
+++ b/work.py   Thu Jun 16 14:31:01 2022 +0200
@@ -209,3 +209,14 @@
             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)

Reply via email to