Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
1498 Ansichten

Hello guys:


I noticed that the column 'qty_available' in the list view of the module product is NOT sortable, and some other columns such as 'cost' 、'forecasted quantity' either.  

I looked into the relevant snippet in list_renderer.js  ,there is a function 'isSortable()' to check with one of properties named 'sortable':

isSortable(column) {
const { hasLabel, name } = column;
const { sortable } = this.fields[name];
const { options } = this.props.list.activeFields[name];
return (sortable || options.allow_order) && hasLabel;

And then I checked the field's properties in the console log and found the value of 'sortable' is 'false' :

 


I knew that computed fields which not stored in database can not be sorted,  but I'm wondering where is the source code determining a field's property 'sortable' ? 


Thanks in advance!

Avatar
Verwerfen
Beste Antwort

Hi,

if a field is computed and not stored (store=False), Odoo will typically set sortable=False automatically because sorting on non-stored fields isn't possible directly in the database.

The method isSortable() in the list_renderer.js checks for this property when rendering the list view in the Odoo web client.

Thanks

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
1
Dez. 24
2275
4
Juli 25
1742
1
Juli 25
965
1
Apr. 25
979
0
März 25
940