### Install and Configure PostgreSQL on Fedora Source: https://github.com/odoo/documentation/blob/19.0/content/administration/on_premise/packages.rst Installs the PostgreSQL server on Fedora, initializes the database, and enables it to start on boot. ```console $ sudo dnf install -y postgresql-server $ sudo postgresql-setup --initdb --unit postgresql $ sudo systemctl enable postgresql $ sudo systemctl start postgresql ``` -------------------------------- ### Use RPC service in a component Source: https://github.com/odoo/documentation/blob/19.0/content/developer/reference/frontend/services.rst This example demonstrates how to use the 'rpc' service within a component's setup to perform an asynchronous operation. The `onWillStart` hook is used to ensure the RPC call is made before the component is fully rendered. ```javascript import { rpc } from "@web/core/network/rpc"; class MyComponent extends Component { setup() { onWillStart(async () => { const result = await rpc(...); }) } } ``` -------------------------------- ### Send HTTP GET and POST Requests using Http Service Source: https://github.com/odoo/documentation/blob/19.0/content/developer/reference/frontend/services.rst This example shows how to utilize the http service to perform GET and POST requests. It includes sending parameters with POST requests. Ensure the http service is available in your context. ```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" }); ``` -------------------------------- ### Install Upgrade Utils via Console Source: https://github.com/odoo/documentation/blob/19.0/content/developer/reference/upgrades/upgrade_utils.rst Clone the repository locally and prepend the src directory to the --upgrade-path option when starting Odoo. ```console $ ./odoo-bin --upgrade-path=/path/to/upgrade-util/src,/path/to/other/upgrade/script/directory [...] ``` -------------------------------- ### Install Documentation Dependencies Source: https://github.com/odoo/documentation/blob/19.0/content/contributing/documentation.rst Install the Python dependencies required for the documentation using pip. ```console $ pip install -r requirements.txt ``` -------------------------------- ### Install PostgreSQL (Linux) Source: https://github.com/odoo/documentation/blob/19.0/content/administration/on_premise/source.rst Install PostgreSQL and its client using the apt package manager on Linux. Supported versions are 13.0 or above. ```console $ sudo apt install postgresql postgresql-client ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/odoo/documentation/blob/19.0/README.md Installs the necessary Python dependencies for building the documentation from the requirements.txt file. ```bash pip install -r requirements.txt ``` -------------------------------- ### Build Documentation (Basic) Source: https://github.com/odoo/documentation/blob/19.0/README.md Builds the HTML documentation. Use 'make help' for a list of all available commands. ```bash make html ``` -------------------------------- ### Owl Component Setup Method Source: https://github.com/odoo/documentation/blob/19.0/content/developer/reference/frontend/owl_components.rst Demonstrates the correct way to initialize an Owl component using the `setup` method. Avoid using the `constructor` for component initialization. ```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 } } ``` -------------------------------- ### NGINX Root and Try_files for Git Source Installation Source: https://github.com/odoo/documentation/blob/19.0/content/administration/on_premise/deploy.rst Example Nginx configuration for 'root' and 'try_files' directives when Odoo is installed from Git sources. ```nginx root /opt/odoo; try_files /community/odoo/addons$uri /community/addons$uri /enterprise$uri @odoo; ``` -------------------------------- ### Build Documentation (Fast) Source: https://github.com/odoo/documentation/blob/19.0/README.md Builds the documentation with a shallow menu, which is faster. ```bash make fast ``` -------------------------------- ### NGINX Root and Try_files for Debian Package Installation Source: https://github.com/odoo/documentation/blob/19.0/content/administration/on_premise/deploy.rst Example Nginx configuration for 'root' and 'try_files' directives when Odoo is installed via Debian packages. ```nginx root /usr/lib/python3/dist-packages/odoo/addons; try_files $uri @odoo; ``` -------------------------------- ### Get Test Database Credentials Source: https://github.com/odoo/documentation/blob/19.0/content/developer/reference/external_rpc_api.rst This snippet shows how to retrieve credentials for a demo Odoo database using the 'start' method. ```APIDOC ## Get Test Database Credentials ### Description This operation retrieves connection details for a demo Odoo database. ### Method POST (Implicit via XML-RPC call) ### Endpoint https://demo.odoo.com/start ### Parameters None explicitly listed for the 'start' method itself, but it returns connection details. ### Request Example (No direct request body example, as it's an XML-RPC call to a method) ### Response #### Success Response - **host** (string) - The URL of the Odoo instance. - **database** (string) - The name of the database. - **user** (string) - The username for authentication. - **password** (string) - The password for authentication. #### Response Example ```json { "host": "https://your-odoo-instance.com", "database": "your_db_name", "user": "your_username", "password": "your_password" } ``` ``` -------------------------------- ### Directory Structure Example Source: https://github.com/odoo/documentation/blob/19.0/content/developer/reference/upgrades/upgrade_scripts.rst Illustrates the typical directory structure for an upgrade script within a custom module. ```text awesome_partner/ |-- migrations/ | |-- 17.0.2.0/ | | |-- pre-exclamation.py ``` -------------------------------- ### Opt-in Odoo Module Transpilation Source: https://github.com/odoo/documentation/blob/19.0/content/developer/reference/frontend/javascript_modules.rst Files not in `/static/src` or `/static/tests` are transpiled only if they start with `/** @odoo-module **/`. This example defines a simple sum function. ```javascript /** @odoo-module **/ export function sum(a, b) { return a + b; } ``` -------------------------------- ### Example Tour Steps: Show Apps Menu and Click Source: https://github.com/odoo/documentation/blob/19.0/content/developer/reference/backend/testing.rst Illustrates how to define steps within a tour. The first step uses a utility function to show the apps menu, and the second step clicks on a specific element identified by a CSS selector. ```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 }, ``` -------------------------------- ### WhatsApp Placeholder Configuration Example Source: https://github.com/odoo/documentation/blob/19.0/content/applications/productivity/whatsapp.rst Example demonstrating how to configure a placeholder like {{1}} in the Variables tab to populate the customer's name from the Partner field. ```text For example, in the :guilabel:`Body` tab, if the following is typed, "Hello {{1}},", then `{{1}}` must be set in the :guilabel:`Variables` tab. For this specific case, the message should greet the customer by name, so the `{{1}}` should be configured to populate the `{{1}}` :guilabel:`Field` with the :guilabel:`Customer` name. ``` -------------------------------- ### Numbered List Example in RST Source: https://github.com/odoo/documentation/blob/19.0/content/contributing/documentation/rst_guidelines.rst Illustrates how to create numbered lists in RST, including automatic numbering and starting with a specific number. ```rst #. This is a numbered list. #. Numbering is automatic. ``` ```text #. This is a numbered list. #. Numbering is automatic. ``` ```rst 6. Use this format to start the numbering with a number other than one. #. The numbering is automatic from there. ``` ```text 6. Use this format to start the numbering with a number other than one. #. The numbering is automatic from there. ``` -------------------------------- ### Good Example: Move and Add Elements Source: https://github.com/odoo/documentation/blob/19.0/content/developer/howtos/website_themes/layout.rst Demonstrates a correct way to move an element and then add another element before a target element. ```xml
``` -------------------------------- ### Menu Selection Markup in RST Source: https://github.com/odoo/documentation/blob/19.0/content/contributing/documentation/rst_guidelines.rst Use the `menuselection` markup to guide users through a sequence of menus, starting with the app's name. ```text To review sales performance, go to :menuselection:`Sales --> Reporting --> Dashboard`. ``` -------------------------------- ### Define Onboarding Tour in XML Source: https://github.com/odoo/documentation/blob/19.0/content/developer/reference/backend/testing.rst Create a record of type 'web_tour.tour' in an XML file to define an onboarding tour. This includes the tour's name, sequence, and optional rainbow man message. ```xml your_tour 10 Congrats, that was a great tour ``` -------------------------------- ### Run Odoo Server with Configuration Source: https://github.com/odoo/documentation/blob/19.0/content/developer/howtos/website_themes/setup.rst Example of running the Odoo server with specified addons paths, database filter, module initialization, development features, and without demo data. ```bash ./odoo-bin --addons-path=../enterprise,addons --db-filter= -d -i website --dev=xml --without-demo=True ``` -------------------------------- ### Get Test Database Credentials (Ruby) Source: https://github.com/odoo/documentation/blob/19.0/content/developer/reference/external_rpc_api.rst This Ruby code fetches connection information for a demo Odoo instance. Ensure the `xmlrpc/client` library is installed. ```ruby require "xmlrpc/client" info = XMLRPC::Client.new2('https://demo.odoo.com/start').call('start') url, db, username, password = info['host'], info['database'], info['user'], info['password'] ``` -------------------------------- ### SCSS Properties Order Example Source: https://github.com/odoo/documentation/blob/19.0/content/contributing/development/coding_guidelines.rst Illustrates the recommended order for SCSS properties, starting from 'position' and moving to decorative properties. Scoped and CSS variables should be 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); } ``` -------------------------------- ### Install Make on Linux Source: https://github.com/odoo/documentation/blob/19.0/content/contributing/documentation.rst Installs the Make utility on Linux systems using apt package manager. This is a prerequisite for certain build processes. ```console $ sudo apt install make -y ``` -------------------------------- ### Start Tour from Python Test Source: https://github.com/odoo/documentation/blob/19.0/content/developer/reference/backend/testing.rst Initiate a tour from a Python test class by inheriting from odoo.tests.HTTPCase and calling the start_tour method. Optional setup and verification steps can be included. ```python def test_your_test(self): # Optional Setup self.start_tour("/web", "your_tour_name", login="admin") # Optional verifications ``` -------------------------------- ### QWeb Call with Parameters (New Way) Source: https://github.com/odoo/documentation/blob/19.0/content/developer/howtos/website_themes/layout.rst Demonstrates the modern, parametric syntax for calling QWeb templates and passing values directly as attributes. ```xml ``` -------------------------------- ### Deploy Module with odoo-bin Source: https://github.com/odoo/documentation/blob/19.0/content/developer/tutorials/importable_modules.rst Demonstrates how to deploy a module to an Odoo instance using the odoo-bin command-line tool. The `--force` option is equivalent to the 'Force init' option in the web wizard. ```bash $ odoo-bin deploy https:// --login --password ``` -------------------------------- ### Get Test Database Credentials (Java) Source: https://github.com/odoo/documentation/blob/19.0/content/developer/reference/external_rpc_api.rst Java example using the Apache XML-RPC library to obtain demo Odoo database connection details. Imports are not included in this snippet. ```java final XmlRpcClient client = new XmlRpcClient(); final XmlRpcClientConfigImpl start_config = new XmlRpcClientConfigImpl(); start_config.setServerURL(new URL("https://demo.odoo.com/start")); final Map info = (Map)client.execute( start_config, "start", emptyList()); final String url = info.get("host"), db = info.get("database"), username = info.get("user"), password = info.get("password"); ``` -------------------------------- ### Set Default Company for Required Field Source: https://github.com/odoo/documentation/blob/19.0/content/developer/howtos/company.rst When `company_id` is required, set a default value to ensure validity and ease user setup. This example uses a lambda to fetch the current company. ```python from odoo import api, fields, models class Record(models.Model): _name = 'record.restricted' _check_company_auto = True company_id = fields.Many2one( 'res.company', required=True, default=lambda self: self.env.company ) other_record_id = fields.Many2one('other.record', check_company=True) ``` -------------------------------- ### Build Documentation with Version Switcher Source: https://github.com/odoo/documentation/blob/19.0/README.md Builds the documentation in the current version and enables the version switcher for specified available versions. This command must be invoked for each version you want to build. ```bash make html VERSIONS=17.0,18.0,saas-18.4,19.0,master ``` -------------------------------- ### Example Alert Block Source: https://github.com/odoo/documentation/blob/19.0/content/contributing/documentation/rst_guidelines.rst The `example` directive is used to present an example to the reader. It demonstrates a concept or usage. ```rst .. list-table:: :class: o-showcase-table * - .. example:: Use this alert block to show an example. * - .. code-block:: text .. example:: Use this alert block to show an example. ``` -------------------------------- ### Combined GUI and Menu Selection in RST Source: https://github.com/odoo/documentation/blob/19.0/content/contributing/documentation/rst_guidelines.rst Example demonstrating the correct usage of `menuselection` and `guilabel` markup for navigation and UI elements. ```text To configure the bill control policy, navigate to :menuselection:`Purchase --> Configuration --> Settings`, and scroll down to the :guilabel:`Invoicing` section. Under :guilabel:`Bill Control`, select either :guilabel:`Ordered quantities` or :guilabel:`Received quantities`. ``` -------------------------------- ### Settings View Example Source: https://github.com/odoo/documentation/blob/19.0/content/developer/reference/user_interface/view_architectures.rst Illustrates the structure of a settings view, including applications, setting groups, and individual settings with fields and buttons. ```xml