Reviewers: ,


Please review this at http://codereview.tryton.org/553002/

Affected files:
  M tryton/gui/window/view_form/model/record.py
  M tryton/gui/window/view_form/screen/screen.py


Index: tryton/gui/window/view_form/model/record.py
===================================================================
--- a/tryton/gui/window/view_form/model/record.py
+++ b/tryton/gui/window/view_form/model/record.py
@@ -140,6 +140,15 @@
     def parent_name(self):
         return self.group.parent_name

+    @property
+    def depth(self):
+        parent = self.parent
+        i = 0
+        while parent:
+            i += 1
+            parent = parent.parent
+        return i
+
     def set_modified(self, value):
         if value:
             self.signal('record-modified')
Index: tryton/gui/window/view_form/screen/screen.py
===================================================================
--- a/tryton/gui/window/view_form/screen/screen.py
+++ b/tryton/gui/window/view_form/screen/screen.py
@@ -565,6 +565,8 @@
         if not records:
             return
         if delete:
+            # Must delete children records before parent
+            records.sort(key=lambda r: r.depth, reverse=True)
             if not self.group.delete(records):
                 return False



--
[email protected] mailing list

Reply via email to