Repository
OCA/server-tools · module folder · Try on Runboat
Module version
1.0.0
Category
Uncategorized
Folder size
0.04 MB
License
LGPL-3
Application
No
Auto-installable
No
Website
https://github.com/OCA/server-tools
Last tracking update
2026-08-07 09:06:27
Authors
Odoo Community Association (OCA), Acsone SA/NV
Maintainers
Odoo Community Association (OCA), Acsone SA/NV
Committers
Weblate, OCA-git-bot, oca-ci, Thomas HERBIN
Odoo dependencies
odoo/odoo:
Python dependencies
None
System dependencies
None
Required by
partner_invoicing_mode, sale_partner_address_restrict
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)}.

Code Analysis

Views touched (0)

No views found for this module.

HTTP endpoints (0)

No HTTP endpoints found for this module.

Models touched (1)

New fields (0)

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…