Search 1.9 billion lines of Odoo code on GitHub

base_partition

Author: Acsone, Odoo Community Association (OCA)
License: AGPL-3
Branch: 13.0-partition-len
Repository: acsone/server-tools
Dependencies: base
Languages: HTML (344, 72.1%), and Python (133, 27.9%)
Other branches: 12.0-asw_master, 12.0-backport-shopinvader_customer_multi_user-len, 12.0-partition-len, and 12.0-trn_master
Other repositories: acsone/odoo-shopinvader

<h1 class="title">Base Partition</h1> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-tools/tree/13.0/base_partition"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-tools-13-0/server-tools-13-0-base_partition"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/149/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p>This module adds a <cite>partition(self, accessor)</cite> method to every model. It accepts for accessor any parameter that would be accepted by <cite>mapped</cite>, i.e. a string <cite>&quot;field(.subfield)*&quot;</cite> or a function <cite>(lambda x: not x.b)</cite>. It returns a dictionary with keys that are equal to <cite>set(record.mapped(accessor))</cite>, and with values that are recordsets (these recordsets forming a partition of the initial recordset, conveniently).</p> <p>So if we have a recordset (x | y | z ) such that x.f == True, y.f == z.f == False, then (x | y | z ).partition(&quot;f&quot;) == {True: x, False: (y | z)}.</p> <p>It also provides a <cite>batch(self, batch_size)</cite> method to every model, which provides a generator that yields recordsets of size at most <cite>batch_size</cite>. The batch size can be omitted if there is a <cite>_default_batch_size</cite> defined on the model.</p> <pre> <code lang="python">for batch in self.batch(100): batch.process()</code> </pre> <p><strong>Table of contents</strong></p> <div class="contents local topic" id="contents"> <ul class="simple"> <li><a class="reference internal" href="#bug-tracker" id="id1">Bug Tracker</a></li> <li><a class="reference internal" href="#credits" id="id2">Credits</a><ul> <li><a class="reference internal" href="#authors" id="id3">Authors</a></li> <li><a class="reference internal" href="#contributors" id="id4">Contributors</a></li> <li><a class="reference internal" href="#maintainers" id="id5">Maintainers</a></li> </ul> </li> </ul> </div> <a name="bug-tracker"></a> <h2><a class="toc-backref" href="#id1">Bug Tracker</a></h2> <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed <a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20base_partition%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <p>Do not contact contributors directly about support or help with technical issues.</p> <a name="credits"></a> <h2><a class="toc-backref" href="#id2">Credits</a></h2> <a name="authors"></a> <h3><a class="toc-backref" href="#id3">Authors</a></h3> <ul class="simple"> <li>Acsone</li> </ul> <a name="contributors"></a> <h3><a class="toc-backref" href="#id4">Contributors</a></h3> <ul class="simple"> <li>Nans Lefebvre &lt;<a class="reference external" href="mailto:nans.lefebvre&#64;acsone.eu">nans.lefebvre&#64;acsone.eu</a>&gt;</li> </ul> <a name="maintainers"></a> <h3><a class="toc-backref" href="#id5">Maintainers</a></h3> <p>This module is maintained by the OCA.</p> <a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> <p>OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/13.0/base_partition">OCA/server-tools</a> project on GitHub.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>