I have a character field named employee's id. In which we enter the employee id's like 102,103,1021,..,because it is a character field it shows like 102,1021,103,.. But i want to display like 102,103,1021,... How can i sort the charcter field.?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
The below SQL to Sort character field as int,
select * from table_name order by cast(employees_id as int) asc
But in python the same code _order = "cast(employees_id as int) asc" is not support.
Solution to override _generate_order_by method in python,
def _generate_order_by(self, order_spec, query):
my_order = "cast(employees_id as int) asc"
if order_spec:
return super(class_name, self)._generate_order_by(order_spec, query) + ", " + my_order
return " order by " + my_order
Refer the link for more details.
Can we update it in xml code?
yes but what about the senario when i have a char like
"INV/01,INV/02"
at this time SQL throw an error how can we overcome?
IN that case , check below link
https://stackoverflow.com/questions/7018628/postgresql-sorting-mixed-alphanumeric-data
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký