### Install Demo Data via Command Line Source: https://www.odoo.com/documentation/saas-19.2/developer/tutorials/define_module_data.html Demonstrates how to install demo data in new Odoo databases using the command line interface. This is useful for populating databases with sample data for testing and demonstration purposes. ```bash $ ./odoo-bin -h Usage: odoo-bin [options] Options: --version show program's version number and exit -h, --help show this help message and exit Common options: [...] --with-demo install demo data in new databases [...] $ ./odoo-bin --addons-path=... -d new-db -i base --with-demo ``` -------------------------------- ### Install Upgrade utils by cloning repository Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/upgrades/upgrade_utils.html Details the process of installing the Upgrade utils library by cloning its repository locally. This method is suitable for self-managed Odoo instances where the library can be directly referenced. ```bash ./odoo-bin --upgrade-path=/path/to/upgrade-util/src,/path/to/other/upgrade/script/directory [...] ``` -------------------------------- ### Owl Component Setup Method Best Practice (JavaScript) Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/frontend/owl_components.html Illustrates the recommended way to initialize an Owl component using the `setup` method. It explicitly shows the incorrect practice of using the `constructor` for initialization, which should be avoided. ```javascript // correct: class MyComponent extends Component { setup() { // initialize component here } } // incorrect. Do not do that! class IncorrectComponent extends Component { constructor(parent, props) { // initialize component here } } ``` -------------------------------- ### Odoo Unit Test Structure and Setup Source: https://www.odoo.com/documentation/saas-19.2/developer/tutorials/unit_tests.html Demonstrates the typical directory structure for tests within an Odoo module and the basic setup for a test class extending Odoo's TransactionCase. It highlights the use of setUpClass for common data setup. ```python from odoo.tests import TransactionCase from odoo.exceptions import UserError # The CI will run these tests after all the modules are installed, # not right after installing the one defining it. class EstateTestCase(TransactionCase): @classmethod def setUpClass(cls): # add env on cls and many other things super(EstateTestCase, cls).setUpClass() # create the data for each tests. By doing it in the setUpClass instead # of in a setUp or in each test case, we reduce the testing time and # the duplication of code. cls.properties = cls.env['estate.property'].create([...]) def test_creation_area(self): """Test that the total_area is computed like it should.""" self.properties.living_area = 20 self.assertRecordValues(self.properties, [ {'name': ..., 'total_area': ...}, {'name': ..., 'total_area': ...}, ]) def test_action_sell(self): """Test that everything behaves like it should when selling a property.""" self.properties.action_sold() self.assertRecordValues(self.properties, [ {'name': ..., 'state': ...}, {'name': ..., 'state': ...}, ]) with self.assertRaises(UserError): self.properties.forbidden_action_on_sold_property() ``` -------------------------------- ### Define Odoo Test Cases with Tags Source: https://www.odoo.com/documentation/saas-19.2/developer/tutorials/unit_tests.html Demonstrates how to use the @tagged decorator to control when Odoo tests are executed during the installation process. 'post_install' runs tests after all modules are installed, while 'at_install' runs tests immediately after the specific module is installed. ```python from odoo.tests import tagged, TransactionCase # The CI will run these tests after all the modules are installed, # not right after installing the one defining it. @tagged('post_install') # this is the default class PostInstallTestCase(TransactionCase): def test_01(self): ... @tagged('at_install', '-post_install') # add `at_install` and remove `post_install` class AtInstallTestCase(TransactionCase): def test_01(self): ... ``` -------------------------------- ### Perform Asset Bundle Operations Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/frontend/assets.html Examples of asset manipulation operations including appending files, prepending files to the start of a bundle, and inserting files before a specific target file. ```python # Append operation (default) 'web.assets_common': [ 'my_addon/static/src/js/**/*', ], # Prepend operation 'web.assets_common': [ ('prepend', 'my_addon/static/src/css/bootstrap_overridden.scss'), ], # Before operation 'web.assets_common': [ ('before', 'web/static/src/css/bootstrap_overridden.scss', 'my_addon/static/src/css/bootstrap_overridden.scss'), ] ``` -------------------------------- ### Module Status and Installation Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/upgrades/upgrade_utils.html Functions to check module installation status and force module installation or upgrades. ```APIDOC ## GET /modules/check ### Description Check if one or multiple modules are currently installed in the database. ### Method GET ### Parameters #### Query Parameters - **module** (str) - Required - The name of the module to check. - **modules** (list) - Optional - A list of module names to check collectively. ### Response #### Success Response (200) - **installed** (bool) - Returns true if the module(s) are installed or marked for installation. --- ## POST /modules/force-install ### Description Force the ORM to install a specific module, optionally conditional on other modules being present. ### Method POST ### Request Body - **module** (str) - Required - Name of the module to install. - **if_installed** (list) - Optional - Only force install if these modules are present. ### Response #### Success Response (200) - **state** (str) - The new state of the module. ``` -------------------------------- ### Use Component Lifecycle Hooks Source: https://www.odoo.com/documentation/saas-19.2/developer/tutorials/discover_js_framework/01_owl_components.html Demonstrates how to use the onMounted lifecycle hook within the setup method of an Owl component. ```javascript setup() { onMounted(() => { // do something here }); } ``` -------------------------------- ### Install Upgrade utils via pip Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/upgrades/upgrade_utils.html Installs the Upgrade utils library using pip for Python environments where Odoo is not self-managed. This command fetches the latest version from the master branch of the GitHub repository. ```bash python3 -m pip install git+https://github.com/odoo/upgrade-util@master ``` -------------------------------- ### Register Odoo Tour in JavaScript Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/backend/testing.html Demonstrates how to initialize a new tour by registering it with a starting URL and a sequence of steps using the web_tour module. ```javascript import tour from 'web_tour.tour'; tour.register('rental_product_configurator_tour', { url: '/web', }, [ // Your sequence of steps ]); ``` -------------------------------- ### Monitor Odoo Module Loading Logs Source: https://www.odoo.com/documentation/saas-19.2/developer/tutorials/server_framework_101/05_firstui.html Example of the server log output confirming that an XML view file has been successfully loaded during the module installation or update process. ```text INFO rd-demo odoo.modules.loading: loading estate/views/estate_property_views.xml ``` -------------------------------- ### Initializing Dashboard Items Source: https://www.odoo.com/documentation/saas-19.2/developer/tutorials/discover_js_framework/02_build_a_dashboard.html Shows the setup method required to inject the dashboard item list into the component state for rendering. ```javascript setup() { this.items = items; } ``` -------------------------------- ### Install ipdb Debugger Source: https://www.odoo.com/documentation/saas-19.2/developer/tutorials/setup_guide.html Installs the ipdb library, a powerful Python debugger that enhances the standard pdb with IPython features. This is a prerequisite for using ipdb in your Odoo project. ```bash pip install ipdb ``` -------------------------------- ### Manage Odoo Server Lifecycle Source: https://www.odoo.com/documentation/saas-19.2/developer/tutorials/backend.html Commands to start the Odoo server and generate a new module structure using the scaffold subcommand. ```bash odoo-bin odoo-bin scaffold ``` -------------------------------- ### Define Tour Steps in JavaScript Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/backend/testing.html Examples of defining tour steps using triggers, action helpers like 'click', and conditional execution based on platform or edition. ```javascript // First step tour.stepUtils.showAppsMenuItem(), // Second step { trigger: '.o_app[data-menu-xmlid="your_module.maybe_your_module_menu_root"]', isActive: ['community'], run: "click", }, { trigger: '.js_product:has(strong:contains(Chair floor protection)) .js_add', run: "click", }, { isActive: ["mobile", "enterprise"], content: "Click on Add a product link", trigger: 'a:contains("Add a product")', tooltipPosition: "bottom", async run(helpers) { helpers.click(); } } ``` -------------------------------- ### Run Odoo Server via CLI Source: https://www.odoo.com/documentation/saas-19.2/developer/howtos/website_themes/setup.html Example of a shell script execution for the Odoo server using odoo-bin with common configuration flags for addons, database filtering, and development modes. ```bash ./odoo-bin --addons-path=../enterprise,addons --db-filter= -d -i website --dev=xml --without-demo=True ``` -------------------------------- ### Map View Configuration Example Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/user_interface/view_architectures.html This example demonstrates how to configure a Map view in Odoo. It specifies the partner field, default ordering, enables routing, and hides the partner's name and address in the popup. It also includes a field to display in the popup. ```xml ``` -------------------------------- ### Python: Odoo Alias Support Integration Example Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/backend/mixins.html Example demonstrating how to integrate alias support into a custom Odoo model (`BusinessTrip`). It inherits `mail.thread` and `mail.alias.mixin`, defines necessary fields, and overrides `_get_alias_model_name` to specify the model for created records and `_get_alias_values` to set default values for the alias. ```python class BusinessTrip(models.Model): _name = 'business.trip' _inherit = ['mail.thread', 'mail.alias.mixin'] _description = 'Business Trip' name = fields.Char(tracking=True) partner_id = fields.Many2one('res.partner', 'Responsible', tracking=True) guest_ids = fields.Many2many('res.partner', 'Participants') state = fields.Selection([('draft', 'New'), ('confirmed', 'Confirmed')], tracking=True) expense_ids = fields.One2many('business.expense', 'trip_id', 'Expenses') alias_id = fields.Many2one('mail.alias', string='Alias', ondelete="restrict", required=True) def _get_alias_model_name(self, vals): """ Specify the model that will get created when the alias receives a message """ return 'business.expense' def _get_alias_values(self): """ Specify some default values that will be set in the alias at its creation """ values = super(BusinessTrip, self)._get_alias_values() # alias_defaults holds a dictionary that will be written # to all records created by this alias # # in this case, we want all expense records sent to a trip alias # to be linked to the corresponding business trip values['alias_defaults'] = "{'trip_id': self.id}" return values ``` -------------------------------- ### Start Odoo Tour via Browser Console Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/backend/testing.html Allows manual execution of a specific tour directly from the browser's JavaScript console. ```javascript odoo.startTour("tour_name"); ``` -------------------------------- ### Initialize Odoo Database Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/cli.html Command to create and initialize a new Odoo database. This process installs the base module and allows for optional demo data and configuration. ```bash $ odoo-bin db init ``` -------------------------------- ### Configure Odoo via .odoorc file Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/cli.html Example of a configuration file structure for Odoo. Options are defined under the [options] section using specific key-value pairs. ```ini [options] db_user=odoo dbfilter=odoo ``` -------------------------------- ### Debug Odoo QWeb Templates Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/frontend/qweb.html Provides examples for logging variables, triggering breakpoints, and executing custom JavaScript within the template rendering context. ```xml console.log("Foo is", ctx.foo); ``` -------------------------------- ### QWeb Directives for Output and Logic Source: https://www.odoo.com/documentation/saas-19.2/developer/tutorials/web.html Examples of using t-out for escaped output, t-raw for raw HTML injection, and t-if for conditional rendering. ```xml
true is true
``` -------------------------------- ### Clone Odoo Petstore Module using Git Source: https://www.odoo.com/documentation/saas-19.2/developer/tutorials/web.html This command clones the example 'petstore' module from GitHub. It requires Git to be installed and accessible in your terminal. The cloned module can then be added to Odoo's addon path. ```bash git clone http://github.com/odoo/petstore ``` -------------------------------- ### Odoo Date and Datetime Utility Operations Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/backend/orm.html Examples of using Odoo's built-in utility methods to perform date arithmetic, such as adding time intervals or finding the start and end of specific time periods. ```python # Adding a relativedelta to a date new_date = fields.Date.add(my_date, months=1) # Finding the start of a month start_of_month = fields.Date.start_of(my_date, 'month') # Finding the end of a week end_of_week = fields.Datetime.end_of(my_datetime, 'week') ``` -------------------------------- ### Configure Tax Report with Columns and Lines Source: https://www.odoo.com/documentation/saas-19.2/developer/howtos/accounting_localization.html A comprehensive example of configuring a tax report including multi-language support, columns, and report lines. This structure is typically found in localization modules like l10n_at. ```xml Tax Report Steuerbericht country Base Bemessungsgrundlage base VAT Umsatzsteuer vat 3. Breakdown for the recapitulative statement (ZM) 3. Aufschlüsselung für die Zusammenfassende Meldung (ZM) ``` -------------------------------- ### Render and Load QWeb Templates Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/frontend/qweb.html Demonstrates how to render a template using a context object and how to load new templates into the QWeb engine instance. ```javascript // Rendering a template const renderedString = core.qweb.render("template_name", { "key": "value" }); // Loading templates from an XML string core.qweb.add_template("Content"); ``` -------------------------------- ### Standalone Owl Application Root Component Template (XML) Source: https://www.odoo.com/documentation/saas-19.2/developer/howtos/standalone_owl_application.html Defines the root component's template for a standalone Owl application. This XML file specifies the structure and content that the root component will render. It's a basic 'Hello, World!' example to verify the setup. ```xml Hello, World! ``` -------------------------------- ### Example: Debugging a Copy Method with ipdb Source: https://www.odoo.com/documentation/saas-19.2/developer/tutorials/setup_guide.html Demonstrates how to integrate ipdb's set_trace() within a Python method to debug its execution. This allows inspection of variables and control flow during the copy operation. ```python def copy(self, default=None): import ipdb; ipdb.set_trace() self.ensure_one() chosen_name = default.get('name') if default else '' new_name = chosen_name or _('%s (copy)') % self.name default = dict(default or {}, name=new_name) return super(Partner, self).copy(default) ``` -------------------------------- ### Define a Mock Model for Testing Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/frontend/unit_testing/mock_server.html Demonstrates how to create a fake model by extending 'models.Model' and registering it using 'defineModels'. This setup includes defining fields, records, and XML views to simulate backend behavior. ```javascript import { defineModels, fields, models } from "@web/../tests/web_test_helpers"; class ResPartner extends models.Model { _name = "res.partner"; name = fields.Char({ required: true }); _records = [ { name: "Mitchel Admin" }, ]; _views = { form: /* xml */`
`, list: /* xml */` `, }; } defineModels({ ResPartner }); ``` -------------------------------- ### Get Odoo Server Version (Python, Ruby, PHP, Java, Go) Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/external_rpc_api.html This snippet shows how to fetch the Odoo server version using the XML-RPC common endpoint. It's a meta-call that doesn't require authentication and is useful for verifying connection details. Examples are provided for Python, Ruby, PHP, Java, and Go. ```python common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url)) common.version() ``` ```ruby common = XMLRPC::Client.new2("#{url}/xmlrpc/2/common") common.call('version') ``` ```php $common = ripcord::client("$url/xmlrpc/2/common"); $common->version(); ``` ```java final XmlRpcClientConfigImpl common_config = new XmlRpcClientConfigImpl(); common_config.setServerURL(new URL(String.format("%s/xmlrpc/2/common", url))); client.execute(common_config, "version", emptyList()); ``` ```go client, err := xmlrpc.NewClient(fmt.Sprintf("%s/xmlrpc/2/common", url), nil) if err != nil { log.Fatal(err) } common := map[string]any{} if err := client.Call("version", nil, &common); err != nil { log.Fatal(err) } ``` -------------------------------- ### Create Records via Mock Server ORM - JavaScript Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/frontend/unit_testing/mock_server.html Demonstrates direct interaction with the mock server's ORM to create records. It retrieves the current mock server environment using `MockServer.env` and then uses the `create` method on a model (e.g., `res.partner`) to add new records. This bypasses the UI and directly affects the mock database. ```javascript // Most common ORM methods are provided out of the box by server models, // and are synchronous. Although, be careful that this will NOT trigger a // UI re-render, and will ONLY affect the (fake) database. const ids = MockServer.env["res.partner"].create([ { name: "foo" }, { name: "bar" }, ]); ``` -------------------------------- ### Instantiate and Use a Class Instance Source: https://www.odoo.com/documentation/saas-19.2/developer/tutorials/web.html Shows how to create an instance of a defined class using the `new` operator and how to call its methods. This example instantiates `MyClass` and calls its `say_hello` method. ```javascript var my_object = new MyClass(); my_object.say_hello(); // print "hello" in the console ``` -------------------------------- ### Create Custom Odoo Model and Get Fields (Python, PHP, Ruby, Java, Go) Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/external_rpc_api.html Demonstrates how to create a new custom Odoo model and then retrieve its field information using RPC calls. This functionality is crucial for dynamic model management and exploration of system content. Ensure the custom model name starts with 'x_' and the 'state' is set to 'manual'. ```python models.execute_kw(db, uid, password, 'ir.model', 'create', [{ 'name': "Custom Model", 'model': "x_custom_model", 'state': 'manual', }]) models.execute_kw(db, uid, password, 'x_custom_model', 'fields_get', [], {'attributes': ['string', 'help', 'type']}) ``` ```php $models->execute_kw($db, $uid, $password, 'ir.model', 'create', array(array( 'name' => "Custom Model", 'model' => 'x_custom_model', 'state' => 'manual' ))); $models->execute_kw($db, $uid, $password, 'x_custom_model', 'fields_get', array(), array('attributes' => array('string', 'help', 'type'))); ``` ```ruby models.execute_kw(db, uid, password, 'ir.model', 'create', [{ name: "Custom Model", model: 'x_custom_model', state: 'manual' }]) fields = models.execute_kw(db, uid, password, 'x_custom_model', 'fields_get', [], {attributes: %w(string help type)}) ``` ```java models.execute( "execute_kw", asList( db, uid, password, "ir.model", "create", asList(new HashMap() {{ put("name", "Custom Model"); put("model", "x_custom_model"); put("state", "manual"); }}) )); final Object fields = models.execute( "execute_kw", asList( db, uid, password, "x_custom_model", "fields_get", emptyList(), new HashMap () {{ put("attributes", asList( "string", "help", "type")); }} )); ``` ```go var id int64 if err := models.Call("execute_kw", []any{ db, uid, password, "ir.model", "create", []map[string]string{ { "name": "Custom Model", "model": "x_custom_model", "state": "manual", }, }, }, &id); err != nil { log.Fatal(err) } recordFields := map[string]string{} if err := models.Call("execute_kw", []any{ db, uid, password, "x_custom_model", "fields_get", []any{}, map[string][]string{ "attributes": {"string", "help", "type"}, }, }, &recordFields); err != nil { log.Fatal(err) } ``` -------------------------------- ### Manage Odoo Modules via CLI Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/cli.html Commands to perform module lifecycle operations including installation, uninstallation, upgrading, and forcing demo data installation. ```bash $ odoo-bin module install $ odoo-bin module uninstall $ odoo-bin module upgrade $ odoo-bin module forcedemo ``` -------------------------------- ### Odoo Default Value Examples Source: https://www.odoo.com/documentation/saas-19.2/developer/tutorials/backend.html Provides examples of setting default values for Odoo model fields. Defaults can be static values or dynamic values provided by a lambda function. ```python name = fields.Char(default="Unknown") user_id = fields.Many2one('res.users', default=lambda self: self.env.user) ``` -------------------------------- ### Define Server Action and Automation Rule in XML Source: https://www.odoo.com/documentation/saas-19.2/developer/tutorials/importable_modules.html This snippet demonstrates how to create an ir.actions.server record to execute Python logic and a base.automation record to trigger that action when a sale order state changes. It requires the base_automation module as a dependency. ```xml Create property from sale order code Create property from sale order on_state_set ``` -------------------------------- ### Card Component Usage Source: https://www.odoo.com/documentation/saas-19.2/developer/tutorials/discover_js_framework/01_owl_components.html Demonstrates how to instantiate a Card component with title and content props and the resulting Bootstrap-styled HTML structure. ```xml ``` ```html
my title

some content

``` -------------------------------- ### Batching Recordset Operations: Create Records (Python) Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/backend/performance.html Illustrates optimizing record creation by accumulating values in a list and calling the create method once for the batch, instead of creating records individually within a loop. This helps the framework optimize field computations. ```Python for name in ['foo', 'bar']: model.create({'name': name}) ``` ```Python create_values = [] for name in ['foo', 'bar']: create_values.append({'name': name}) records = model.create(create_values) ``` -------------------------------- ### Odoo Kanban Header Button Example Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/user_interface/view_architectures.html Shows how to add buttons to the control panel of an Odoo Kanban view using the `header` element. It includes examples of buttons with 'always' display mode. ```xml
...
``` -------------------------------- ### Secure QWeb Template Rendering Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/backend/security.html Demonstrates the transition from insecure 't-raw' rendering to secure template practices using 't-out' and structured data separation. ```javascript QWeb.render('secure_template', { message: "You have an important notification on the product:", subject: product.name }); ``` ```xml
``` -------------------------------- ### Implement Odoo migrate() function Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/upgrades/upgrade_scripts.html Examples of implementing the migrate() function in Odoo upgrade scripts. The first example uses raw SQL via the database cursor, while the second utilizes Odoo's Upgrade utils to access the ORM. ```python import logging _logger = logging.getLogger(__name__) def migrate(cr, version): cr.execute("UPDATE res_partner SET name = name || '!'") _logger.info("Updated %s partners", cr.rowcount) ``` ```python import logging from odoo.upgrade import util _logger = logging.getLogger(__name__) def migrate(cr, version): env = util.env(cr) partners = env["res.partner"].search([]) for partner in partners: partner.name += "!" _logger.info("Updated %s partners", len(partners)) ``` -------------------------------- ### Configure Actions and Menus Source: https://www.odoo.com/documentation/saas-19.2/developer/tutorials/backend.html Shows how to declare a window action (ir.actions.act_window) and link it to a menu item using the shortcut. Note that the action record must be declared before the menu item in the XML file to ensure the reference exists. ```xml Ideas idea.idea list,form ``` -------------------------------- ### Deploy Module Remotely with Odoo CLI Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/cli.html The `deploy` command uploads a module to a remote Odoo server and installs it. It requires Odoo administrative credentials and the `base_import_module` to be installed on the server. This command simplifies remote module deployment without requiring full server access. ```bash $ odoo-bin deploy --db --login --password ``` -------------------------------- ### GET /account.report Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/standard_modules/account/account_report.html Retrieves the configuration and filter settings for a specific accounting report definition. ```APIDOC ## GET /account.report ### Description Retrieves the schema and configuration settings for an account report, including line definitions, column layouts, and available UI filters. ### Method GET ### Endpoint /account.report ### Parameters #### Query Parameters - **id** (int) - Required - The unique identifier of the report. ### Request Example { "id": 1 } ### Response #### Success Response (200) - **name** (str) - Name of the report - **line_ids** (list) - List of report lines - **column_ids** (list) - List of report columns - **root_report_id** (int) - ID of the parent report if this is a variant - **country_id** (int) - ID of the associated country - **load_more_limit** (int) - Pagination limit for report lines #### Response Example { "name": "Balance Sheet", "load_more_limit": 500, "filter_date_range": true, "filter_journals": true } ``` -------------------------------- ### Start New Rows with Newline Element in Odoo XML Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/user_interface/view_architectures.html The `newline` element is used within `group` elements to force the start of a new row. It immediately moves subsequent elements to the next row without attempting to fill the current row, aiding in layout control. ```xml
... ...
``` ```xml
... ... ...
``` -------------------------------- ### Call sub-templates with t-call Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/frontend/qweb.html Explains how to reuse templates using t-call. Demonstrates passing context variables and using the magical '0' variable to inject content into sub-templates. ```XML
``` -------------------------------- ### Importing Core Utilities Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/frontend/framework_overview.html Demonstrates how to import utility functions from the Odoo web framework using the @web prefix. ```javascript import { memoize } from "@web/core/utils/functions"; ``` -------------------------------- ### GET /model/fields_get Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/backend/orm.html Retrieves the metadata and definition of fields for a specific model. ```APIDOC ## GET /model/fields_get ### Description Returns the definition of each field in the model, including translated attributes like help text and selection options. ### Method GET ### Endpoint /model/fields_get ### Parameters #### Query Parameters - **allfields** (list[str]) - Optional - Specific fields to document. - **attributes** (list[str]) - Optional - Specific attributes to return for each field. ### Request Example { "allfields": ["name", "email"], "attributes": ["string", "help"] } ### Response #### Success Response (200) - **fields** (dict) - Dictionary mapping field names to their attribute definitions. #### Response Example { "name": { "string": "Name", "help": "The name of the record" } } ``` -------------------------------- ### GET /get_columns Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/upgrades/upgrade_utils.html Retrieves a list of column names for a specified database table. ```APIDOC ## GET /get_columns ### Description Returns a list of columns present in a specific table, excluding specified columns. ### Method GET ### Endpoint /get_columns ### Parameters #### Query Parameters - **table** (str) - Required - The table name. - **ignore** (list) - Optional - List of columns to exclude from the result. ### Response #### Success Response (200) - **columns** (list) - A list of column names found in the table. ``` -------------------------------- ### GET /response/get_json Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/backend/http.html Parses the response data as JSON, useful for testing purposes. ```APIDOC ## GET /response/get_json ### Description Parses the response data as JSON. Returns None if the mimetype is not application/json. ### Method GET ### Parameters #### Query Parameters - **force** (bool) - Optional - Ignore the mimetype and always try to parse JSON. - **silent** (bool) - Optional - Silence parsing errors and return None instead. ### Response #### Success Response (200) - **data** (Any) - The parsed JSON content or None. ``` -------------------------------- ### Configure Window Action Views using XML Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/backend/actions.html Examples of defining Odoo window action views and records using XML. These snippets show how to link specific views to actions and configure view sequences. ```xml list ``` ```xml A Test Action some.model graph ``` -------------------------------- ### Odoo Search Domain Examples Source: https://www.odoo.com/documentation/saas-19.2/developer/tutorials/backend.html Demonstrates how to construct search domains in Odoo to filter records. Domains are lists of criteria combined with logical operators like AND, OR, and NOT. ```python [('product_type', '=', 'service'), ('unit_price', '>', 1000)] ``` ```python ['|', ('product_type', '=', 'service'), '!', '&', ('unit_price', '>=', 1000), ('unit_price', '<', 2000)] ``` -------------------------------- ### Apply Dynamic Class Attributes Source: https://www.odoo.com/documentation/saas-19.2/developer/tutorials/discover_js_framework/01_owl_components.html Example showing how to combine static and dynamic class attributes in Owl templates using t-att-class. ```xml
``` -------------------------------- ### Create Mock Environment with makeMockEnv Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/frontend/unit_testing/web_helpers.html The `makeMockEnv` helper creates a pre-configured environment object for web component testing. It initializes a MockServer, starts services, and ensures proper teardown. This is useful for testing low-level features not tied to a specific component. ```javascript const env = await makeMockEnv(); expect(env.isSmall).toBe(false); ``` -------------------------------- ### GET /api/extract/applicant/{id}/get_result Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/extract_api.html Retrieves the parsing results for an applicant document. The ID in the endpoint refers to the specific applicant being queried. ```APIDOC ## GET /api/extract/applicant/{id}/get_result ### Description Retrieves the parsing results for an applicant document. The ID in the endpoint refers to the specific applicant being queried. ### Method GET ### Endpoint /api/extract/applicant/{id}/get_result ### Parameters #### Path Parameters - **id** (int) - Required - The unique identifier for the applicant. ### Response #### Success Response (200) - **jsonrpc** (string) - The JSON-RPC version. - **id** (string) - The request ID. - **result** (object) - Contains the parsing results. - **status** (string) - The code indicating the status of the request. - **status_msg** (string) - Verbose details about the request status. - **results** (array) - An array of dictionaries, where each dictionary represents the extracted features for a document. - Each dictionary contains feature names as keys and their extracted values. #### Response Example ```json { "jsonrpc": "2.0", "id": "some_id", "result": { "status": "success", "status_msg": "Success", "results": [ { "applicant_name": { "selected_value": { "content": "John Doe", "coords": [0.5, 0.5, 0.2, 0.05, 0.0], "page": 0 }, "candidates": [ { "content": "John Doe", "coords": [0.5, 0.5, 0.2, 0.05, 0.0], "page": 0 } ] } } ] } } ``` ``` -------------------------------- ### Execute Tour in Python Test Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/backend/testing.html Shows how to trigger an interactive tour from a Python test case by inheriting from HTTPCase and calling the start_tour method. ```python def test_your_test(self): # Optional Setup self.start_tour("/web", "your_tour_name", login="admin") # Optional verifications ``` -------------------------------- ### GET /api/extract/expense/{id}/get_result Source: https://www.odoo.com/documentation/saas-19.2/developer/reference/extract_api.html Retrieves the parsing results for an expense document. The ID in the endpoint refers to the specific expense being queried. ```APIDOC ## GET /api/extract/expense/{id}/get_result ### Description Retrieves the parsing results for an expense document. The ID in the endpoint refers to the specific expense being queried. ### Method GET ### Endpoint /api/extract/expense/{id}/get_result ### Parameters #### Path Parameters - **id** (int) - Required - The unique identifier for the expense. ### Response #### Success Response (200) - **jsonrpc** (string) - The JSON-RPC version. - **id** (string) - The request ID. - **result** (object) - Contains the parsing results. - **status** (string) - The code indicating the status of the request. - **status_msg** (string) - Verbose details about the request status. - **results** (array) - An array of dictionaries, where each dictionary represents the extracted features for a document. - Each dictionary contains feature names as keys and their extracted values. #### Response Example ```json { "jsonrpc": "2.0", "id": "some_id", "result": { "status": "success", "status_msg": "Success", "results": [ { "vendor_name": { "selected_value": { "content": "Example Corp", "coords": [0.5, 0.5, 0.2, 0.05, 0.0], "page": 0 }, "candidates": [ { "content": "Example Corp", "coords": [0.5, 0.5, 0.2, 0.05, 0.0], "page": 0 } ] } } ] } } ``` ```