Reputation: 720
I try to call sort() method and sorted() function but it doesn't work.
Calling sorted() function :
<t t-set='data' t-value="{4: 'd', 3: 'c', 'b': 2, 'a': 1}"/>
<t t-set="list_key" t-value="sorted(list(data.keys()))"/>
<t t-esc="list_key"/>
But it gives me error like :
Error to render compiling AST TypeError: 'NoneType' object is not callable
Calling sort() method:
<t t-set='data' t-value="{4: 'd', 3: 'c', 'b': 2, 'a': 1}"/>
<t t-set="list_key" t-value="list(data.keys()).sort()"/>
<t t-esc="list_key"/>
It gives no error but when i try to access one element of list_key, i get this error :
Error to render compiling AST TypeError: 'NoneType' object is not subscriptable
Can you help me? Thanky you.
Upvotes: 0
Views: 1541
Reputation: 2825
I don't know why you needed to create sort method inside your model definition, as sorted
method is already provided to be applied on a recordset, can also be used inside qweb. For example, this line is taken from odoo community code:
<t t-foreach="move.move_line_ids.sorted(key=lambda ml: ml.location_id.id)" t-as="ml">
For more information on odoo ORM sorted
method, you can read the official documentation.
Upvotes: 1