Odoo Help

Welcome!

This community 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.

0

Doubt in python coding - Sorting alpha numeric values ?

By
Dimple
on 1/28/15, 1:12 AM 486 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.

 

 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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