Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
4051 Näkymät
estate
├── data
│   └── master_data.xml
├── demo
│   └── demo_data.xml
├── models
│   ├── *.py
│   └── __init__.py
├── populate
​├── *.py │ ​└── __init__.py ├── security │ └── ir.model.access.csv ├── views │ └── estate_property_offer_views.xml ├── __init__.py └── __manifest__.py

What is the use of populate folder ? Can any one explain ?

Avatar
Hylkää
Paras vastaus

Hi,

This is the tool to generate data in the db for the performance and testing purpose . You can see more about the populate from here in the odoo documentation:  https://www.odoo.com/documentation/16.0/developer/reference/backend/performance.html?highlight=populate#module-odoo.tools.populate


Thanks

Avatar
Hylkää
Paras vastaus

Hello Srikanth Puli

• This is a concept of “Database Population”
- Which is accessed through the CLI command “odoo-bin populate”
• This feature is used 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.
• The following methods and attributes can be defined as below:
◦ Model._populate_sizes
◦ Model._populate_dependencies
◦ Model._populate
◦ Model._populate_factories
• For an example considering the model “account.bank.statement.line”, below is the reference logic.
◦ Here the field ‘amount’ will be populated with random number in the provided range. 
• Various Population tools are used. They are as follows:
odoo.tools.populate.cartesian
odoo.tools.populate.compute
odoo.tools.populate.constant
odoo.tools.populate.iterate
odoo.tools.populate.randint
odoo.tools.populate.randomize

Please find Example in comment. 

I hope this can help you.

Thanks & Regards,
Email:   odoo@aktivsoftware.com 

Skype: kalpeshmaheshwari

Avatar
Hylkää

Find code example here :-

from odoo.tools import populate

class AccountBankStatementLine(models.Model):
_inherit = "account.bank.statement.line"
_populate_sizes = { 'small': 100, 'medium': 10000, 'large': 200000, }
_populate_dependencies = ['account.journal', 'res.company', 'res.partner']
def _populate_factories(self):
def get_amount(random, **kwargs):
return random.uniform(-1000, 1000) or 1
return [ ('amount', populate.compute(get_amount)),]

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
3
elok. 25
2613
1
toukok. 25
2646
1
huhtik. 25
3637
1
huhtik. 25
4492
1
huhtik. 25
1962