Commits

Jordi Esteve (Zikzakmedia) committed 9e64823

Added searcher methods to funcion fields

  • Participants
  • Parent commits 5bc40dd

Comments (0)

Files changed (1)

     note = fields.Text('Notes')
     softwares = fields.One2Many('network.software', 'hardware', 'Softwares')
     party = fields.Function(fields.Many2One('party.party', 'Party'),
-            'get_party')
+            'get_party', searcher='search_party')
 
     def get_party(self, name):
         return self.network.party.id
 
+    @classmethod
+    def search_party(cls, name, clause):
+        return [('network.%s' % name,) + tuple(clause[1:])]
+
 
 class NetworkSoftwareType(ModelSQL, ModelView):
     'Network Software Type'
     type = fields.Many2One('network.software.type', 'Software Type')
     note = fields.Text('Notes')
     network = fields.Function(fields.Many2One('network.network', 'Network'),
-            'get_network',
+            'get_network', searcher='search_network'
         )
     party = fields.Function(fields.Many2One('party.party', 'Party'),
-            'get_party',
+            'get_party', searcher='search_party'
         )
     logins = fields.One2Many('network.software.login', 'software',
         'Login Users')
     def get_network(self, name):
         return self.hardware.network.id
 
+    @classmethod
+    def search_network(cls, name, clause):
+        return [('hardware.%s' % name,) + tuple(clause[1:])]
+
     def get_party(self, name):
         return self.hardware.network.party.id
 
+    @classmethod
+    def search_party(cls, name, clause):
+        return [('hardware.network.%s' % name,) + tuple(clause[1:])]
+
 
 class NetworkSoftwareLogin(ModelSQL, ModelView):
     'Network Software Login'