In Odoo, the data folder plays an essential role in defining and managing various aspects of the module’s initial data setup. This folder typically contains XML, CSV, or YML files that are used to populate the database with default data, configurations, and other necessary setups when the module is installed.
data FolderInitial Data Loading: The data folder is used to load initial data into the database. This data can include records for models, default configurations, menu items, actions, views, and more.
Configuration Files: Files in the data folder can contain configurations that are necessary for the module to function properly. These can include settings, access controls, and other necessary parameters.
Demo Data: Although demo data is usually stored in a demo folder, sometimes you might find demonstration data in the data folder, especially if it is needed for initial setups.
data FolderXML Files: XML files are commonly used for loading various types of data including views, actions, workflows, security rules, and more.
CSV Files: CSV files are often used for importing large sets of data, such as product lists, partner details, and other bulk data.
YML Files: Although less common, YML files can also be used to define initial data and configurations.
data Folder ContentsHere’s an example of what the data folder might contain in a typical Odoo module:
my_module/
├── __init__.py
├── __manifest__.py
├── models/
│ └── ...
├── views/
│ └── ...
├── data/
│ ├── my_module_data.xml
│ ├── ir.model.access.csv
│ ├── my_module_default_config.xml
│ └── ...
└── ...
An XML file in the data folder might look something like this:
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<!-- Define a new record for a model -->
<record id="my_record" model="my.model">
<field name="name">My Record Name</field>
<field name="value">42</field>
</record>
<!-- Create a new menu item -->
<menuitem id="menu_my_module" name="My Module" parent="base.menu_custom" sequence="10"/>
<!-- Define an action for the menu item -->
<record id="action_my_module" model="ir.actions.act_window">
<field name="name">My Module Action</field>
<field name="res_model">my.model</field>
<field name="view_mode">tree,form</field>
</record>
<!-- Link the action to the menu item -->
<menuitem id="submenu_my_module" name="My Submenu" parent="menu_my_module" action="action_my_module"/>
</data>
</odoo>
A CSV file in the data folder might look like this for access control:
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_my_model,my.model,model_my_model,base.group_user,1,1,1,1
Amanda Martines 5 days ago
Exercitation photo booth stumptown tote bag Banksy, elit small batch freegan sed. Craft beer elit seitan exercitation, photo booth et 8-bit kale chips proident chillwave deep v laborum. Aliquip veniam delectus, Marfa eiusmod Pinterest in do umami readymade swag. Selfies iPhone Kickstarter, drinking vinegar jean.
ReplyBaltej Singh 5 days ago
Drinking vinegar stumptown yr pop-up artisan sunt. Deep v cliche lomo biodiesel Neutra selfies. Shorts fixie consequat flexitarian four loko tempor duis single-origin coffee. Banksy, elit small.
ReplyMarie Johnson 5 days ago
Kickstarter seitan retro. Drinking vinegar stumptown yr pop-up artisan sunt. Deep v cliche lomo biodiesel Neutra selfies. Shorts fixie consequat flexitarian four loko tempor duis single-origin coffee. Banksy, elit small.
Reply