-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADD] Developer: data module tutorial #11050
base: 17.0
Are you sure you want to change the base?
Conversation
Will need a new entry in codeowners ( |
Introduce a new tutorial about creating Odoo modules using XML data files instead of Python code. This guide is follows closely the 'Server Framework 101' tutorial and covers the following: - Module structure and deployment - Defining models and fields - Setting up security and access rights - Creating views and actions - Implementing relational fields (many2one, many2many, one2many) - Working with computed and related fields - Adding business logic through server actions and automation rules - Creating website controllers for API endpoints The tutorial includes practical exercises and code examples to reinforce learning, catering to developers who need to customize Odoo without writing Python code (e.g. Odoo PS-Tech employees, partners that focus on SaaS instances or author of Industry modules). Task-4167176
dc9b746
to
0c95a70
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff 👍
Just the style issue of putting id
first in the XML <record/>
s and some minor typos.
This tutorial assumes familiarity with the :doc:`server_framework_101` tutorial and the | ||
:doc:`define_module_data` tutorial. | ||
|
||
Although as developpers, we prefer to have the full power of Python to write our modules, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although as developpers, we prefer to have the full power of Python to write our modules, | |
Although, as developers, we prefer to have the full power of Python to write our modules, |
|
||
However, the flexible nature of Odoo is meant to allow customizations out of the box. Whilst | ||
a lot is possible with :doc:`Studio </applications/studio>`, it is also possible to define | ||
models, fields and logic in :doc:`XLM Data File <define_module_data>`. This makes it easier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
models, fields and logic in :doc:`XLM Data File <define_module_data>`. This makes it easier | |
models, fields and logic in :doc:`XML Data Files <define_module_data>`. This makes it easier |
|
||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<record model="ir.model" id="model_real_estate_property"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id
should come first. https://www.odoo.com/documentation/15.0/contributing/development/coding_guidelines.html#xml-files
<record model="ir.model" id="model_real_estate_property"> | |
<record id="model_real_estate_property" model="ir.model"> |
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<!-- ...model definition from before... --> | ||
<record model="ir.model.fields" id="field_real_estate_property_name"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<record model="ir.model.fields" id="field_real_estate_property_name"> | |
<record id="field_real_estate_property_name" model="ir.model.fields"> |
<field name="required">True</field> | ||
</record> | ||
|
||
<record model="ir.model.fields" id="field_real_estate_property_selling_price"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<record model="ir.model.fields" id="field_real_estate_property_selling_price"> | |
<record id="field_real_estate_property_selling_price" model="ir.model.fields"> |
|
||
- Add a server action to the ``x_estate.property.offer`` model that sets the ``x_status`` | ||
field of an offer to ``Accepted`` and update the selling price and buyer of the property | ||
to which the offer is attached accordingly. This action also marks all the other offers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to which the offer is attached accordingly. This action also marks all the other offers | |
to which the offer is attached accordingly. This action should also mark all the other offers |
|
||
.. code-block:: xml | ||
|
||
<record model="ir.ui.view" id="view_sale_order_form"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<record model="ir.ui.view" id="view_sale_order_form"> | |
<record id="view_sale_order_form" model="ir.ui.view"> |
|
||
.. code-block:: xml | ||
|
||
<record model="ir.actions.server" id="action_x_estate_property_create_from_sale_order"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<record model="ir.actions.server" id="action_x_estate_property_create_from_sale_order"> | |
<record id="action_x_estate_property_create_from_sale_order" model="ir.actions.server"> |
|
||
.. code-block:: xml | ||
|
||
<record model="ir.actions.server" id="server_action_estate_list"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<record model="ir.actions.server" id="server_action_estate_list"> | |
<record id="server_action_estate_list" model="ir.actions.server"> |
- add an access right record to allow public users to read and write the model | ||
- prevent any write from the public user by adding a record rule for the write operation | ||
with an impossible domain (e.g. `[('id', '=', False)]`) to prevent any write operation | ||
- add a record rule so that properties marked as `x_api_published` are can be read by the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- add a record rule so that properties marked as `x_api_published` are can be read by the | |
- add a record rule so that properties marked as `x_api_published` can be read by the |
Introduce a new tutorial about creating Odoo modules using XML data files
instead of Python code.
This guide is follows closely the 'Server Framework 101' tutorial and
covers the following:
The tutorial includes practical exercises and code examples to reinforce
learning, catering to developers who need to customize Odoo without writing
Python code (e.g. Odoo PS-Tech employees, partners that focus on SaaS instances
or author of Industry modules).
Task-4167176