### Clone the Example Module
Source: https://www.odoo.com/documentation/19.0/developer/tutorials/web.html
Download the example module 'petstore' to begin customization. Ensure Odoo's addons path is updated and the module is installed.
```bash
$ git clone http://github.com/odoo/petstore
```
--------------------------------
### Register a Tour
Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/testing.html
Register a tour by providing its name, the starting URL, and the sequence of steps. This is the initial setup for any 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
]);
```
--------------------------------
### Install Custom Module via Script
Source: https://www.odoo.com/documentation/19.0/developer/tutorials/website_theme/01_theming.html
This command installs your custom theme module and ensures it's applied to the specified database. Adjust the --addons-path and --db-filter as needed for your setup.
```bash
./odoo-bin --addons-path=../enterprise,addons,../myprojects --db-filter=theming -d theming
--without-demo=True -i website_airproof --dev=xml
```
--------------------------------
### Settings View Example
Source: https://www.odoo.com/documentation/19.0/developer/reference/user_interface/view_architectures.html
An example of a settings view structure using `app`, `setting`, and `block` elements.
```xml
This is a different setting
```
--------------------------------
### Describe Block Example
Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/unit_testing/hoot.html
Demonstrates how to group tests within a suite using the `describe` function, allowing for setup and organization.
```javascript
import { describe, expect, test } from "@odoo/hoot";
describe("My first suite", () => {
test("My first test", () => {
expect(2 + 2).toBe(4);
});
});
```
--------------------------------
### Patch Owl Component Setup Method
Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/patching_code.html
Illustrates patching the `setup` method of an Owl component to integrate custom hooks or logic. This follows the best practice of using `setup` for patchable extensions.
```javascript
patch(MyComponent.prototype, {
setup() {
useMyHook();
},
});
```
--------------------------------
### Force Demo Data Install
Source: https://www.odoo.com/documentation/19.0/developer/reference/cli.html
Forces the installation of demo data for modules. This action is irreversible and a database backup is recommended beforehand.
```bash
$ odoo-bin module forcedemo
```
--------------------------------
### Correct vs. Incorrect Component Setup Method
Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/owl_components.html
Illustrates the correct way to initialize an Owl component using the `setup` method, and warns against using the `constructor` directly.
```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
}
}
```
--------------------------------
### Querying Other Models via Environment
Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/orm.html
You can use the environment to query other models. This example shows how to get an empty recordset for 'res.partner' and then search for companies that are also customers.
```python
>>> self.env['res.partner']
res.partner()
>>> self.env['res.partner'].search([('is_company', '=', True), ('customer', '=', True)])
res.partner(7, 18, 12, 14, 17, 19, 8, 31, 26, 16, 13, 20, 30, 22, 29, 15, 23, 28, 74)
```
--------------------------------
### Map View Configuration Example
Source: https://www.odoo.com/documentation/19.0/developer/reference/user_interface/view_architectures.html
This example demonstrates how to configure a map view, specifying the partner ID, default order, and enabling routing. It also shows how to display custom field information in the pin's popup.
```xml
```
--------------------------------
### Start the Odoo Server
Source: https://www.odoo.com/documentation/19.0/developer/tutorials/backend.html
Invoke the odoo-bin command in the shell to start the Odoo server. Ensure the full path to the file is provided if necessary.
```bash
odoo-bin
```
--------------------------------
### Example Header with Button and Status Field
Source: https://www.odoo.com/documentation/19.0/developer/reference/user_interface/view_architectures.html
An example of a header containing a reset button and a status bar field.
```xml
```
--------------------------------
### Install Demo Data via Command Line
Source: https://www.odoo.com/documentation/19.0/developer/tutorials/define_module_data.html
Use the `--with-demo` flag when running Odoo to install demo data in new databases. This is useful for setting up databases with sample content for testing or demonstration.
```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
```
--------------------------------
### Example Footer with Standard and Custom Buttons
Source: https://www.odoo.com/documentation/19.0/developer/reference/user_interface/view_architectures.html
Demonstrates a footer with save, custom action, and discard buttons.
```xml
```
--------------------------------
### Start Tour from Python Test
Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/testing.html
Initiates a tour from a Python test case by inheriting from HTTPCase and calling the start_tour method. Optional setup and verifications can be added.
```python
def test_your_test(self):
# Optional Setup
self.start_tour("/web", "your_tour_name", login="admin")
# Optional verifications
```
--------------------------------
### Defining Post-Install and At-Install Tests
Source: https://www.odoo.com/documentation/19.0/developer/tutorials/unit_tests.html
Demonstrates how to use the `tagged` decorator to specify when tests should run. 'post_install' tests run after all modules are installed, while 'at_install' (the default) run during module installation.
```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):
...
```
--------------------------------
### Dashboard Component Setup
Source: https://www.odoo.com/documentation/19.0/developer/tutorials/discover_js_framework/02_build_a_dashboard.html
Initializes the `items` property within the dashboard component's setup method.
```javascript
setup() {
this.items = items;
}
```
--------------------------------
### Install Modules
Source: https://www.odoo.com/documentation/19.0/developer/reference/cli.html
Installs a list of specified modules into the Odoo database. Ensure the database is initialized before running this command.
```bash
$ odoo-bin module install
```
--------------------------------
### Basic Test Example
Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/unit_testing/hoot.html
A simple example demonstrating how to write a basic test case using the `test` function and the `expect` assertion.
```javascript
import { expect, test } from "@odoo/hoot";
test("My first test", () => {
expect(2 + 2).toBe(4);
});
```
--------------------------------
### Install ipdb Debugger
Source: https://www.odoo.com/documentation/19.0/developer/tutorials/setup_guide.html
Install the ipdb library using pip. This is the first step to enable advanced debugging capabilities.
```bash
pip install ipdb
```
--------------------------------
### Example Code Upgrade Script
Source: https://www.odoo.com/documentation/19.0/developer/reference/cli.html
An example Python script for the 'upgrade_code' command. This script iterates through Python files in an addon and performs content replacements.
```python
def upgrade(file_manager):
files = (file for file in file_manager if file.path.suffix == '.py')
for fileno, file in enumerate(files, start=1):
file.content = file.content.replace(..., ...)
file_manager.print_progress(fileno, len(files))
```
--------------------------------
### Configured Search View Example
Source: https://www.odoo.com/documentation/19.0/developer/reference/user_interface/view_architectures.html
An example of a search view with multiple fields configured with custom strings, filter domains, and other attributes. The 'ref' field uses a 'like' operator within its filter domain.
```xml
```
--------------------------------
### Start Tour with Debug Mode
Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/testing.html
Launches a tour with browser devtools open and a debugger breakpoint at the start for detailed debugging. Requires `debug=True` parameter.
```python
self.start_tour("/web", "your_tour_name", debug=True)
```
--------------------------------
### Kanban Header Button Examples
Source: https://www.odoo.com/documentation/19.0/developer/reference/user_interface/view_architectures.html
Demonstrates adding buttons to the kanban header, specifying their display mode ('always' or 'display').
```XML
```
--------------------------------
### Install Upgrade utils via pip
Source: https://www.odoo.com/documentation/19.0/developer/reference/upgrades/upgrade_utils.html
Install the upgrade-util library from GitHub using pip. This is suitable for environments where Odoo is managed via pip.
```bash
$ python3 -m pip install git+https://github.com/odoo/upgrade-util@master
```
--------------------------------
### Classical Inheritance: Usage Example
Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/orm.html
Demonstrates creating records from 'inheritance.0' and 'inheritance.1' and calling their respective 'call' methods.
```python
a = env['inheritance.0'].create({'name': 'A'})
b = env['inheritance.1'].create({'name': 'B'})
a.call()
b.call()
```
--------------------------------
### Patch Class Setup Method with Super
Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/patching_code.html
Provides a workaround for patching constructors by patching a method called within the constructor. Uses `super` to call the original `setup` method and extends its functionality.
```javascript
class MyClass {
constructor() {
this.setup();
}
setup() {
this.number = 1;
}
}
patch(MyClass.prototype, {
setup() {
super.setup(...arguments);
this.doubleNumber = this.number * 2;
},
});
```
--------------------------------
### db init - Initialize a Database
Source: https://www.odoo.com/documentation/19.0/developer/reference/cli.html
Creates a new database and installs the `base` module. Allows specifying the language and country of the main company.
```APIDOC
## db init - Initialize a Database
### Description
Creates a new database and installs the `base` module. You can specify the language and country of the main company.
### Usage
```bash
odoo-bin db init
```
### Parameters
#### Path Parameters
* **database** (string) - Required - Name of the database to be initialized.
#### Options
* `--with-demo`: Install demo data in the initialized database.
* `--force`: Delete the database if it already exists, before initializing the new one.
* `--country `: Code of the country to be set on the main company.
* `--language `: Default language for the instance, default `en_US`.
* `--username `: Username for the new database, default `admin`.
* `--password `: Password for the new database, default `admin`.
```
--------------------------------
### Get Partner IDs (Python ORM)
Source: https://www.odoo.com/documentation/19.0/developer/reference/external_api.html
Example of retrieving partner IDs using Odoo's internal Python ORM with context.
```python
Model = self.env["res.partner"].with_context({"lang": "en_US"})
records = Model.search([("name", "ilike", "%deco%"), ("is_company", "=", True)])
return json.dumps(records.ids)
```
--------------------------------
### Business Trip Model with Alias Integration
Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/mixins.html
Example of a Business Trip model inheriting 'mail.thread' and 'mail.alias.mixin', demonstrating the setup for alias integration.
```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
```
--------------------------------
### Get Start of Time Period
Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/orm.html
The `fields.Date.start_of()` method calculates the beginning of a specified period (year, month, week, etc.) from a given date or datetime object.
```python
fields.Date.start_of(value, granularity='month')
```
--------------------------------
### Basic Owl Component Definition
Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/owl_components.html
Defines a simple Owl component with inline template, state management, and an event handler. This is useful for getting started with Owl.
```javascript
import { Component, xml, useState } from "@odoo/owl";
class MyComponent extends Component {
static template = xml`
`;
setup() {
this.state = useState({ value: 1 });
}
increment() {
this.state.value++;
}
}
```
--------------------------------
### QWeb template rendering with parameters (Old Way)
Source: https://www.odoo.com/documentation/19.0/developer/howtos/website_themes/layout.html
Demonstrates the older syntax for calling QWeb templates and passing parameters using t-set directives.
```xml
My page title
```
--------------------------------
### Basic Cohort View Configuration
Source: https://www.odoo.com/documentation/19.0/developer/reference/user_interface/view_architectures.html
A simple example of a cohort view definition. It specifies the title, start date field, end date field, and the time interval for analysis.
```xml
```
--------------------------------
### Odoo Configuration File Example
Source: https://www.odoo.com/documentation/19.0/developer/reference/cli.html
A sample Odoo configuration file showing how to set database user and filter options.
```ini
[options]
db_user=odoo
dbfilter=odoo
```
--------------------------------
### Defining Constraints and Indexes in Odoo Models
Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/orm.html
Example of defining a CHECK constraint and a database index on model fields. The attribute names must start with an underscore to avoid clashes with field names.
```python
class AModel(models.Model):
_name = 'a.model'
_my_check = models.Constraint("CHECK (x > y)", "x > y is not true")
_name_idx = models.Index("(last_name, first_name)")
```
--------------------------------
### Get Odoo Version (HTTP GET)
Source: https://www.odoo.com/documentation/19.0/developer/reference/external_api.html
Demonstrates how to retrieve the Odoo version using an HTTP GET request to the /web/version endpoint.
```http
GET /web/version HTTP/1.1
```
```json
HTTP/1.1 200 OK
Content-Type: application/json
{"version_info": [19, 0, 0, "final", 0, ""], "version": "19.0"}
```
--------------------------------
### Application Mount Setup
Source: https://www.odoo.com/documentation/19.0/developer/howtos/standalone_owl_application.html
Set up the JavaScript code to mount the root component when the application is ready. This file handles the initialization and rendering of the Owl application into the document body.
```javascript
import { whenReady } from "@odoo/owl";
import { mountComponent } from "@web/env";
import { Root } from "./root";
whenReady(() => mountComponent(Root, document.body));
```
--------------------------------
### JSON-RPC Request Example
Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/http.html
Example of a JSON-RPC request being sent to the server.
```json
--> {"jsonrpc": "2.0", "method": "call", "params": {"arg1": "val1" }, "id": null}
```
--------------------------------
### Listen to Web Client Ready Event
Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/framework_overview.html
Subscribe to the 'WEB_CLIENT_READY' event on the environment's bus to execute a function when the web client is fully mounted. This is useful for performing actions that depend on the client being ready.
```javascript
env.bus.on("WEB_CLIENT_READY", null, doSomething);
```
--------------------------------
### QWeb template rendering with parameters (New Way)
Source: https://www.odoo.com/documentation/19.0/developer/howtos/website_themes/layout.html
Illustrates the modern, parametric syntax for calling QWeb templates and passing parameters directly as attributes.
```xml
```
--------------------------------
### Get Current Datetime
Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/orm.html
Use `fields.Datetime.now()` to get the current date and time in the format expected by the Odoo ORM.
```python
fields.Datetime.now()
```
--------------------------------
### Creating and Using a Basic Registry
Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/registries.html
Demonstrates how to create a new registry, add an entry, and retrieve it. This is useful for managing custom configurations or data within the web client.
```javascript
import { Registry } from "@web/core/registry";
const myRegistry = new Registry();
myRegistry.add("hello", "odoo");
console.log(myRegistry.get("hello"));
```
--------------------------------
### Start Tour with Watch Mode
Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/testing.html
Launches a tour in a browser window for observation during local testing. Requires `watch=True` parameter.
```python
self.start_tour("/web", "your_tour_name", watch=True)
```
--------------------------------
### Open Customers with List and Form Views
Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/actions.html
Use this window action to display a list of customers (partners with the 'customer' flag set) and allow opening their form view. It specifies the model, views, and a domain for filtering.
```python
{
"type": "ir.actions.act_window",
"res_model": "res.partner",
"views": [[False, "list"], [False, "form"]],
"domain": [["customer", "=", true]],
}
```
--------------------------------
### Registering a Custom Service with Dependencies
Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/framework_overview.html
This example demonstrates how to register a custom service named 'myService'. It includes a dependency on the 'notification' service and uses setInterval to periodically add 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);
```
--------------------------------
### Directory Structure Example for Upgrade Script
Source: https://www.odoo.com/documentation/19.0/developer/reference/upgrades/upgrade_scripts.html
Illustrates the expected directory layout for an upgrade script within a custom Odoo module.
```text
awesome_partner/
|-- migrations/
| |-- 17.0.2.0/
| | |-- pre-exclamation.py
```
--------------------------------
### Date Filter with Start Year Offset
Source: https://www.odoo.com/documentation/19.0/developer/reference/user_interface/view_architectures.html
Configures a date filter to show years starting from an offset relative to the current year.
```xml
```
--------------------------------
### Date Filter with Start Month Offset
Source: https://www.odoo.com/documentation/19.0/developer/reference/user_interface/view_architectures.html
Configures a date filter to show months starting from an offset relative to the current month.
```xml
```
--------------------------------
### Odoo Unit Test Class Setup
Source: https://www.odoo.com/documentation/19.0/developer/tutorials/unit_tests.html
Demonstrates setting up a test class that extends Odoo's TransactionCase. It shows how to use setUpClass to create common test data for multiple test methods, improving efficiency.
```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([...])
```
--------------------------------
### Configure Date Range Start Date Field
Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/javascript_reference.html
Specify the 'start_date_field' option to link a daterange widget to a specific field for the start date.
```xml
```
--------------------------------
### Manifest Configuration for Onboarding Tour
Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/testing.html
Updates the `__manifest__.py` file to include the tour's XML data and JavaScript assets for backend loading.
```python
'data': [
'data/your_tour.xml',
],
'assets': {
'web.assets_backend': [
'your_module/static/src/js/tours/your_tour.js',
],
},
```
--------------------------------
### Creating QWeb Views with
Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/data.html
Use the tag to create a QWeb view with minimal configuration. It requires the 'arch' section and supports optional attributes like 'id', 'name', 'inherit_id', 'priority', 'groups', and 'active'.
```xml
New Content
```
--------------------------------
### Get Current Date for ORM
Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/orm.html
Use `fields.Date._today()` to get the current day in the format expected by the Odoo ORM, often used for default values.
```python
fields.Date._today()
```
--------------------------------
### Launch Odoo Server
Source: https://www.odoo.com/documentation/19.0/developer/tutorials/setup_guide.html
Launch the Odoo server with specified addons paths and database. Ensure you are in the Odoo source directory.
```bash
cd $HOME/src/odoo/
./odoo-bin --addons-path="addons/,../enterprise/,../tutorials" -d rd-demo
```
--------------------------------
### SCSS Theme Example
Source: https://www.odoo.com/documentation/19.0/developer/howtos/website_themes/theming.html
Example of SCSS code that can be added to your theme file, utilizing Bootstrap variables and Odoo's color and font functions.
```scss
blockquote {
border-radius: $rounded-pill;
color: o-color('o-color-3');
font-family: o-website-value('headings-font');
}
```
--------------------------------
### Complete SVG Image Shape Example
Source: https://www.odoo.com/documentation/19.0/developer/howtos/website_themes/shapes.html
This is a complete example of an SVG file used for an image shape, including definitions for masks and decorative elements.
```svg
```
--------------------------------
### Create and Query Custom Model (Python)
Source: https://www.odoo.com/documentation/19.0/developer/reference/external_rpc_api.html
Demonstrates creating a custom model named 'x_custom_model' and then retrieving its field definitions using the `fields_get` method. Ensure the model state is set to 'manual' for custom models.
```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']})
```
--------------------------------
### Basic SelectMenu with Choices and Groups
Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/owl_components.html
This example demonstrates the basic usage of the SelectMenu component, displaying predefined choices and organizing them into groups.
```javascript
import { Component, xml } from "@odoo/owl";
import { SelectMenu } from "@web/core/select_menu/select_menu";
class MyComponent extends Component {
static template = xml`
`;
get choices() {
return [
{
value: "value_1",
label: "First value"
}
]
}
get groups() {
return [
{
label: "Group A",
choices: [
{
value: "value_2",
label: "Second value"
},
{
value: "value_3",
label: "Third value"
}
]
},
{
label: "Group B",
choices: [
{
value: "value_4",
label: "Fourth value"
}
]
}
]
}
}
```
--------------------------------
### Populate a Database with Data
Source: https://www.odoo.com/documentation/19.0/developer/reference/cli.html
Use the 'populate' command to duplicate existing data in a database for testing. Specify the database, models, and duplication factors.
```bash
$ odoo-bin populate -d my_database --models res.partner,account.move --factors 1000
```
--------------------------------
### Using RPC Service in a Component
Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/services.html
This example shows how to use the `rpc` service within a component's `onWillStart` lifecycle hook to perform an asynchronous operation.
```javascript
import { rpc } from "@web/core/network/rpc";
class MyComponent extends Component {
setup() {
onWillStart(async () => {
const result = await rpc(...);
})
}
}
```
--------------------------------
### Get Test Database Credentials (PHP)
Source: https://www.odoo.com/documentation/19.0/developer/reference/external_rpc_api.html
Use the Ripcord library in PHP to get test database credentials. Ensure XML-RPC and OpenSSL extensions are enabled.
```php
require_once('ripcord.php');
$info = ripcord::client('https://demo.odoo.com/start')->start();
list($url, $db, $username, $password) = array($info['host'], $info['database'], $info['user'], $info['password']);
```
--------------------------------
### TransactionCase
Source: https://www.odoo.com/documentation/19.0/developer/reference/backend/testing.html
A test case class where each test method runs in a sub-transaction. Database setup common to all methods should be in `setUpClass`. Useful for tests with significant database setup.
```APIDOC
## Class _odoo.tests.TransactionCase
### Description
Test class in which all test methods are run in a single transaction, but each test method is run in a sub-transaction managed by a savepoint. The transaction’s cursor is always closed without committing.
### Class Methods
* **setUpClass**(): Data setup common to all methods should be done here.
### Methods
* **browse_ref**(_xid_)
* Returns a record object for the provided external identifier.
* Parameters:
* **xid** (string) - Fully-qualified external identifier, in the form `{module}.{identifier}`.
* Raises:
* ValueError if not found.
* Returns:
* `BaseModel` record object.
* **ref**(_xid_)
* Returns database ID for the provided external identifier, shortcut for `_xmlid_lookup`.
* Parameters:
* **xid** (string) - Fully-qualified external identifier, in the form `{module}.{identifier}`.
* Raises:
* ValueError if not found.
* Returns:
* registered id.
* **setUp**()
* Cleans up the record cache and the registry cache after each test method.
* **tearDown**()
* If a test modifies the registry (custom models and/or fields), it should prepare the necessary cleanup (`self.registry.reset_changes()`).
```
--------------------------------
### Instantiate and Use a Class
Source: https://www.odoo.com/documentation/19.0/developer/tutorials/web.html
Create an instance of a class using the 'new' operator and call its methods.
```javascript
var my_object = new MyClass();
my_object.say_hello();
// print "hello" in the console
```
--------------------------------
### Start New Group Rows with newline
Source: https://www.odoo.com/documentation/19.0/developer/reference/user_interface/view_architectures.html
Use the `newline` element within group elements to end the current row early and start a new one.
```xml
```
--------------------------------
### Native Javascript Module Example
Source: https://www.odoo.com/documentation/19.0/developer/reference/frontend/javascript_modules.html
Example of a native Javascript module using import and export syntax. Files in /static/src and /static/tests are transpiled into Odoo modules by default.
```javascript
import { someFunction } from "./file_b";
export function otherFunction(val) {
return someFunction(val + 3);
}
```
--------------------------------
### Create Theme Module Directory
Source: https://www.odoo.com/documentation/19.0/developer/howtos/website_themes/theming.html
When creating a new theme, prefix the directory name with 'website_' and use only lowercase ASCII alphanumeric characters and underscores.
```bash
website_airproof
```
--------------------------------
### Call Placeholder for User Sign In
Source: https://www.odoo.com/documentation/19.0/developer/howtos/website_themes/layout.html
Integrate a sign-in link or button into your header using the `portal.placeholder_user_sign_in` QWeb template. This provides a standard entry point for user authentication.
```xml
```
--------------------------------
### XPath Position Attribute Examples
Source: https://www.odoo.com/documentation/19.0/developer/tutorials/server_framework_101/12_inheritance.html
Demonstrates different `position` attributes within an `xpath` expression for view inheritance. These examples show how to insert elements relative to a matched element.
```xml
```
--------------------------------
### Deploy Module Remotely
Source: https://www.odoo.com/documentation/19.0/developer/reference/cli.html
Uploads and installs a module on a remote Odoo server using administrative credentials. Ensure the 'base_import_module' is installed on the server and the login user has admin rights.
```bash
$ odoo-bin deploy --db --login --password
```