SlideShare a Scribd company logo
How to Use Constraints and
SQL Constraints in Odoo 15
www.cybrosys.com
INTRODUCTION
 Odoo helps you to set constraints to variants which we can perform using python and
model constraints. In odoo python constraints are specified along with methods.
 This Slide will provide an insight on python and model constraints in Odoo 15.
 In python, constraints are defined along with a method decorated with constraints().
Odoo provides two ways to set up automatically verified invariants
 Python constraints
 SQL constraints
 A Python constraint is defined as a method decorated with @api.constrains,
and invoked on a recordset.
 The decorator specifies which fields are involved in the constraint, so that the
constraint is automatically evaluated when one of them is modified.
 The method is expected to raise an exception if its invariant is not satisfied:
Python Constraints
The field for which constraint is to be applied is specified along with the decorator constraints().
Can provide multiple field values as arguments in the function. Therefore, the function
gets invoked each time the value in the field gets modified/changed
There are certain limitations for using constraints()
● constrains() are not supported along with related fields. They can only be applied to simple
fields. For example related fields like partner_id.phone.
● constrains() can only be applied to fields that are included in the create and write call
because if the field is which is not contained in the view will not trigger a call to python
function.
 SQL constraints are defined through the model using _sql_constraints.
 The latter is assigned to a list of triples of strings (name, sql_definition, message),
where name is a valid SQL constraint name, sql_definition is a table_constraint_
expression, and message is the error message.
SQL Constraints
The code is used to prevent the addition of records with the same email. Because it is
irrelevant to add the same email to blacklist twice. So for situations like this where you need
to apply constraints of this type the _sql_constraints comes into action.
 name - Name for the sql constraint(eg:'unique_email')
 definition - Constraint to be applied on the table.(eg:unique (email))
 message - Validation message to be displayed. (eg: Email address
already exists!)
 Check constraint: A check constraint is defined using the CHECK keyword. Furthermore, as
the name suggests it is used to check whether it satisfies a certain condition.
 Not-Null Constraints: NOT NULL keyword is used to specify not null constraints, which
means that certain values or fields cannot be NULL.
 Unique Constraint:It is used along with a ‘unique’ keyword.The unique constraint helps
you to check whether a specified column in rows satisfies the unique constraint.
For More
Details
Check our company website for related blogs and Odoo
book.
Odoo Book V15
Check our YouTube channel for functional and technical
videos in Odoo.
How to Use Constraint and SQL Constraint? | Model
Constraints & SQL Constraints in Odoo 15
How to Use Constraint and SQL Constraint in Odoo 15
Thank You
Ad

More Related Content

What's hot (20)

How to develop automated tests
How to develop automated testsHow to develop automated tests
How to develop automated tests
Odoo
 
Widgets in odoo
Widgets in odooWidgets in odoo
Widgets in odoo
Celine George
 
Owl: The New Odoo UI Framework
Owl: The New Odoo UI FrameworkOwl: The New Odoo UI Framework
Owl: The New Odoo UI Framework
Odoo
 
What is Delegation Inheritance in Odoo 15
What is Delegation Inheritance in Odoo 15What is Delegation Inheritance in Odoo 15
What is Delegation Inheritance in Odoo 15
Celine George
 
Create Data Files and Load Data in Odoo 15
Create Data Files and Load Data in Odoo 15Create Data Files and Load Data in Odoo 15
Create Data Files and Load Data in Odoo 15
Celine George
 
Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)
sroo galal
 
Odoo icon smart buttons
Odoo   icon smart buttonsOdoo   icon smart buttons
Odoo icon smart buttons
Taieb Kristou
 
What is Computed Fields and @api Depends in Odoo 15
What is Computed Fields and @api Depends in Odoo 15What is Computed Fields and @api Depends in Odoo 15
What is Computed Fields and @api Depends in Odoo 15
Celine George
 
Developing New Widgets for your Views in Owl
Developing New Widgets for your Views in OwlDeveloping New Widgets for your Views in Owl
Developing New Widgets for your Views in Owl
Odoo
 
QWeb Report in odoo
QWeb Report in odooQWeb Report in odoo
QWeb Report in odoo
expertodoo
 
Odoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new apiOdoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new api
Odoo
 
How to Develop your own in App-Purchase Service in Odoo
How to Develop your own in App-Purchase Service in OdooHow to Develop your own in App-Purchase Service in Odoo
How to Develop your own in App-Purchase Service in Odoo
Odoo
 
Defining Kanban View in Odoo15 | Advanced Views
Defining Kanban View in Odoo15 | Advanced ViewsDefining Kanban View in Odoo15 | Advanced Views
Defining Kanban View in Odoo15 | Advanced Views
Celine George
 
View Inheritance in Odoo 16
View Inheritance in Odoo 16View Inheritance in Odoo 16
View Inheritance in Odoo 16
Celine George
 
How to show warning _ error messages in Odoo 16
How to show warning _ error messages in Odoo 16 How to show warning _ error messages in Odoo 16
How to show warning _ error messages in Odoo 16
Celine George
 
HOW TO CREATE A MODULE IN ODOO
HOW TO CREATE A MODULE IN ODOOHOW TO CREATE A MODULE IN ODOO
HOW TO CREATE A MODULE IN ODOO
Celine George
 
Odoo - Smart buttons
Odoo - Smart buttonsOdoo - Smart buttons
Odoo - Smart buttons
Odoo
 
How to Import data into OpenERP V7
How to Import data into OpenERP V7How to Import data into OpenERP V7
How to Import data into OpenERP V7
Audaxis
 
How to Build Custom Module in Odoo 15
How to Build Custom Module in Odoo 15How to Build Custom Module in Odoo 15
How to Build Custom Module in Odoo 15
Celine George
 
Updating Client Interface 'on change' @api.onchange in Odoo 15
Updating Client Interface 'on change' @api.onchange in Odoo 15Updating Client Interface 'on change' @api.onchange in Odoo 15
Updating Client Interface 'on change' @api.onchange in Odoo 15
Celine George
 
How to develop automated tests
How to develop automated testsHow to develop automated tests
How to develop automated tests
Odoo
 
Owl: The New Odoo UI Framework
Owl: The New Odoo UI FrameworkOwl: The New Odoo UI Framework
Owl: The New Odoo UI Framework
Odoo
 
What is Delegation Inheritance in Odoo 15
What is Delegation Inheritance in Odoo 15What is Delegation Inheritance in Odoo 15
What is Delegation Inheritance in Odoo 15
Celine George
 
Create Data Files and Load Data in Odoo 15
Create Data Files and Load Data in Odoo 15Create Data Files and Load Data in Odoo 15
Create Data Files and Load Data in Odoo 15
Celine George
 
Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)
sroo galal
 
Odoo icon smart buttons
Odoo   icon smart buttonsOdoo   icon smart buttons
Odoo icon smart buttons
Taieb Kristou
 
What is Computed Fields and @api Depends in Odoo 15
What is Computed Fields and @api Depends in Odoo 15What is Computed Fields and @api Depends in Odoo 15
What is Computed Fields and @api Depends in Odoo 15
Celine George
 
Developing New Widgets for your Views in Owl
Developing New Widgets for your Views in OwlDeveloping New Widgets for your Views in Owl
Developing New Widgets for your Views in Owl
Odoo
 
QWeb Report in odoo
QWeb Report in odooQWeb Report in odoo
QWeb Report in odoo
expertodoo
 
Odoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new apiOdoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new api
Odoo
 
How to Develop your own in App-Purchase Service in Odoo
How to Develop your own in App-Purchase Service in OdooHow to Develop your own in App-Purchase Service in Odoo
How to Develop your own in App-Purchase Service in Odoo
Odoo
 
Defining Kanban View in Odoo15 | Advanced Views
Defining Kanban View in Odoo15 | Advanced ViewsDefining Kanban View in Odoo15 | Advanced Views
Defining Kanban View in Odoo15 | Advanced Views
Celine George
 
View Inheritance in Odoo 16
View Inheritance in Odoo 16View Inheritance in Odoo 16
View Inheritance in Odoo 16
Celine George
 
How to show warning _ error messages in Odoo 16
How to show warning _ error messages in Odoo 16 How to show warning _ error messages in Odoo 16
How to show warning _ error messages in Odoo 16
Celine George
 
HOW TO CREATE A MODULE IN ODOO
HOW TO CREATE A MODULE IN ODOOHOW TO CREATE A MODULE IN ODOO
HOW TO CREATE A MODULE IN ODOO
Celine George
 
Odoo - Smart buttons
Odoo - Smart buttonsOdoo - Smart buttons
Odoo - Smart buttons
Odoo
 
How to Import data into OpenERP V7
How to Import data into OpenERP V7How to Import data into OpenERP V7
How to Import data into OpenERP V7
Audaxis
 
How to Build Custom Module in Odoo 15
How to Build Custom Module in Odoo 15How to Build Custom Module in Odoo 15
How to Build Custom Module in Odoo 15
Celine George
 
Updating Client Interface 'on change' @api.onchange in Odoo 15
Updating Client Interface 'on change' @api.onchange in Odoo 15Updating Client Interface 'on change' @api.onchange in Odoo 15
Updating Client Interface 'on change' @api.onchange in Odoo 15
Celine George
 

Similar to How to Use Constraint and SQL Constraint in Odoo 15 (20)

Python Constraints & Model Constraints in Odoo 15
Python Constraints & Model Constraints in Odoo 15Python Constraints & Model Constraints in Odoo 15
Python Constraints & Model Constraints in Odoo 15
Celine George
 
Configuration of Python and SQL Constraints in Odoo 18
Configuration of Python and SQL Constraints in Odoo 18Configuration of Python and SQL Constraints in Odoo 18
Configuration of Python and SQL Constraints in Odoo 18
Celine George
 
SQL Constraints in Odoo 17 - Odoo 17 Slides
SQL Constraints in Odoo 17 - Odoo 17 SlidesSQL Constraints in Odoo 17 - Odoo 17 Slides
SQL Constraints in Odoo 17 - Odoo 17 Slides
Celine George
 
Model Constraints - SQL Constraints Odoo 16
Model Constraints - SQL Constraints Odoo 16Model Constraints - SQL Constraints Odoo 16
Model Constraints - SQL Constraints Odoo 16
Celine George
 
Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...
libogdelcy
 
Intro To Unit and integration Testing
Intro To Unit and integration TestingIntro To Unit and integration Testing
Intro To Unit and integration Testing
Paul Churchward
 
Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...
meeritmoral56
 
Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...
hmuraratgai
 
Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...
helawiganiga
 
Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...
gazangyuones
 
Chapter8 pl sql
Chapter8 pl sqlChapter8 pl sql
Chapter8 pl sql
Jafar Nesargi
 
Dbms important questions and answers
Dbms important questions and answersDbms important questions and answers
Dbms important questions and answers
LakshmiSarvani6
 
Bn1017 a demo rdbms
Bn1017 a demo  rdbmsBn1017 a demo  rdbms
Bn1017 a demo rdbms
conline training
 
SAS Proc SQL
SAS Proc SQLSAS Proc SQL
SAS Proc SQL
guest2160992
 
Relational Model and Relational Algebra.pptx
Relational Model and Relational Algebra.pptxRelational Model and Relational Algebra.pptx
Relational Model and Relational Algebra.pptx
Koteswari Kasireddy
 
Cursors, triggers, procedures
Cursors, triggers, proceduresCursors, triggers, procedures
Cursors, triggers, procedures
Vaibhav Kathuria
 
Dbms ii mca-ch7-sql-2013
Dbms ii mca-ch7-sql-2013Dbms ii mca-ch7-sql-2013
Dbms ii mca-ch7-sql-2013
Prosanta Ghosh
 
PROCEDURAL LANGUAGE/ STRUCTURED QUERY LANGUAGE.pdf
PROCEDURAL LANGUAGE/ STRUCTURED QUERY LANGUAGE.pdfPROCEDURAL LANGUAGE/ STRUCTURED QUERY LANGUAGE.pdf
PROCEDURAL LANGUAGE/ STRUCTURED QUERY LANGUAGE.pdf
rajeswaria21
 
Absolute C++ 5th Edition Savitch Solutions Manual
Absolute C++ 5th Edition Savitch Solutions ManualAbsolute C++ 5th Edition Savitch Solutions Manual
Absolute C++ 5th Edition Savitch Solutions Manual
nanteguepi
 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
karymadelaneyrenne19
 
Python Constraints & Model Constraints in Odoo 15
Python Constraints & Model Constraints in Odoo 15Python Constraints & Model Constraints in Odoo 15
Python Constraints & Model Constraints in Odoo 15
Celine George
 
Configuration of Python and SQL Constraints in Odoo 18
Configuration of Python and SQL Constraints in Odoo 18Configuration of Python and SQL Constraints in Odoo 18
Configuration of Python and SQL Constraints in Odoo 18
Celine George
 
SQL Constraints in Odoo 17 - Odoo 17 Slides
SQL Constraints in Odoo 17 - Odoo 17 SlidesSQL Constraints in Odoo 17 - Odoo 17 Slides
SQL Constraints in Odoo 17 - Odoo 17 Slides
Celine George
 
Model Constraints - SQL Constraints Odoo 16
Model Constraints - SQL Constraints Odoo 16Model Constraints - SQL Constraints Odoo 16
Model Constraints - SQL Constraints Odoo 16
Celine George
 
Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...
libogdelcy
 
Intro To Unit and integration Testing
Intro To Unit and integration TestingIntro To Unit and integration Testing
Intro To Unit and integration Testing
Paul Churchward
 
Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...
meeritmoral56
 
Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...
hmuraratgai
 
Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...
helawiganiga
 
Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...Database Systems Design Implementation and Management 11th Edition Coronel So...
Database Systems Design Implementation and Management 11th Edition Coronel So...
gazangyuones
 
Dbms important questions and answers
Dbms important questions and answersDbms important questions and answers
Dbms important questions and answers
LakshmiSarvani6
 
Relational Model and Relational Algebra.pptx
Relational Model and Relational Algebra.pptxRelational Model and Relational Algebra.pptx
Relational Model and Relational Algebra.pptx
Koteswari Kasireddy
 
Cursors, triggers, procedures
Cursors, triggers, proceduresCursors, triggers, procedures
Cursors, triggers, procedures
Vaibhav Kathuria
 
Dbms ii mca-ch7-sql-2013
Dbms ii mca-ch7-sql-2013Dbms ii mca-ch7-sql-2013
Dbms ii mca-ch7-sql-2013
Prosanta Ghosh
 
PROCEDURAL LANGUAGE/ STRUCTURED QUERY LANGUAGE.pdf
PROCEDURAL LANGUAGE/ STRUCTURED QUERY LANGUAGE.pdfPROCEDURAL LANGUAGE/ STRUCTURED QUERY LANGUAGE.pdf
PROCEDURAL LANGUAGE/ STRUCTURED QUERY LANGUAGE.pdf
rajeswaria21
 
Absolute C++ 5th Edition Savitch Solutions Manual
Absolute C++ 5th Edition Savitch Solutions ManualAbsolute C++ 5th Edition Savitch Solutions Manual
Absolute C++ 5th Edition Savitch Solutions Manual
nanteguepi
 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
karymadelaneyrenne19
 
Ad

More from Celine George (20)

Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
How to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 SalesHow to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 Sales
Celine George
 
How to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo SlidesHow to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo Slides
Celine George
 
How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18
Celine George
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
How to Manage a Customer Account in Odoo 17 Sales
How to Manage a Customer Account in Odoo 17 SalesHow to Manage a Customer Account in Odoo 17 Sales
How to Manage a Customer Account in Odoo 17 Sales
Celine George
 
How to Open a Wizard When Clicking on the Kanban Tile in Odoo 18
How to Open a Wizard When Clicking on the Kanban Tile in Odoo 18How to Open a Wizard When Clicking on the Kanban Tile in Odoo 18
How to Open a Wizard When Clicking on the Kanban Tile in Odoo 18
Celine George
 
Ledger Posting in odoo Continental Accounting
Ledger Posting in odoo Continental AccountingLedger Posting in odoo Continental Accounting
Ledger Posting in odoo Continental Accounting
Celine George
 
How to Create & Manage a New User Menu in Odoo 18
How to Create & Manage a New User Menu in Odoo 18How to Create & Manage a New User Menu in Odoo 18
How to Create & Manage a New User Menu in Odoo 18
Celine George
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
How to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 SalesHow to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 Sales
Celine George
 
How to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo SlidesHow to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo Slides
Celine George
 
How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18
Celine George
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
How to Manage a Customer Account in Odoo 17 Sales
How to Manage a Customer Account in Odoo 17 SalesHow to Manage a Customer Account in Odoo 17 Sales
How to Manage a Customer Account in Odoo 17 Sales
Celine George
 
How to Open a Wizard When Clicking on the Kanban Tile in Odoo 18
How to Open a Wizard When Clicking on the Kanban Tile in Odoo 18How to Open a Wizard When Clicking on the Kanban Tile in Odoo 18
How to Open a Wizard When Clicking on the Kanban Tile in Odoo 18
Celine George
 
Ledger Posting in odoo Continental Accounting
Ledger Posting in odoo Continental AccountingLedger Posting in odoo Continental Accounting
Ledger Posting in odoo Continental Accounting
Celine George
 
How to Create & Manage a New User Menu in Odoo 18
How to Create & Manage a New User Menu in Odoo 18How to Create & Manage a New User Menu in Odoo 18
How to Create & Manage a New User Menu in Odoo 18
Celine George
 
Ad

Recently uploaded (20)

"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
APM Midlands Region April 2025 Sacha Hind Circulated.pdf
APM Midlands Region April 2025 Sacha Hind Circulated.pdfAPM Midlands Region April 2025 Sacha Hind Circulated.pdf
APM Midlands Region April 2025 Sacha Hind Circulated.pdf
Association for Project Management
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx   quiz by Ridip HazarikaTHE STG QUIZ GROUP D.pptx   quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
Ridip Hazarika
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
Herbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptxHerbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptx
RAJU THENGE
 
Kenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 CohortKenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 Cohort
EducationNC
 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
Engage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdfEngage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdf
TechSoup
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx   quiz by Ridip HazarikaTHE STG QUIZ GROUP D.pptx   quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
Ridip Hazarika
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
Herbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptxHerbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptx
RAJU THENGE
 
Kenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 CohortKenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 Cohort
EducationNC
 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
Engage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdfEngage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdf
TechSoup
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 

How to Use Constraint and SQL Constraint in Odoo 15

  • 1. How to Use Constraints and SQL Constraints in Odoo 15 www.cybrosys.com
  • 2. INTRODUCTION  Odoo helps you to set constraints to variants which we can perform using python and model constraints. In odoo python constraints are specified along with methods.  This Slide will provide an insight on python and model constraints in Odoo 15.  In python, constraints are defined along with a method decorated with constraints().
  • 3. Odoo provides two ways to set up automatically verified invariants  Python constraints  SQL constraints
  • 4.  A Python constraint is defined as a method decorated with @api.constrains, and invoked on a recordset.  The decorator specifies which fields are involved in the constraint, so that the constraint is automatically evaluated when one of them is modified.  The method is expected to raise an exception if its invariant is not satisfied: Python Constraints
  • 5. The field for which constraint is to be applied is specified along with the decorator constraints().
  • 6. Can provide multiple field values as arguments in the function. Therefore, the function gets invoked each time the value in the field gets modified/changed
  • 7. There are certain limitations for using constraints() ● constrains() are not supported along with related fields. They can only be applied to simple fields. For example related fields like partner_id.phone. ● constrains() can only be applied to fields that are included in the create and write call because if the field is which is not contained in the view will not trigger a call to python function.
  • 8.  SQL constraints are defined through the model using _sql_constraints.  The latter is assigned to a list of triples of strings (name, sql_definition, message), where name is a valid SQL constraint name, sql_definition is a table_constraint_ expression, and message is the error message. SQL Constraints
  • 9. The code is used to prevent the addition of records with the same email. Because it is irrelevant to add the same email to blacklist twice. So for situations like this where you need to apply constraints of this type the _sql_constraints comes into action.
  • 10.  name - Name for the sql constraint(eg:'unique_email')  definition - Constraint to be applied on the table.(eg:unique (email))  message - Validation message to be displayed. (eg: Email address already exists!)
  • 11.  Check constraint: A check constraint is defined using the CHECK keyword. Furthermore, as the name suggests it is used to check whether it satisfies a certain condition.
  • 12.  Not-Null Constraints: NOT NULL keyword is used to specify not null constraints, which means that certain values or fields cannot be NULL.
  • 13.  Unique Constraint:It is used along with a ‘unique’ keyword.The unique constraint helps you to check whether a specified column in rows satisfies the unique constraint.
  • 14. For More Details Check our company website for related blogs and Odoo book. Odoo Book V15 Check our YouTube channel for functional and technical videos in Odoo. How to Use Constraint and SQL Constraint? | Model Constraints & SQL Constraints in Odoo 15