Base Partition
base_partition · OCA/server-tools
-
Security25/25No findings
-
Activity20/25Last human commit 11 months ago
-
Required by20/253 modules depend on it
-
Maturity25/25In 4 Odoo series since 16.0
Heuristic over the facts below, not an audit · How it's computed
Description
This module adds a partition(self, accessor) method to every model. It accepts for accessor any parameter that would be accepted by mapped, i.e. a string "field(.subfield)*" or a function (lambda x: not x.b). It returns a dictionary with keys that are equal to set(record.mapped(accessor)), and with values that are recordsets (these recordsets forming a partition of the initial recordset, conveniently).
So if we have a recordset (x | y | z ) such that x.f == True, y.f == z.f == False, then (x | y | z ).partition("f") == {True: x, False: (y | z)}.
Dependencies
- Odoo dependencies
-
odoo/odoo:- base
- Python dependencies
- None
- System dependencies
- None
- Required by
- partner_invoicing_mode, sale_invoice_policy, sale_partner_address_restrict
Code analysis
Extracted from the source by best-effort static analysis (no code is executed); details may be incomplete.
Views touched 0
No views found for this module.
HTTP endpoints 0
No HTTP endpoints found for this module.
Models touched 1
No new fields.
Public methods (3)-
batch(self, batch_size=None)Yield successive batches of size batch_size, or . -
partition(self, accessor)Returns a dictionary forming a partition of self into a dictionary value/recordset for each value obtained from the accessor. The accessor itself can be either a string that can be passed to mapped, or an arbitrary function. Note that it is always at least as fast to pass a function, hence the current implementation. If we have a 'field.subfield' accessor such that subfield is not a relational then the result is a list (not hashable). Then the str(key) are used. In the general case a value could both not be hashable nor stringifiable, in a which case this function would crash. -
read_per_record(self, fields=None, load='_classic_read')
Loading…
Loading…
Loading…
Loading…