Odoo ORM Methods | Object Relational Mapping in Odoo15
CelineGeorge1
1,366 views
8 slides
Mar 04, 2022
Slide 1 of 8
1
2
3
4
5
6
7
8
About This Presentation
ORM(Object Relational Mapping) is a concept or technique which acts as a bridge between your programming language and your database. Object Relational Mapping helps to execute SQL queries without writing them explicitly. Once the ORM is configured in an application, the user can use the OOP concepts...
ORM(Object Relational Mapping) is a concept or technique which acts as a bridge between your programming language and your database. Object Relational Mapping helps to execute SQL queries without writing them explicitly. Once the ORM is configured in an application, the user can use the OOP concepts like classes and objects to interact with the database. ORM methods are one of its strong features which helps in executing SQL queries without writing them down explicitly. With the help of ORM methods, the user can implement the OOPS concepts to interact with the database. Odoo creates and manages tables for us inside the database. Thus reducing our work of creation of tables using the queries.
Size: 1.61 MB
Language: en
Added: Mar 04, 2022
Slides: 8 pages
Slide Content
Odoo ORM Methods www.cybrosys.com
INTRODUCTION ORM(Object Relational Mapping) is a concept or technique which acts as a bridge between your programming language and your database. The Object Relational Mapping helps to execute SQL queries without writing them explicitly. Once the ORM is configured in an application, the user can use the OOP concepts like classes and objects to interact with the database. ORM methods are one of its strong features which helps in executing SQL queries without writing them down explicitly. With the help of ORM methods, the user can implement the OOPS concepts to interact with the database. Odoo creates and manages tables for us inside the database. Thus reducing our work of creation of tables using the queries.
sorted ( ) The sorted() method returns the records inside the self, ordered by the key passed as the argument. Syntax: Model.sorted (key=None, reverse=False), If reverse is set as True, returns the result in reverse order. Eg : records.sorted (key=lambda r: r.name) - Sorts the record based on the name field.
mapped ( ) The mapped() function applies the function given as an argument on all the records in the self, and then returns the result as a list or recordset . This method accepts a function as its argument. Syntax: Model.mapped ( func ) ? recordset / list Eg : records.mapped (lambda r: r.field1 + r.field2) - This returns a list of summing two fields for each record in the set.
filtered ( ) The filtered method returns a set of records which satisfies the function given as argument. This method accepts a function as its argument. Syntax: Model.filtered ( func ) ? records Eg : records.filtered (lambda r: r.company_id == user.company_id ) - This only keeps records whose company is the current user's.
For More Details Check our company website for related blogs and Odoo book. Common ORM Methods ORM (Object Relational Mapping) in Odoo Check our YouTube channel for functional and technical videos in Odoo. Odoo ORM Methods