# HG changeset patch
# User Mathias Behrle <mbehrle@m9s.biz>
# Date 1567965112 -7200
#      Sun Sep 08 19:51:52 2019 +0200
# Node ID 7632d8de78a9cf696458248bad5d9a2ecb3c47a1
# Parent  8f2099fb96d6ef040f18b129959eb5e6471642a0
Migrate the tree models to the new TreeMixin.

- check_recursion is now a component of TreeMixin
- get_rec_name is handled by TreeMixin

diff -r 8f2099fb96d6 -r 7632d8de78a9 tryton/health/health.py
--- a/tryton/health/health.py	Fri Sep 06 11:20:32 2019 +0100
+++ b/tryton/health/health.py	Sun Sep 08 19:51:52 2019 +0200
@@ -39,7 +39,7 @@
 from sql.functions import Overlay, Position
 
 from trytond.model import ModelView, ModelSingleton, ModelSQL, \
-    ValueMixin, fields, Unique
+    ValueMixin, fields, Unique, tree
 from trytond.wizard import Wizard, StateAction, StateView, Button
 from trytond.transaction import Transaction
 from trytond import backend
@@ -1941,7 +1941,7 @@
 
 
 # Use the template as in Product category.
-class MedicamentCategory(ModelSQL, ModelView):
+class MedicamentCategory(tree(separator=' / '), ModelSQL, ModelView):
     'Medicament Category'
     __name__ = 'gnuhealth.medicament.category'
 
@@ -1959,17 +1959,6 @@
         super(MedicamentCategory, cls).__setup__()
         cls._order.insert(0, ('name', 'ASC'))
 
-    @classmethod
-    def validate(cls, categories):
-        super(MedicamentCategory, cls).validate(categories)
-        cls.check_recursion(categories, rec_name='name')
-
-    def get_rec_name(self, name):
-        if self.parent:
-            return self.parent.get_rec_name(name) + ' / ' + self.name
-        else:
-            return self.name
-
 
 class Medicament(ModelSQL, ModelView):
     'Medicament'
@@ -2221,7 +2210,7 @@
                 'The schedule code must be unique'),
         ]
 
-class PathologyCategory(ModelSQL, ModelView):
+class PathologyCategory(tree(separator=' / '), ModelSQL, ModelView):
     'Disease Categories'
     __name__ = 'gnuhealth.pathology.category'
 
@@ -2238,17 +2227,6 @@
         cls._order.insert(0, ('name', 'ASC'))
 
     @classmethod
-    def validate(cls, categories):
-        super(PathologyCategory, cls).validate(categories)
-        cls.check_recursion(categories, rec_name='name')
-
-    def get_rec_name(self, name):
-        if self.parent:
-            return self.parent.get_rec_name(name) + ' / ' + self.name
-        else:
-            return self.name
-
-    @classmethod
     def __setup__(cls):
         super(PathologyCategory, cls).__setup__()
         t = cls.__table__()
