0% found this document useful (0 votes)
5 views12 pages

Unit 4

The document provides an overview of Object-Relational Mapping (ORM) in Odoo, detailing its benefits and traditional methods for database operations such as create, read, update, and delete. It also covers advanced ORM methods, API decorations, and relational field operations, along with examples for better understanding. Additionally, it highlights the differences between Odoo versions and the importance of using the GUI for data management.

Uploaded by

mparma2006
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views12 pages

Unit 4

The document provides an overview of Object-Relational Mapping (ORM) in Odoo, detailing its benefits and traditional methods for database operations such as create, read, update, and delete. It also covers advanced ORM methods, API decorations, and relational field operations, along with examples for better understanding. Additionally, it highlights the differences between Odoo versions and the importance of using the GUI for data management.

Uploaded by

mparma2006
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Course Code:- 3040233207

Course Name:- Integrated Web


Solutions with Django and Basic of
Odoo

Unit No:- 4 Traditional ORM methods

SEMESTER: 4
PREPARED BY: Ms. Kiran Rajput
Introduction to ORM in Odoo

•What is ORM?
• Object-Relational Mapping
• Facilitates interaction between Python objects and
database tables

•Benefits of ORM:
• Simplifies database operations
• Reduces boilerplate code

2
Traditional ORM Methods

•Basic ORM Operations:


•Create: create()
•Read: search(), browse()
•Update: write()
•Delete: unlink()

•Example:

record = self.env['model.name'].create({'field_name': 'value'})

3
Advanced ORM Methods

•Advanced Operations:
•Search Read: search_read()
•Copy: copy()
•Get: get()

•Example:

records = self.env['model.name'].search_read([('field_name', '=',


'value')])

4
Procedure from the GUI

•Using the Odoo GUI:


• Navigate to the desired model
• Use the interface to create, read, update, or delete
records

•Follow-Up Method:
• Review changes in the database through the GUI
• Validate data integrity and relationships

5
API Decorations in Odoo

•What are API Decorations?


•Annotations that modify the behavior of methods and
fields

•Common API Decorations:

•@api.model
•@api.multi
•@api.depends
•@api.onchange

6
Differences Between Versions

•Version Changes:
• New features and deprecations in
different Odoo versions
•Key Differences:
• Changes in API methods and
behavior
• Migration considerations for
upgrading

7
Odoo Calls

•What are Odoo Calls?


•Methods to interact with Odoo models and
data

•Common Calls:

•self.env['model.name']
•self.browse()
•self.search()

8
Most Used API Decorations

•Overview of Commonly Used Decorations:

•@api.model: For methods that do not depend on a specific


record
•@api.multi: For methods that can operate on multiple
records
•@api.depends: For computed fields that depend on other
fields
•@api.onchange: For methods that trigger when a field
changes

9
Relational Field Operations with the API

•Working with Relational Fields:

•Many2one: Accessing related records


•One2many: Managing child records
•Many2many: Handling multiple relationships

•Example:

partner = self.env['res.partner'].browse(partner_id)
orders = partner.order_ids

10
Review of Commonly Used ORM Methods

•Summary of Key ORM Methods:

•create(): Create a new record


•search(): Find records based on criteria
•write(): Update existing records
•unlink(): Delete records
•search_read(): Retrieve records and their data in
one call

11
PMS Editing and Expression

•What is PMS Editing?


•Process of modifying records in Odoo using the ORM

•Using Expressions:
•Filtering and searching using domain expressions

•Example:

records = self.env['model.name'].search([('field_name', 'ilike',


'value')])

12

You might also like