From 840a73939683788c11095fa55970898878acc4eb Mon Sep 17 00:00:00 2001 From: "Victor Piryns (pivi)" Date: Fri, 13 Sep 2024 12:35:25 +0200 Subject: [PATCH] [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) Co-authored-by: Aurelienvd --- .../reference/backend/performance.rst | 77 ------------------- content/developer/reference/cli.rst | 32 +------- 2 files changed, 1 insertion(+), 108 deletions(-) diff --git a/content/developer/reference/backend/performance.rst b/content/developer/reference/backend/performance.rst index ad636f8be..17c10f242 100644 --- a/content/developer/reference/backend/performance.rst +++ b/content/developer/reference/backend/performance.rst @@ -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 a higher memory limit: `--limit-memory-hard $((8*1024**3))`. -.. _reference/performance/populate: - -Database population -=================== - -Odoo CLI offers a :ref:`database population ` 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: Good practices diff --git a/content/developer/reference/cli.rst b/content/developer/reference/cli.rst index 71293a1eb..c56b5aa2b 100644 --- a/content/developer/reference/cli.rst +++ b/content/developer/reference/cli.rst @@ -7,8 +7,7 @@ Command-line interface (CLI) The CLI :dfn:`command-line interface` offers several functionalities related to Odoo. You can use it to :ref:`run the server `, :ref:`launch Odoo as a Python console environment `, :ref:`scaffold an Odoo module `, -:ref:`populate a database `, or :ref:`count the number of lines of code -`. +or :ref:`count the number of lines of code `. .. important:: 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/*. -.. _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 `, 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: Cloc