Skip to Content
Menu
v 18.0 Third Party 42
Download for v 18.0 Deploy on Odoo.sh
Availability
Odoo Online
Odoo.sh
On Premise
Lines of code 401
Technical Name faker
LicenseLGPL-3
You bought this module and need support? Click here!
Availability
Odoo Online
Odoo.sh
On Premise
Lines of code 401
Technical Name faker
LicenseLGPL-3

Odoo Faker

Warning

Take into account that this addon is still in development mode. Also, keep in mind it's not intended for production sites. Use it at your own discretion.

Odoo Faker is an addon for Odoo that facilitates the generation of random demo data. As they are other ways, here's a comparison.

Feature Demo mode The populate command The Faker addon
Flexible number of records No Yes Yes
Works for all models No (1) No (2) Yes
Has a user interface No No Yes
Supports massive amounts of data No Yes No

Usage

Generators

Once the addon is installed, you'll find a new Faker option in your menu. That option will let you define your own Generators.

Screenshot of the Odoo Faker generator form

Each of your generators will target a model from your Odoo database. You can create as many generators as you want. For every generator, you can define:

  • a name (like Corporations from the United Kingdom)
  • a model (like Contact)
  • a default locale to be used when generating fake data

Generator fields

To make your generators useful, you have to define its fields. The fields available are literally the stored fields of the corresponding model.

The information that you can set for each field depends on the type of field, which can be one of:

  • Constant
  • Faker
  • Random record
  • Generated rows

Constant

When adding fields of type Constant you will only be able to set one thing: its (constant) value.

You will use constant fields when you want all the generated records to have the same value.

For instance, if you want to generate active contacts, you can set its active field to True.

Faker

The Faker type is meant to be used for fields where you want a different value to be created each time, like names, emails, phones, addresses, account numbers, etc.

The values are generated by Python's Faker, so check out their documentation. Most of its methods are available. Feel free to open an issue if you need or want one of the methods that aren't currently available.

By default, each new faker Field inherits the locale from its parent generator but you can choose a different one. Make the Faker locale column visible to be able to view and edit its value.

Sequential dates

Some times you may want to create records with sequential dates. For instance, you may want to do it when you are populating a demo database with sale orders. Otherwise, you'd obtain an incoherent database where sorting the orders by number wouldn't be consistent with ordering by date. This would be a disaster if we were talking about invoices!

In order to fix that, you can use Sequential dates for your date columns. When defining a date with this type of generator, you'll be able to add a minimum and a maximum date, so that all the generated dates will be in that period.

Random record

If your model has a many to one field (like the country of a contact) you can set its type Random record so one different record from the related table will be used each time.

Generated rows

If your model has a one to many relationship (like the lines of an order) you can set its type to Generated rows and use the Row generator column to select a related generator created specifically to define the child rows.

Generator wizard

Once you have defined your generator, you can use the Generate header button to run a wizard where you can define:

  • the generator that you want to use
  • the number of records that you want to generate
  • a maximum number of errors to tolerate before aborting

Screenshot of the Odoo Faker generator wizard

Development

Dependencies

This addon depends on Python's Faker package for the generation of random data. Make sure to install it before enabling the addon.

Tests

The test suite can be executed by filtering the tests with the faker tag.

odoo-bin --test-enable --test-tags faker

Please log in to comment on this module

  • The author can leave a single reply to each comment.
  • This section is meant to ask simple questions or leave a rating. Every report of a problem experienced while using the module should be addressed to the author directly (refer to the following point).
  • If you want to start a discussion with the author, please use the developer contact information. They can usually be found in the description.
Please choose a rating from 1 to 5 for this module.