Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sorting by location in stock item table #4658

Merged
merged 1 commit into from
Apr 22, 2023

Conversation

sur5r
Copy link
Contributor

@sur5r sur5r commented Apr 22, 2023

Currently, when sorting the stock item table by location, it gets sorted by location id.

This changes the sorting criterion to pathstring.

@SchrodingersGat
Copy link
Member

@sur5r I would have expected this to be tacked at the api level, not at the db level. Have you confirmed if this works for both ascending / descending ordering?

@sur5r
Copy link
Contributor Author

sur5r commented Apr 22, 2023

Yes it works in both directions. My first attempt was [ 'level', 'name', ] but this lead to wrong results.

I tried to add this at the API level but failed to understand how it works and whether there is a corresponding place at all.

@SchrodingersGat
Copy link
Member

@sur5r there is a place, specifically:

'stock': ['quantity', 'serial_int', 'serial'],

You could add a line as follows:

"location": "location__pathstring",

to switch the ordering type for the location field

Changing this at the database level may have some unintended consequences,

Currently, when sorting the stock item table by location, it gets sorted
by location id.

This changes the sorting criterion to pathstring.
@sur5r
Copy link
Contributor Author

sur5r commented Apr 22, 2023

Ah, that was non-obvious to me. I tried it and it looks good to me.

@SchrodingersGat
Copy link
Member

Yah the API functionality has a few subtleties - the reassignment of ordering fields is one of the more complex ones

@SchrodingersGat SchrodingersGat added the api Relates to the API label Apr 22, 2023
@SchrodingersGat SchrodingersGat added this to the 0.12.0 milestone Apr 22, 2023
@SchrodingersGat SchrodingersGat merged commit 7537fd1 into inventree:master Apr 22, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Relates to the API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants