Odoo Help

0

Doubt in python coding - Sorting alpha numeric values ?

By
Dimple
on 1/28/15, 1:12 AM 631 views

I want to sort an alphanumeric values for the employee ids. For this I have writen the query in the code as :

def _generate_order_by(self,employee_id,query):        
          my_order = "SELECT employee_id FROM hr_employee order by CAST(SPLIT_PART(employee_id, '-', 2) AS INTEGER)"       
          if employee_id:             
             return super(hr_employee, self)._generate_order_by(x_payroll, query) + ", " + my_order            
          return " order by " + my_order

Here I call the function as default,

_defaults = {

                   'employee_id': _generate_order_by, 

                   }  

But while running this code,the folllowing error occured :

ProgrammingError: syntax error at or near "SELECT"

 

If there is any error in this code please help me to correct.

 

 

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 1/28/15, 1:12 AM
Seen: 631 times
Last updated: 3/16/15, 8:10 AM