### Install and Initialize PostgreSQL on Fedora Source: https://www.odoo.com/documentation/19.0/administration/on_premise/packages.html These commands install, initialize, enable, and start the PostgreSQL server on Fedora-based systems. ```bash $ sudo dnf install -y postgresql-server $ sudo postgresql-setup --initdb --unit postgresql $ sudo systemctl enable postgresql $ sudo systemctl start postgresql ``` -------------------------------- ### Install demo data with Odoo command line Source: https://www.odoo.com/documentation/19.0/developer/tutorials/define_module_data.html Demonstrates how to use the --with-demo option when starting Odoo to install demo data in new databases. It also shows the help output for odoo-bin. ```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 Odoo dependencies on Debian/Ubuntu with setup script Source: https://www.odoo.com/documentation/19.0/administration/on_premise/source.html Runs the setup/debinstall.sh script to automatically parse and install required packages from the debian/control file. Execute from the Odoo Community root directory. ```bash $ cd odoo #CommunityPath $ sudo ./setup/debinstall.sh ``` -------------------------------- ### Clone petstore module with Git Source: https://www.odoo.com/documentation/19.0/developer/tutorials/web.html Download the example petstore module from GitHub to use as a starting point for web client customization. ```bash $ git clone http://github.com/odoo/petstore ``` -------------------------------- ### Configure Odoo Nightly Repository and Install on Fedora Source: https://www.odoo.com/documentation/19.0/administration/on_premise/packages.html Add the Odoo nightly repository, install Odoo, and then enable and start the Odoo service on Fedora. ```bash $ sudo dnf config-manager --add-repo=https://nightly.odoo.com/19.0/nightly/rpm/odoo.repo $ sudo dnf install -y odoo $ sudo systemctl enable odoo $ sudo systemctl start odoo ``` -------------------------------- ### Install Odoo .rpm Package on Fedora Source: https://www.odoo.com/documentation/19.0/administration/on_premise/packages.html Install a downloaded Odoo .rpm package using dnf, then enable and start the Odoo service on Fedora. ```bash $ sudo dnf localinstall odoo_19.0.latest.noarch.rpm $ sudo systemctl enable odoo $ sudo systemctl start odoo ``` -------------------------------- ### Run Odoo server with specific configuration Source: https://www.odoo.com/documentation/19.0/developer/howtos/website_themes/setup.html Example shell script to launch the Odoo server, specifying addon paths, database filters, initial module installation, and development mode. ```bash ./odoo-bin --addons-path=../enterprise,addons --db-filter= -d -i website --dev=xml --without-demo=True ``` -------------------------------- ### Install Make (Linux) Source: https://www.odoo.com/documentation/19.0/contributing/documentation.html Installs the make utility on Debian-based Linux systems using apt, which is often required for build processes. ```Bash $ sudo apt install make -y ``` -------------------------------- ### Create an 'Example' admonition in reStructuredText Source: https://www.odoo.com/documentation/19.0/contributing/documentation/rst_guidelines.html Use the `example` directive to present an illustrative example. ```rst .. example:: Use this alert block to show an example. ``` -------------------------------- ### Apply menuselection Markup for Menu Paths Source: https://www.odoo.com/documentation/19.0/contributing/documentation/rst_guidelines.html Use the `menuselection` markup to guide users through a sequence of menu items, starting with the app's name. ```rst To review sales performance, go to :menuselection:`Sales --> Reporting --> Dashboard`. ``` -------------------------------- ### Correct Owl Component Initialization with setup() (JS) Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/owl_components.html Illustrates the correct way to initialize an Owl component in Odoo using the `setup()` method. This is preferred over `constructor()` as it is overridable. ```javascript // correct: class MyComponent extends Component { setup() { // initialize component here } } ``` -------------------------------- ### odoo-bin module install Source: https://www.odoo.com/documentation/19.0/developer/reference/cli.html Installs all selected modules straight away. Before installing modules, the Odoo database needs to be created and initialized on your PostgreSQL instance. ```APIDOC ## module install ### Description This command installs all selected modules straight away. Before installing modules, the Odoo database needs to be created and initialized on your PostgreSQL instance. ### Syntax `odoo-bin module install ` ### Arguments - **modules** (list of strings) - Required - List of modules you want to install. ``` -------------------------------- ### SCSS Property Order Example Source: https://www.odoo.com/documentation/19.0/contributing/development/coding_guidelines.html Demonstrates the recommended order for properties in SCSS, starting with position, followed by display, margin, width, border, padding, background, font, and filter, with scoped variables at the top. ```scss .o_element { $-inner-gap: $border-width + $legend-margin-bottom; --element-margin: 1rem; --element-size: 3rem; @include o-position-absolute(1rem); display: block; margin: var(--element-margin); width: calc(var(--element-size) + #{$-inner-gap}); border: 0; padding: 1rem; background: blue; font-size: 1rem; filter: blur(2px); } ``` -------------------------------- ### start() Source: https://www.odoo.com/documentation/19.0/es_419/developer/reference/external_rpc_api.html Retrieves information for a test database, including host, database name, username, and password, from the Odoo demo server. ```APIDOC ## RPC Method: start ### Description This method is called on the `/start` endpoint to provision and retrieve details for a temporary Odoo test database. ### Method XML-RPC Call ### Endpoint `https://demo.odoo.com/start` ### Parameters #### RPC Parameters - No explicit parameters are passed to the `start` method. ### Response #### Success Response - **host** (string) - The URL of the Odoo instance. - **database** (string) - The name of the test database. - **user** (string) - The username for the test database. - **password** (string) - The password for the test database. #### Response Example ```json { "host": "https://your-instance.odoo.com", "database": "your_db_name", "user": "your_username", "password": "your_password" } ``` ``` -------------------------------- ### Install PostgreSQL on Linux using apt Source: https://www.odoo.com/documentation/19.0/administration/on_premise/source.html Install PostgreSQL and its client on Debian/Ubuntu-based Linux systems using the `apt` package manager. Ensure PostgreSQL version 13.0 or higher is installed. ```bash $ sudo apt install postgresql postgresql-client ``` -------------------------------- ### Initialize dashboard items in component setup Source: https://www.odoo.com/documentation/19.0/developer/tutorials/discover_js_framework/02_build_a_dashboard.html Assign the imported items list to the component instance in the setup method to make it available in the template. ```javascript setup() { this.items = items; } ``` -------------------------------- ### Start a Web Tour from a Python Test Source: https://www.odoo.com/documentation/19.0/es_419/developer/reference/backend/testing.html Shows how to initiate a web tour from a Python test by inheriting from `HTTPCase` and calling `self.start_tour` with the starting URL, tour name, and optional login. ```python def test_your_test(self): # Optional Setup self.start_tour("/web", "your_tour_name", login="admin") # Optional verifications ``` -------------------------------- ### Install Debugging Tool Temporarily Source: https://www.odoo.com/documentation/19.0/administration/odoo_sh/advanced/containers.html Install pudb or ipdb for the current build only. These tools are not installed by default and must be added before use. ```bash $ pip install pudb --user ``` ```bash $ pip install ipdb --user ``` -------------------------------- ### Manage Widget Properties with Events Source: https://www.odoo.com/documentation/19.0/developer/tutorials/web.html This example demonstrates how to use widget properties with `set()` and `get()`. Setting a property automatically triggers `change:_propname_` and `change` events, allowing other parts of the application to react to data changes. ```javascript start: function() { this.widget = ... this.widget.on("change:name", this, this.name_changed); this.widget.set("name", "Nicolas"); }, name_changed: function() { console.log("The new value of the property 'name' is", this.widget.get("name")); } ``` -------------------------------- ### start() Source: https://www.odoo.com/documentation/19.0/developer/reference/external_rpc_api.html Retrieves connection information for a test Odoo database, including URL, database name, username, and password. ```APIDOC ## RPC Method: start ### Description Retrieves connection information for a test Odoo database, including URL, database name, username, and password. ### RPC Endpoint `https://demo.odoo.com/start` ### RPC Method Name `start` ### RPC Parameters None ### Response #### Success Response - **host** (string) - The URL of the Odoo instance. - **database** (string) - The name of the Odoo database. - **user** (string) - The username for the test database. - **password** (string) - The password for the test database. #### Response Example ``` { "host": "https://example.odoo.com", "database": "test_db", "user": "test_user", "password": "test_password" } ``` ``` -------------------------------- ### Install Python requirements with pip on Windows Source: https://www.odoo.com/documentation/19.0/administration/on_premise/source.html Installs setuptools, wheel, and Odoo Python dependencies from requirements.txt on Windows. Must be run in a terminal with Administrator privileges. ```batch C:\> cd \CommunityPath C:\> pip install setuptools wheel C:\> pip install -r requirements.txt ``` -------------------------------- ### Launch Odoo with odoo-bin Source: https://www.odoo.com/documentation/19.0/developer/tutorials/setup_guide.html Use this command to start the Odoo server, specifying addon paths and a database for your development environment. ```bash $ cd $HOME/src/odoo/ $ ./odoo-bin --addons-path="addons/,../enterprise/,../tutorials" -d rd-demo ``` -------------------------------- ### Install Module with Odoo CLI Source: https://www.odoo.com/documentation/19.0/administration/odoo_sh/advanced/containers.html Install a module and immediately shutdown the server after initialization. Use `--stop-after-init` to prevent the server from continuing to run. ```bash $ odoo-bin -i sale --stop-after-init ``` -------------------------------- ### SCSS Syntax and Formatting Example Source: https://www.odoo.com/documentation/19.0/contributing/development/coding_guidelines.html Illustrates recommended SCSS syntax and formatting, including nested rules and variable usage for properties like height and background. ```scss .o_foo, .o_foo_bar, .o_baz { height: $o-statusbar-height; .o_qux { height: $o-statusbar-height * 0.5; } } .o_corge { background: $o-list-footer-bg-color; } ``` -------------------------------- ### Access Right Naming Convention Example Source: https://www.odoo.com/documentation/19.0/applications/general/users/access_rights.html This example demonstrates a recommended naming convention for access rights, combining the model's technical name with a group identifier. ```text res.partner.purchase.manager ``` -------------------------------- ### Patching an Odoo Component's Setup Method Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/patching_code.html Shows how to patch the `setup` method of an Owl component, which is the recommended approach for extending component behavior. ```javascript patch(MyComponent.prototype, { setup() { useMyHook(); }, }); ``` -------------------------------- ### Start Odoo Server Source: https://www.odoo.com/documentation/19.0/developer/tutorials/backend.html Invokes the odoo-bin command to start the Odoo server. The server can be stopped by pressing Ctrl-C twice. ```bash odoo-bin ``` -------------------------------- ### Basic Registry Usage Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/registries.html Demonstrates how to create a new registry, add a key-value pair, and retrieve a value using the `add` and `get` methods. ```javascript import { Registry } from "@web/core/registry"; const myRegistry = new Registry(); myRegistry.add("hello", "odoo"); console.log(myRegistry.get("hello")); ``` -------------------------------- ### Install modules with odoo-bin Source: https://www.odoo.com/documentation/19.0/developer/reference/cli.html Install selected modules. The Odoo database must be created and initialized on PostgreSQL before running this command. ```bash $ odoo-bin module install ``` -------------------------------- ### Run Odoo on Linux Source: https://www.odoo.com/documentation/19.0/administration/on_premise/source.html Launches the Odoo server from the specified CommunityPath, using `python3` and connecting to `mydb`. This example uses a relative `addons-path`. ```bash $ cd /CommunityPath $ python3 odoo-bin --addons-path=addons -d mydb ``` -------------------------------- ### Install PostgreSQL on Debian/Ubuntu Source: https://www.odoo.com/documentation/19.0/administration/on_premise/packages.html Use this command to install the PostgreSQL server on Debian or Ubuntu systems, which is required for Odoo to run. ```bash $ sudo apt install postgresql -y ``` -------------------------------- ### Install Python requirements with pip3 on Mac OS Source: https://www.odoo.com/documentation/19.0/administration/on_premise/source.html Installs setuptools, wheel, and Odoo Python dependencies from requirements.txt on Mac OS using pip3. ```bash $ cd /CommunityPath $ pip3 install setuptools wheel $ pip3 install -r requirements.txt ``` -------------------------------- ### Install Python Dependencies Source: https://www.odoo.com/documentation/19.0/contributing/documentation.html Installs all Python packages listed in the requirements.txt file using pip, which are necessary for building the documentation. ```Bash $ pip install -r requirements.txt ``` -------------------------------- ### Install ipdb debugger Source: https://www.odoo.com/documentation/19.0/developer/tutorials/setup_guide.html Install the ipdb Python debugging library using pip. ```bash pip install ipdb ``` -------------------------------- ### Initializing useSpellCheck for Input Elements Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/hooks.html This example shows how to initialize the `useSpellCheck` hook in an Owl component's setup method. It demonstrates using default and custom reference names to enable spellcheck on different input and contenteditable elements. ```JavaScript import { useSpellCheck } from "@web/core/utils/hooks"; class Comp { setup() { this.simpleRef = useSpellCheck(); this.customRef = useSpellCheck({ refName: "custom" }); this.nodeRef = useSpellCheck({ refName: "container" }); } static template = "Comp"; } ``` -------------------------------- ### Example 'values' Dictionary for ensure_xmlid_match_record Source: https://www.odoo.com/documentation/19.0/es_419/developer/reference/upgrades/upgrade_utils.html Examples demonstrating the structure of the 'values' dictionary used in the 'ensure_xmlid_match_record' function to specify record criteria for matching. ```python values = {"id": 123} ``` ```python values = {"name": "INV/2024/0001", "company_id": 1} ``` -------------------------------- ### Initialize Odoo Database Source: https://www.odoo.com/documentation/19.0/developer/reference/cli.html Creates a new Odoo database and installs the base module. Replace `` with the desired database name. ```bash $ odoo-bin db init ``` -------------------------------- ### Create a tour in JavaScript Source: https://www.odoo.com/documentation/19.0/developer/tutorials/importable_modules.html Add a tour file to guide users through the application. Import the registry and add a tour with steps that define triggers and content messages. ```javascript import { registry } from "@web/core/registry"; registry.category("web_tour.tours").add('estate_tour', { url: "/web", steps: () => [{ trigger: '.o_app[data-menu-xmlid="estate.menu_root"]', content: 'Start selling your properties from this app!', }], }); ``` -------------------------------- ### Example Execution Order of Upgrade Scripts Source: https://www.odoo.com/documentation/19.0/developer/reference/upgrades/upgrade_scripts.html Demonstrates the lexical execution order of upgrade scripts within different phases (pre, post, end) for a single module and version. ```text 1. pre-10-do_something.py 2. pre-20-something_else.py 3. post-do_something.py 4. post-something.py 5. end-01-migrate.py 6. end-migrate.py ``` -------------------------------- ### CSS Compiled Output Example Source: https://www.odoo.com/documentation/19.0/contributing/development/coding_guidelines.html Shows the compiled CSS output corresponding to the SCSS example, demonstrating how variables and nesting are resolved into standard CSS. ```css .o_foo, .o_foo_bar, .o_baz { height: 32px; } .o_foo .o_quux, .o_foo_bar .o_quux, .o_baz .o_qux { height: 16px; } .o_corge { background: #EAEAEA; } ``` -------------------------------- ### Title Service Parts Example Source: https://www.odoo.com/documentation/19.0/es_419/developer/reference/frontend/services.html Example of a Parts object structure showing how multiple parts compose the document title. ```JavaScript { odoo: "Odoo", action: "Import" } ``` -------------------------------- ### Install system libraries on Debian/Ubuntu for Python compilation Source: https://www.odoo.com/documentation/19.0/administration/on_premise/source.html Installs required system libraries (LDAP, PostgreSQL, SASL) needed for Python package compilation steps on Debian/Ubuntu systems. ```bash $ sudo apt install python3-pip libldap2-dev libpq-dev libsasl2-dev ``` -------------------------------- ### Example Odoo TransactionCase Test Class Source: https://www.odoo.com/documentation/19.0/developer/tutorials/unit_tests.html Demonstrates a basic Odoo unit test class inheriting from `TransactionCase`, including `setUpClass` for efficient data setup and example test methods with assertions and exception handling. ```python from odoo.tests.common import TransactionCase from odoo.exceptions import UserError from odoo.tests import tagged # The CI will run these tests after all the modules are installed, # not right after installing the one defining it. @tagged('post_install', '-at_install') 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() ``` -------------------------------- ### Implement and register a service Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/javascript_reference.html Create a service by defining an object with a start() method that returns the service interface, then register it in the services category. Services are instantiated at application startup and remain available throughout the application lifetime. ```javascript import { registry } from "@web/core/registry"; export const OrmService = { start() { return { read(...) { ... }, write(...) { ... }, unlink(...) { ... }, ... } }, }; registry.category("services").add("orm", OrmService); ``` -------------------------------- ### Start Numbered List with Specific Number in RST Source: https://www.odoo.com/documentation/19.0/contributing/documentation/rst_guidelines.html Illustrates how to start a numbered list with a specific number and then continue with automatic numbering. ```rst 6. Use this format to start the numbering with a number other than one. #. The numbering is automatic from there. ``` -------------------------------- ### Register a Web Tour in JavaScript Source: https://www.odoo.com/documentation/19.0/es_419/developer/reference/backend/testing.html Registers a new web tour using `web_tour.tour.register`. Specify a unique name and an optional starting URL for the tour. ```javascript import tour from 'web_tour.tour'; tour.register('rental_product_configurator_tour', { url: '/web', // Here, you can specify any other starting url }, [ // Your sequence of steps ]); ``` -------------------------------- ### Odoo Website Snippets Demo Page URL Source: https://www.odoo.com/documentation/19.0/developer/howtos/website_themes/building_blocks.html Example URL to access the demo page for snippets, requiring demo data to be installed. ```url https://your-database.com/website/demo/snippets ``` -------------------------------- ### Configure Odoo Nightly Repository and Install on Debian/Ubuntu Source: https://www.odoo.com/documentation/19.0/administration/on_premise/packages.html Add the Odoo nightly repository key and source list, then update package lists and install Odoo Community edition on Debian/Ubuntu. ```bash $ wget -q -O - https://nightly.odoo.com/odoo.key | sudo gpg --dearmor -o /usr/share/keyrings/odoo-archive-keyring.gpg $ echo 'deb [signed-by=/usr/share/keyrings/odoo-archive-keyring.gpg] https://nightly.odoo.com/19.0/nightly/deb/ ./' | sudo tee /etc/apt/sources.list.d/odoo.list $ sudo apt-get update && sudo apt-get install odoo ``` -------------------------------- ### Install Upgrade Utils via pip Source: https://www.odoo.com/documentation/19.0/developer/reference/upgrades/upgrade_utils.html Install the Upgrade Utils library directly from its Git repository using pip. This method is recommended for environments where Odoo is not self-managed. ```bash python3 -m pip install git+https://github.com/odoo/upgrade-util@master ``` -------------------------------- ### HTTP Test Case Example in Odoo Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/testing.html Use `HttpCase` for tests involving web interactions. The `@tagged` decorator controls when the test runs relative to module installation. ```python from odoo.tests import HttpCase, tagged # This test should only be executed after all modules have been installed. @tagged('-at_install', 'post_install') class WebsiteVisitorTests(HttpCase): def test_create_visitor_on_tracked_page(): Page = self.env['website.page'] ``` -------------------------------- ### Assign QWeb Template Directly to Widget Source: https://www.odoo.com/documentation/19.0/developer/tutorials/web.html This JavaScript example shows how to assign a QWeb template directly to a widget's `template` attribute for automatic rendering before the `start()` method. ```javascript local.HomePage = instance.Widget.extend({ template: "HomePageTemplate", start: function() { ... }, }); ``` -------------------------------- ### SCSS and CSS Syntax Formatting Example Source: https://www.odoo.com/documentation/19.0/es_419/contributing/development/coding_guidelines.html Demonstrates proper SCSS and CSS formatting with nested selectors, variable usage, and correct indentation. Shows both SCSS with variables and equivalent CSS with hardcoded values. ```scss .o_foo, .o_foo_bar, .o_baz { height: $o-statusbar-height; .o_qux { height: $o-statusbar-height * 0.5; } } .o_corge { background: $o-list-footer-bg-color; } ``` ```css .o_foo, .o_foo_bar, .o_baz { height: 32px; } .o_foo .o_quux, .o_foo_bar .o_quux, .o_baz .o_qux { height: 16px; } .o_corge { background: #EAEAEA; } ``` -------------------------------- ### Filter databases by name pattern Source: https://www.odoo.com/documentation/19.0/developer/reference/cli.html Use `--db-filter` to restrict access to databases matching a regular expression. This example filters for databases whose names start with '11'. ```bash $ odoo-bin --db-filter ^11.*$ ``` -------------------------------- ### Create a new Git branch for Odoo 19.0 contribution Source: https://www.odoo.com/documentation/19.0/contributing/development.html Use this command to create a new branch for your changes, starting from the `19.0` base branch. This example is for external contributors. ```bash $ git switch -c 19.0-fix-invoices ``` -------------------------------- ### Define Odoo Test Cases with `at_install` and `post_install` Tags Source: https://www.odoo.com/documentation/19.0/developer/tutorials/unit_tests.html Use `@tagged('post_install', '-at_install')` for tests that run after all modules are installed, which can speed up CI. Use `@tagged('at_install')` (the default) for tests whose behavior might change if other modules are installed later. ```python from odoo.tests.common import TransactionCase from odoo.tests import tagged # The CI will run these tests after all the modules are installed, # not right after installing the one defining it. @tagged('post_install', '-at_install') # add `post_install` and remove `at_install` class PostInstallTestCase(TransactionCase): def test_01(self): ... @tagged('at_install') # this is the default class AtInstallTestCase(TransactionCase): def test_01(self): ... ``` -------------------------------- ### Example of Odoo `button_box` with Buttons and StatInfo Source: https://www.odoo.com/documentation/19.0/developer/reference/user_interface/view_architectures.html This example shows a `button_box` containing an edit button and another button that displays a field value using the `statinfo` widget. ```XML
``` -------------------------------- ### Get Child Widget Element in JavaScript Source: https://www.odoo.com/documentation/19.0/developer/tutorials/web.html Illustrates how to use 'getChildren()' within a widget's 'start' method to retrieve and log the root DOM element of its first child widget. ```JavaScript local.HomePage = instance.Widget.extend({ start: function() { var greeting = new local.GreetingsWidget(this); greeting.appendTo(this.$el); console.log(this.getChildren()[0].$el); // will print "div.oe_petstore_greetings" in the console }, }); ``` -------------------------------- ### Perform HTTP GET and POST Requests Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/services.html Demonstrates how to use the `http` service to send GET and POST requests to an external API. It shows fetching data and sending new data. ```javascript const httpService = useService("http"); const data = await httpService.get("https://something.com/posts/1"); // ... await httpService.post("https://something.com/posts/1", { title: "new title", content: "new content" }); ``` -------------------------------- ### Get Parent Widget Element in JavaScript Source: https://www.odoo.com/documentation/19.0/developer/tutorials/web.html Demonstrates how to use 'getParent()' within a widget's 'start' method to access and log the parent widget's root DOM element. ```JavaScript local.GreetingsWidget = instance.Widget.extend({ start: function() { console.log(this.getParent().$el ); // will print "div.oe_petstore_homepage" in the console }, }); ``` -------------------------------- ### Define Basic Web Tour Steps in JavaScript Source: https://www.odoo.com/documentation/19.0/es_419/developer/reference/backend/testing.html Illustrates defining a sequence of steps for a web tour, including using predefined utilities and custom steps with triggers and run actions. ```javascript // First step tour.stepUtils.showAppsMenuItem(), // Second step { trigger: '.o_app[data-menu-xmlid="your_module.maybe_your_module_menu_root"]', isActive: ['community'], // Optional run: "click", }, { // Third step }, ``` -------------------------------- ### Clone Odoo repositories with SSH (Linux/Mac) Source: https://www.odoo.com/documentation/19.0/administration/on_premise/source.html Clone both Community and Enterprise repositories using SSH protocol. Use this method when contributing to Odoo source code or following the Getting Started developer tutorial. ```bash $ git clone --branch 19.0 --single-branch git@github.com:odoo/odoo.git $ git clone --branch 19.0 --single-branch git@github.com:odoo/enterprise.git ``` -------------------------------- ### Example `vals_list` format for `Model.create()` Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/orm.html Defines the structure for the `vals_list` parameter in `Model.create()`, which is a list of dictionaries, each representing a record's field values. ```python [{'field_name': field_value, ...}, ...] ``` -------------------------------- ### NGINX Root and Try_Files for Git Sources Installation Source: https://www.odoo.com/documentation/19.0/administration/on_premise/deploy.html This snippet provides the specific 'root' and 'try_files' directives for NGINX when Odoo is installed from Git sources, accommodating multiple addons paths. ```nginx root /opt/odoo; try_files /community/odoo/addons$uri /community/addons$uri /enterprise$uri @odoo; ``` -------------------------------- ### Load languages into Odoo database Source: https://www.odoo.com/documentation/19.0/developer/reference/cli.html Install and activate one or more languages in the Odoo instance. Language codes must follow XPG (POSIX) locale format; examples include en, es_AR, and sr@latin. ```bash $ odoo-bin i18n loadlang -l en # English (U.S.) $ odoo-bin i18n loadlang -l es es_AR # Spanish (Spain, Argentina) $ odoo-bin i18n loadlang -l sr@latin # Serbian (Latin) ``` -------------------------------- ### Connect to Database with psql Source: https://www.odoo.com/documentation/19.0/administration/odoo_sh/advanced/containers.html Example of accessing the PostgreSQL database from within an Odoo.sh container shell using psql command. ```bash odoo@odoo-addons-master-1.odoo.sh:~$ psql psql (9.5.2, server 9.5.11) SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off) Type "help" for help. odoo-addons-master-1=> ``` -------------------------------- ### Configure Odoo dbfilter to show 'mycompany' databases Source: https://www.odoo.com/documentation/19.0/administration/on_premise/deploy.html Set the `dbfilter` option in the Odoo configuration file to only display databases whose names start with 'mycompany'. This is useful for multi-tenant setups where specific databases should be accessible. ```ini [options] dbfilter = ^mycompany.*$ ``` -------------------------------- ### Clone Odoo repositories with SSH (Windows) Source: https://www.odoo.com/documentation/19.0/administration/on_premise/source.html Clone both Community and Enterprise repositories using SSH protocol on Windows. Use this method when contributing to Odoo source code or following the Getting Started developer tutorial. ```bash C:\> git clone --branch 19.0 --single-branch git@github.com:odoo/odoo.git C:\> git clone --branch 19.0 --single-branch git@github.com:odoo/enterprise.git ``` -------------------------------- ### Registering a Custom Service with Dependencies Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/framework_overview.html This example illustrates how to register a new service, `myService`, that declares a dependency on the `notification` service. The service then uses `setInterval` to display periodic notifications. ```javascript import { registry } from "./core/registry"; const serviceRegistry = registry.category("services"); const myService = { dependencies: ["notification"], start(env, { notification }) { let counter = 1; setInterval(() => { notification.add(`Tick Tock ${counter++}`); }, 5000); } }; serviceRegistry.add("myService", myService); ``` -------------------------------- ### Configure test tags for post-install execution in Odoo Source: https://www.odoo.com/documentation/19.0/es_419/developer/tutorials/unit_tests.html Use @tagged('post_install', '-at_install') to defer test execution until after all modules are installed, avoiding CI slowdown when test behavior is independent of other module installations. Requires importing TransactionCase and tagged from odoo.tests. ```python from odoo.tests.common import TransactionCase from odoo.tests import tagged # The CI will run these tests after all the modules are installed, # not right after installing the one defining it. @tagged('post_install', '-at_install') # add `post_install` and remove `at_install` class PostInstallTestCase(TransactionCase): def test_01(self): ... ``` ```python @tagged('at_install') # this is the default class AtInstallTestCase(TransactionCase): def test_01(self): ... ``` -------------------------------- ### Configure Odoo dbfilter to match the first subdomain Source: https://www.odoo.com/documentation/19.0/administration/on_premise/deploy.html Set the `dbfilter` option to match the first subdomain of the incoming request. For example, `mycompany.com` would match the 'mycompany' database. This is crucial for multi-tenant setups with domain-based database selection. ```ini [options] dbfilter = ^%d$ ``` -------------------------------- ### Rendered HTML output of QWeb foreach loop Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/qweb.html This is the HTML output generated by the basic `t-foreach` example. ```HTML

1

2

3

``` -------------------------------- ### Odoo Server Log Output Example Source: https://www.odoo.com/documentation/19.0/administration/odoo_sh/advanced/containers.html Sample log output showing Odoo version, configuration file path, and addons paths. Use this to verify the correct addons directories are being loaded by your Odoo.sh instance. ```text 2018-02-19 10:51:39,267 4 INFO ? odoo: Odoo version 19.0 2018-02-19 10:51:39,268 4 INFO ? odoo: Using configuration file at /home/odoo/.config/odoo/odoo.conf 2018-02-19 10:51:39,268 4 INFO ? odoo: addons paths: ['/home/odoo/data/addons/19.0', '/home/odoo/src/user', '/home/odoo/src/enterprise', '/home/odoo/src/themes', '/home/odoo/src/odoo/addons', '/home/odoo/src/odoo/odoo/addons'] ``` -------------------------------- ### Create Custom Model and Get Fields via RPC Source: https://www.odoo.com/documentation/19.0/developer/reference/external_rpc_api.html Use `ir.model` to dynamically create a new custom model and then retrieve its default fields. Custom model names must start with `x_` and the `state` must be `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) } ``` -------------------------------- ### Example Upgrade Test Directory Structure Source: https://www.odoo.com/documentation/19.0/developer/reference/upgrades/upgrade_utils.html Illustrates the recommended directory structure for placing upgrade test files within an Odoo module's upgrade path, ensuring they are detected by Odoo. ```text myupgrades/ └── mymodule1/ ├── 18.0.1.1.2/ │ └── pre-myupgrade.py └── tests/ ├── __init__.py └── test_myupgrade.py ``` -------------------------------- ### CSV Data File Format for Country States Source: https://www.odoo.com/documentation/19.0/developer/tutorials/server_framework_101/04_securityintro.html Example CSV file structure for loading country state data with external identifiers and foreign key references. The id column uses external identifiers, country_id:id references another record by its external identifier, and data must be declared in __manifest__.py to load during module installation. ```csv "id","country_id:id","name","code" state_au_1,au,"Australian Capital Territory","ACT" state_au_2,au,"New South Wales","NSW" state_au_3,au,"Northern Territory","NT" state_au_4,au,"Queensland","QLD" ... ``` -------------------------------- ### Run Odoo on Windows Source: https://www.odoo.com/documentation/19.0/administration/on_premise/source.html Launches the Odoo server from the specified CommunityPath, using `python` and connecting to `mydb` with a specific PostgreSQL user and password. This example uses a relative `addons-path`. ```cmd C:\> cd CommunityPath/ C:\> python odoo-bin -r dbuser -w dbpassword --addons-path=addons -d mydb ``` -------------------------------- ### Verify pip installation (Windows) Source: https://www.odoo.com/documentation/19.0/administration/on_premise/source.html Confirm that pip is installed for the Python version being used on Windows. Required for installing Odoo dependencies. ```bash C:\> pip --version ``` -------------------------------- ### Verify pip installation (Linux/Mac) Source: https://www.odoo.com/documentation/19.0/administration/on_premise/source.html Confirm that pip is installed for the Python 3 version being used. Required for installing Odoo dependencies. ```bash $ pip3 --version ``` -------------------------------- ### Install Odoo Enterprise .deb package Source: https://www.odoo.com/documentation/19.0/administration/on_premise/community_to_enterprise.html Install the Odoo Enterprise .deb package on Linux, which is designed to install over the existing Community package. ```bash $ sudo dpkg -i ``` -------------------------------- ### Install rtlcss on Windows Source: https://www.odoo.com/documentation/19.0/administration/on_premise/source.html Installs the rtlcss package globally using npm on Windows for right-to-left language support. Requires nodejs to be installed first. ```batch C:\> npm install -g rtlcss ``` -------------------------------- ### Rendered HTML output of QWeb t-att=mapping Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/qweb.html This is the HTML output generated by the `t-att="{'a': 1, 'b': 2}"` example. ```HTML
``` -------------------------------- ### Example Directory Structure for Odoo Upgrade Script Source: https://www.odoo.com/documentation/19.0/developer/reference/upgrades/upgrade_scripts.html Illustrates the required directory structure for an Odoo upgrade script, showing the module, migrations, version, and a pre-phase script file. ```text awesome_partner/ |-- migrations/ | |-- 17.0.2.0/ | | |-- pre-exclamation.py ``` -------------------------------- ### Install Python requirements with pip on Linux/Mac Source: https://www.odoo.com/documentation/19.0/administration/on_premise/source.html Installs Odoo Python dependencies from requirements.txt for the current user. Navigate to the Odoo Community installation path first. ```bash $ cd /CommunityPath $ pip install -r requirements.txt ``` -------------------------------- ### Update database with web_enterprise module (Linux installer) Source: https://www.odoo.com/documentation/19.0/administration/on_premise/community_to_enterprise.html Run this command to update your Odoo database with the 'web_enterprise' module after installing the Enterprise package via the installer. ```bash $ python3 /usr/bin/odoo-bin -d -i web_enterprise --stop-after-init ``` -------------------------------- ### Mount Standalone Owl Application Source: https://www.odoo.com/documentation/19.0/developer/howtos/standalone_owl_application.html Set up the main application entry point to mount the root Owl component when the document is ready. The `mountComponent` utility handles environment setup and template access. ```javascript import { whenReady } from "@odoo/owl"; import { mountComponent } from "@web/env"; import { Root } from "./root"; whenReady(() => mountComponent(Root, document.body)); ``` -------------------------------- ### Nested Dropdown Menu Example (XML) Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/owl_components.html Demonstrates creating a nested dropdown menu by embedding `Dropdown` components within the content slot of other dropdowns. Shows how to structure submenus. ```XML Save Open Document Spreadsheet ``` -------------------------------- ### Install rtlcss on Linux Source: https://www.odoo.com/documentation/19.0/administration/on_premise/source.html Installs the rtlcss package globally using npm for right-to-left language support (Arabic, Hebrew). Requires nodejs and npm to be installed first. ```bash $ sudo npm install -g rtlcss ``` -------------------------------- ### QWeb t-call with Parameters (New Parametric Syntax) Source: https://www.odoo.com/documentation/19.0/developer/howtos/website_themes/layout.html Demonstrates the modern, parametric way to pass arguments to a QWeb `t-call` directive directly as attributes on the `t-call` tag. ```xml ``` -------------------------------- ### Example Python function with ipdb breakpoint Source: https://www.odoo.com/documentation/19.0/developer/tutorials/setup_guide.html An example of a Python method with an ipdb breakpoint inserted for debugging purposes. ```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) ``` -------------------------------- ### Include User Sign-in Link (QWeb) Source: https://www.odoo.com/documentation/19.0/developer/howtos/website_themes/layout.html Render the user sign-in link using the "portal.placeholder_user_sign_in" template. Custom classes can be applied to the item and link for styling. ```QWeb XML ``` -------------------------------- ### Example `default` parameter for `Model.copy()` Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/orm.html Illustrates the dictionary format for the `default` parameter in `Model.copy()`, used to specify field values to override during record duplication. ```python {'field_name': overridden_value, ...} ``` -------------------------------- ### Define Window Action to Launch a Wizard (XML) Source: https://www.odoo.com/documentation/19.0/developer/tutorials/backend.html This XML record defines a window action to launch a wizard. Set "target" to "new" to open it in a dialog and "binding_model_id" to link it to a specific model's action menu. ```xml Launch the Wizard wizard.model.name form new ``` -------------------------------- ### Multiple Create Buttons with Context in `control` Element Source: https://www.odoo.com/documentation/19.0/developer/reference/user_interface/view_architectures.html This example shows how to define multiple `create` buttons within a `control` element, each with a specific string and context for different record types. ```xml ``` -------------------------------- ### Starting a JavaScript Tour from Python Test Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/testing.html Shows how to initiate a registered JavaScript tour from a Python test method. The test class must inherit from `HTTPCase` to use the `start_tour` method. ```python def test_your_test(self): # Optional Setup self.start_tour("/web", "your_tour_name", login="admin") # Optional verifications ``` -------------------------------- ### Define Advanced Web Tour Step with Async Run Function Source: https://www.odoo.com/documentation/19.0/es_419/developer/reference/backend/testing.html Demonstrates a tour step with conditional activation (`isActive`), custom content, tooltip positioning, and an asynchronous `run` function for more complex interactions. ```javascript { isActive: ["mobile", "enterprise"], content: "Click on Add a product link", trigger: 'a:contains("Add a product")', tooltipPosition: "bottom", async run(helpers) { //Exactly the same as run: "click" helpers.click(); } }, ``` -------------------------------- ### Basic IoT Interface Implementation Source: https://www.odoo.com/documentation/19.0/developer/howtos/connect_device.html This code demonstrates how to create a new IoT Interface by extending the `Interface` class, setting the `connection_type`, and implementing the `get_devices` method to return detected devices. ```python from odoo.addons.hw_drivers.interface import Interface class InterfaceName(Interface): connection_type = 'ConnectionType' def get_devices(self): return { 'device_identifier_1': {...}, ... } ``` -------------------------------- ### Open Customers with List and Form Views (ir.actions.act_window) Source: https://www.odoo.com/documentation/19.0/es_419/developer/reference/backend/actions.html This action opens the `res.partner` model, displaying customers with both list and form views, filtered to show only partners marked as customers. ```json { "type": "ir.actions.act_window", "res_model": "res.partner", "views": [[False, "list"], [False, "form"]], "domain": [["customer", "=", true]] } ``` -------------------------------- ### Successful API Response Example Source: https://www.odoo.com/documentation/19.0/developer/reference/external_api.html Example of a successful API response, returning a 200 OK status with the JSON-serialized result of the called method. ```HTTP HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 [ {"id": 25, "name": "Deco Addict"} ] ``` -------------------------------- ### Define Module File Structure for Onboarding Tour Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/testing.html Illustrates the recommended directory and file layout for integrating a custom onboarding tour into an Odoo module, including the XML definition and JavaScript tour file. ```plaintext your_module ├── ... ├── data | └── your_tour.xml ├── static/src/js/tours/your_tour.js └── __manifest__.py ``` -------------------------------- ### odoo-bin module forcedemo Source: https://www.odoo.com/documentation/19.0/developer/reference/cli.html Forces the installation of Demo Data. Once installed, there is no way to undo it, so you might want to save a backup of the database first. ```APIDOC ## module forcedemo ### Description This command forces the installation of Demo Data. Once installed, there is no way to undo it, so you might want to save a backup of the database first. ### Syntax `odoo-bin module forcedemo` ``` -------------------------------- ### Verify Database Table Creation with psql Source: https://www.odoo.com/documentation/19.0/developer/tutorials/getting_started/04_basicmodel.html Use this command to connect to the PostgreSQL database and verify the existence and initial state of the `estate_property` table after model definition. ```shell $ psql -d rd-demo rd-demo=# SELECT COUNT(*) FROM estate_property; count ------- 0 (1 row) ``` -------------------------------- ### Install Odoo .deb Package on Ubuntu Source: https://www.odoo.com/documentation/19.0/administration/on_premise/packages.html Update package lists and install a downloaded Odoo .deb package as root on Ubuntu systems. ```bash # apt update # apt install ``` -------------------------------- ### Create mock environment with makeMockEnv Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/unit_testing/web_helpers.html Creates a pre-configured env object with all necessary properties for web components, spawns a MockServer, starts registered services, and handles teardown. Only one env can be active per test. ```javascript // Can be further configured, but is already packed with all the necessary stuff const env = await makeMockEnv(); expect(env.isSmall).toBe(false); ``` -------------------------------- ### Scheduled Action Code Example Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/actions.html This snippet shows a basic example of the 'code' field for a scheduled action, demonstrating how to call a method on a specified model. ```python model.() ``` -------------------------------- ### Install Command Line Tools on Mac OS Source: https://www.odoo.com/documentation/19.0/administration/on_premise/source.html Installs Xcode Command Line Tools required for compiling non-Python dependencies on Mac OS. ```bash $ xcode-select --install ``` -------------------------------- ### Register tour with XML record Source: https://www.odoo.com/documentation/19.0/developer/tutorials/importable_modules.html Create an XML record in the data folder to register the tour and configure its display properties including name, sequence, and welcome message. ```xml estate_tour 2 Welcome! Happy exploring. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.