[REM] developer/performance: remove mentions to the populate tool

closes odoo/documentation#11034

Related: odoo/odoo#180318
Related: odoo/enterprise#70095
Signed-off-by: Piryns Victor (pivi) <pivi@odoo.com>
Co-authored-by: Aurelienvd <avd@odoo.com>
This commit is contained in:
Victor Piryns (pivi) 2024-09-13 12:35:25 +02:00
parent 3692e684c4
commit 840a739396
2 changed files with 1 additions and 108 deletions

View File

@ -287,83 +287,6 @@ Performance pitfalls
results, which can lead to an HTTP 500 error. In this case, you may need to start the server with results, which can lead to an HTTP 500 error. In this case, you may need to start the server with
a higher memory limit: `--limit-memory-hard $((8*1024**3))`. a higher memory limit: `--limit-memory-hard $((8*1024**3))`.
.. _reference/performance/populate:
Database population
===================
Odoo CLI offers a :ref:`database population <reference/cmdline/populate>` feature through the CLI
command :command:`odoo-bin populate`.
Instead of the tedious manual, or programmatic, specification of test data, one can use this feature
to fill a database on demand with the desired number of test data. This can be used to detect
diverse bugs or performance issues in tested flows.
.. _reference/performance/populate/methods:
To populate a given model, the following methods and attributes can be defined.
.. currentmodule:: odoo.models
.. autoattribute:: Model._populate_sizes
.. autoattribute:: Model._populate_dependencies
.. automethod:: Model._populate
.. automethod:: Model._populate_factories
.. note::
You have to define at least :meth:`~odoo.models.Model._populate` or
:meth:`~odoo.models.Model._populate_factories` on the model to enable database population.
.. example::
.. code-block:: python
from odoo.tools import populate
class CustomModel(models.Model)
_inherit = "custom.some_model"
_populate_sizes = {"small": 100, "medium": 2000, "large": 10000}
_populate_dependencies = ["custom.some_other_model"]
def _populate_factories(self):
# Record ids of previously populated models are accessible in the registry
some_other_ids = self.env.registry.populated_models["custom.some_other_model"]
def get_some_field(values=None, random=None, **kwargs):
""" Choose a value for some_field depending on other fields values.
:param dict values:
:param random: seeded :class:`random.Random` object
"""
field_1 = values['field_1']
if field_1 in [value2, value3]:
return random.choice(some_field_values)
return False
return [
("field_1", populate.randomize([value1, value2, value3])),
("field_2", populate.randomize([value_a, value_b], [0.5, 0.5])),
("some_other_id", populate.randomize(some_other_ids)),
("some_field", populate.compute(get_some_field, seed="some_field")),
('active', populate.cartesian([True, False])),
]
def _populate(self, size):
records = super()._populate(size)
# If you want to update the generated records
# E.g setting the parent-child relationships
records.do_something()
return records
Population tools
----------------
Multiple population tools are available to easily create the needed data generators.
.. automodule:: odoo.tools.populate
:members: cartesian, compute, constant, iterate, randint, randomize
.. _performance/good_practices: .. _performance/good_practices:
Good practices Good practices

View File

@ -7,8 +7,7 @@ Command-line interface (CLI)
The CLI :dfn:`command-line interface` offers several functionalities related to Odoo. You can use it The CLI :dfn:`command-line interface` offers several functionalities related to Odoo. You can use it
to :ref:`run the server <reference/cmdline/server>`, :ref:`launch Odoo as a Python console to :ref:`run the server <reference/cmdline/server>`, :ref:`launch Odoo as a Python console
environment <reference/cmdline/shell>`, :ref:`scaffold an Odoo module <reference/cmdline/scaffold>`, environment <reference/cmdline/shell>`, :ref:`scaffold an Odoo module <reference/cmdline/scaffold>`,
:ref:`populate a database <reference/cmdline/populate>`, or :ref:`count the number of lines of code or :ref:`count the number of lines of code <reference/cmdline/cloc>`.
<reference/cmdline/cloc>`.
.. important:: .. important::
The command to use to call the CLI depends on how you installed Odoo. In the examples below, we The command to use to call the CLI depends on how you installed Odoo. In the examples below, we
@ -740,35 +739,6 @@ Scaffolding is available via the :command:`odoo-bin scaffold` subcommand.
This will create module *my_module* in directory */addons/*. This will create module *my_module* in directory */addons/*.
.. _reference/cmdline/populate:
Database Population
===================
.. program:: odoo-bin populate
Odoo CLI supports database population features. If the feature is
:ref:`implemented on a given model <reference/performance/populate/methods>`, it allows automatic
data generation of the model's records to test your modules in databases containing non-trivial
amounts of records.
.. code-block:: console
$ odoo-bin populate
.. option:: --models
list of models for which the database should be filled
.. option:: --size (small|medium|large)
population size, the actual records number depends on the model's `_populate_sizes` attribute.
The generated records content is specified by the :meth:`~odoo.models._populate_factories` method
of a given model (cf. the :file:`populate` folder of modules for further details).
.. seealso::
:ref:`reference/performance/populate`
.. _reference/cmdline/cloc: .. _reference/cmdline/cloc:
Cloc Cloc