Skip to Content
Menu
This question has been flagged
1 Reply
1503 Views

I have a one2many field which has a column named abc in which i am storing ids. It has sequence as 1, 1.1, 1.2, 1.n. I am trying sort according to the abc column of one2many field but i am facing an issue related to the sorting that is, When the ids are more than 10 then Sorting or order by doesn't work properly.

Suppose, In one2many field, I have more than 10 records, lets say 15 records and i have  added order by on abc field then it performed sorting as below:-

1, 1.1, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9

but i expected the sorting as below:-

1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15

here is the code in which i have added order by:-

test_object = self.env['module.name'].search([], order='abc')

i have also tried implementing order by in one2many table as below:-

_order = "abc"

I have tried another solution by implementing order in tree view of one2many field:-


but not working in any of the cases.

How can i solve this issue? Do anyone have any idea related to this?


Avatar
Discard
Best Answer

The problem is that it is sorting correctly based on the naming convention.

1.2 is more than 1.15

The sequence should be 1.01 ...... 1.09, 1.10, 1.11 ..... to sort correctly

Avatar
Discard
Related Posts Replies Views Activity
1
May 24
1433
1
Apr 24
23242
1
Nov 22
1402
2
Jul 22
1798
2
Jul 22
1822