Skip to content
Snippets Groups Projects
Commit e1231ef08ace authored by oury.balde's avatar oury.balde
Browse files

Added `sortkey` parameter to the `RelationToMany` class

parent e26d83ca7c9e
No related branches found
Tags 16.0.1.2.0
1 merge request!44Added `sortkey` parameter to the `RelationToMany` class
Changelog
=========
16.0.1.2.0
----------
Added `sortkey` parameter to the `RelationToMany` class.
16.0.1.1.1
----------
......
......@@ -22,7 +22,7 @@
"name": "Converter",
"license": "AGPL-3",
"summary": "Convert odoo records to/from plain data structures.",
"version": "16.0.1.1.1",
"version": "16.0.1.2.0",
"category": "Hidden",
"author": "XCG Consulting",
"website": "https://orbeet.io/",
......
......@@ -127,6 +127,7 @@
field_name: str,
model_name: Optional[str],
converter: Converter,
sortkey: None | Callable[[models.Model], bool] = None,
filtered: None | str | Callable[[models.Model], bool] = None,
context: Optional[ContextBuilder] = None,
limit: Optional[Any] = None,
......@@ -138,6 +139,7 @@
self.converter = converter
self.model_name = model_name
self.filtered = filtered
self.sortkey = sortkey
self.context = context
self.limit = limit
......@@ -150,6 +152,8 @@
return Skip
if self.filtered:
value = value.filtered(self.filtered)
if self.sortkey:
value = value.sorted(key=self.sortkey)
if self.limit:
value = value[: self.limit]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment