Advertisement
Guest User

Tryton Override searcher

a guest
Dec 22nd, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.22 KB | None | 0 0
  1.      def search_state(cls, name, clause):                                      
  2.           result = super(PurchaseRequest, cls).search_state(name, clause)          
  3.           # result contains [('id', 'in', state_query)]                            
  4.           _, _, state_query = result[0]                                            
  5.           # state query is a python-sql which can be manipullated                  
  6.           state_query.where &= new_condition  # To add new where                    
  7.           # If required you can join to new tables                                  
  8.           new_query = state_query.join()                                            
  9.           # Or enterly replace the wer                                              
  10.           new_query.where = new_where                                              
  11.           # Once you have customized the query you can return it                    
  12.           return [('id', 'in', new_query)]                                          
  13.   ~                                                                                                                                                                    
  14.   ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement