SlideShare a Scribd company logo

Model Constraints - SQL Constraints Odoo 16

SQL Constraints helps to set validation for the record sets, which act as a reminder for the user for the workflow.

1 of 10
Download to read offline
Model Constraints - SQL
Constraints Odoo 16
● SQL Constraints which are defined through the model attribute
_sql_constraints.
● SQL Constraints also give the same purpose of python
constraints.
● SQL Constraints helps to set validation for the recordsets,which
act as a reminder for the user for the workflow.
Types Of SQL Constraints
1. Not Null
2. Check
3. Unique
How SQL Constraints Work
Example Model:
Class TestModel(model.Model):
_name=’test.model’
_description=’Test Model’
name=fields.Char()
channel_type=fields.Selection([(‘chat’,’Chat’),(‘channel’,’Channel’)])
probability=fields.Float()
Not Null
This constraint ensures that no field can be empty or null.
Eg : _sql_constraints=[(‘channel_type_not_null’,’CHECK(channel_type IS NOT NULL)’,The
Channel Type Cannot be Empty’)]
● This is a tuple that defines a single check constraint.
● The first member of the tuple “channel_type_not_null” is a string that defines the constraints
name.The name may be whatever you like as long as it is unique to the model.
Not Null
● The second member of the tuple,CHECK(channel_type IS NOT NULL), defines the
check constraint.In this case ,the constraint checks whether the channel_type field is
not null.If the channel_type field is null,the constraint will be violated and an error will be
raised.
● The third member of the tuple,’The Channel Type Cannot be Empty’,is a string that
provides an error message that will be displayed to the user if the constraint is violated.

Recommended

View Inheritance in Odoo 15
View Inheritance in Odoo 15View Inheritance in Odoo 15
View Inheritance in Odoo 15Celine George
 
Actions and menus in odoo 16
Actions and menus in odoo 16Actions and menus in odoo 16
Actions and menus in odoo 16Celine George
 
Object Relation Mapping in Odoo 16
Object Relation Mapping in Odoo 16Object Relation Mapping in Odoo 16
Object Relation Mapping in Odoo 16Celine George
 
View Inheritance in Odoo 16
View Inheritance in Odoo 16View Inheritance in Odoo 16
View Inheritance in Odoo 16Celine 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
 
Building l10n Payroll Structures from the Ground up
Building l10n Payroll Structures from the Ground upBuilding l10n Payroll Structures from the Ground up
Building l10n Payroll Structures from the Ground upOdoo
 
Oracle Forms Introduction
Oracle Forms IntroductionOracle Forms Introduction
Oracle Forms IntroductionSekhar Byna
 
How to Use Constraint and SQL Constraint in Odoo 15
How to Use Constraint and SQL Constraint in Odoo 15How to Use Constraint and SQL Constraint in Odoo 15
How to Use Constraint and SQL Constraint in Odoo 15Celine George
 

More Related Content

What's hot

Basic Views in Odoo 16
Basic Views in Odoo 16Basic Views in Odoo 16
Basic Views in Odoo 16Celine George
 
What are Wizards - Defining and Launching in Odoo 15Wizards - Defining and La...
What are Wizards - Defining and Launching in Odoo 15Wizards - Defining and La...What are Wizards - Defining and Launching in Odoo 15Wizards - Defining and La...
What are Wizards - Defining and Launching in Odoo 15Wizards - Defining and La...Celine George
 
scaffold method odoo 16
scaffold method odoo 16scaffold method odoo 16
scaffold method odoo 16Celine George
 
Odoo - Smart buttons
Odoo - Smart buttonsOdoo - Smart buttons
Odoo - Smart buttonsOdoo
 
Oracle Forms Tutorial
Oracle Forms TutorialOracle Forms Tutorial
Oracle Forms TutorialATR Login
 
Odoo ORM Methods | Object Relational Mapping in Odoo15
Odoo ORM Methods | Object Relational Mapping in Odoo15 Odoo ORM Methods | Object Relational Mapping in Odoo15
Odoo ORM Methods | Object Relational Mapping in Odoo15 Celine George
 
Basic i/o & file handling in java
Basic i/o & file handling in javaBasic i/o & file handling in java
Basic i/o & file handling in javaJayasankarPR2
 
Oracle D2K reports
Oracle D2K reports Oracle D2K reports
Oracle D2K reports Rajesh Ch
 
Oracle Forms Triggers
Oracle Forms TriggersOracle Forms Triggers
Oracle Forms TriggersSekhar Byna
 
How to Define One2Many Field in Odoo 15
 How to Define One2Many Field in Odoo 15 How to Define One2Many Field in Odoo 15
How to Define One2Many Field in Odoo 15Celine George
 
Oracle Forms: Introduction to multiple Forms
Oracle Forms: Introduction to multiple FormsOracle Forms: Introduction to multiple Forms
Oracle Forms: Introduction to multiple FormsSekhar Byna
 
QWeb Report in odoo
QWeb Report in odooQWeb Report in odoo
QWeb Report in odooexpertodoo
 
[Curso Java Basico] Exercicios Aula 35
[Curso Java Basico] Exercicios Aula 35[Curso Java Basico] Exercicios Aula 35
[Curso Java Basico] Exercicios Aula 35Loiane Groner
 
[Curso Java Basico] Exercicios Aulas 25 a 27
[Curso Java Basico] Exercicios Aulas 25 a 27[Curso Java Basico] Exercicios Aulas 25 a 27
[Curso Java Basico] Exercicios Aulas 25 a 27Loiane Groner
 
Select all record from menu for matching item type in ap invoice personalization
Select all record from menu for matching item type in ap invoice personalizationSelect all record from menu for matching item type in ap invoice personalization
Select all record from menu for matching item type in ap invoice personalizationAhmed Elshayeb
 

What's hot (20)

Basic Views in Odoo 16
Basic Views in Odoo 16Basic Views in Odoo 16
Basic Views in Odoo 16
 
What are Wizards - Defining and Launching in Odoo 15Wizards - Defining and La...
What are Wizards - Defining and Launching in Odoo 15Wizards - Defining and La...What are Wizards - Defining and Launching in Odoo 15Wizards - Defining and La...
What are Wizards - Defining and Launching in Odoo 15Wizards - Defining and La...
 
scaffold method odoo 16
scaffold method odoo 16scaffold method odoo 16
scaffold method odoo 16
 
Odoo - Smart buttons
Odoo - Smart buttonsOdoo - Smart buttons
Odoo - Smart buttons
 
Oracle Forms Tutorial
Oracle Forms TutorialOracle Forms Tutorial
Oracle Forms Tutorial
 
Odoo ORM Methods | Object Relational Mapping in Odoo15
Odoo ORM Methods | Object Relational Mapping in Odoo15 Odoo ORM Methods | Object Relational Mapping in Odoo15
Odoo ORM Methods | Object Relational Mapping in Odoo15
 
Basic i/o & file handling in java
Basic i/o & file handling in javaBasic i/o & file handling in java
Basic i/o & file handling in java
 
Oracle D2K reports
Oracle D2K reports Oracle D2K reports
Oracle D2K reports
 
Oracle Forms Triggers
Oracle Forms TriggersOracle Forms Triggers
Oracle Forms Triggers
 
Oracle 11i forms personalization
Oracle 11i forms personalizationOracle 11i forms personalization
Oracle 11i forms personalization
 
forms builder
forms builderforms builder
forms builder
 
How to Define One2Many Field in Odoo 15
 How to Define One2Many Field in Odoo 15 How to Define One2Many Field in Odoo 15
How to Define One2Many Field in Odoo 15
 
Oracle Forms: Introduction to multiple Forms
Oracle Forms: Introduction to multiple FormsOracle Forms: Introduction to multiple Forms
Oracle Forms: Introduction to multiple Forms
 
Java modules
Java modulesJava modules
Java modules
 
Reports 6i
Reports 6iReports 6i
Reports 6i
 
Python Programming Essentials - M27 - Logging module
Python Programming Essentials - M27 - Logging modulePython Programming Essentials - M27 - Logging module
Python Programming Essentials - M27 - Logging module
 
QWeb Report in odoo
QWeb Report in odooQWeb Report in odoo
QWeb Report in odoo
 
[Curso Java Basico] Exercicios Aula 35
[Curso Java Basico] Exercicios Aula 35[Curso Java Basico] Exercicios Aula 35
[Curso Java Basico] Exercicios Aula 35
 
[Curso Java Basico] Exercicios Aulas 25 a 27
[Curso Java Basico] Exercicios Aulas 25 a 27[Curso Java Basico] Exercicios Aulas 25 a 27
[Curso Java Basico] Exercicios Aulas 25 a 27
 
Select all record from menu for matching item type in ap invoice personalization
Select all record from menu for matching item type in ap invoice personalizationSelect all record from menu for matching item type in ap invoice personalization
Select all record from menu for matching item type in ap invoice personalization
 

Similar to Model Constraints - SQL Constraints Odoo 16

Oracle SQL Fundamentals - Lecture 3
Oracle SQL Fundamentals - Lecture 3Oracle SQL Fundamentals - Lecture 3
Oracle SQL Fundamentals - Lecture 3MuhammadWaheed44
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity ConstraintsMegha yadav
 
1.Implementing_Data_Integrity.pdf
1.Implementing_Data_Integrity.pdf1.Implementing_Data_Integrity.pdf
1.Implementing_Data_Integrity.pdfdiaa46
 
Data Manipulation(DML) and Transaction Control (TCL)
Data Manipulation(DML) and Transaction Control (TCL)  Data Manipulation(DML) and Transaction Control (TCL)
Data Manipulation(DML) and Transaction Control (TCL) MuhammadWaheed44
 
Sql integrity constraints
Sql integrity constraintsSql integrity constraints
Sql integrity constraintsVivek Singh
 
Entigrity constraint
Entigrity constraintEntigrity constraint
Entigrity constraintsuman kumar
 
RDBMS Lab03 applying constraints (UIU)
RDBMS Lab03 applying constraints (UIU)RDBMS Lab03 applying constraints (UIU)
RDBMS Lab03 applying constraints (UIU)Muhammad T Q Nafis
 
SQL/MX 3.6 Select for update feature
SQL/MX 3.6 Select for update featureSQL/MX 3.6 Select for update feature
SQL/MX 3.6 Select for update featureFrans Jongma
 
Constraints constraints of oracle data base management systems
Constraints  constraints of oracle data base management systemsConstraints  constraints of oracle data base management systems
Constraints constraints of oracle data base management systemsSHAKIR325211
 
2. DBMS Experiment - Lab 2 Made in SQL Used
2. DBMS Experiment - Lab 2 Made in SQL Used2. DBMS Experiment - Lab 2 Made in SQL Used
2. DBMS Experiment - Lab 2 Made in SQL UsedTheVerse1
 
Dms 22319 micro project
Dms 22319 micro projectDms 22319 micro project
Dms 22319 micro projectARVIND SARDAR
 
Check Constraints in MySQL 8.0. Presented at pre-FOSDEM MySQL Day 2020
Check Constraints in MySQL 8.0. Presented at pre-FOSDEM MySQL Day 2020Check Constraints in MySQL 8.0. Presented at pre-FOSDEM MySQL Day 2020
Check Constraints in MySQL 8.0. Presented at pre-FOSDEM MySQL Day 2020DmitryLenev
 
Using_PATSTAT_with_SQL_v2.8.pptx
Using_PATSTAT_with_SQL_v2.8.pptxUsing_PATSTAT_with_SQL_v2.8.pptx
Using_PATSTAT_with_SQL_v2.8.pptxssuserf96a5b
 

Similar to Model Constraints - SQL Constraints Odoo 16 (20)

Oracle SQL Fundamentals - Lecture 3
Oracle SQL Fundamentals - Lecture 3Oracle SQL Fundamentals - Lecture 3
Oracle SQL Fundamentals - Lecture 3
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Sql commands
Sql commandsSql commands
Sql commands
 
1.Implementing_Data_Integrity.pdf
1.Implementing_Data_Integrity.pdf1.Implementing_Data_Integrity.pdf
1.Implementing_Data_Integrity.pdf
 
Bn1017 a demo rdbms
Bn1017 a demo  rdbmsBn1017 a demo  rdbms
Bn1017 a demo rdbms
 
Data Manipulation(DML) and Transaction Control (TCL)
Data Manipulation(DML) and Transaction Control (TCL)  Data Manipulation(DML) and Transaction Control (TCL)
Data Manipulation(DML) and Transaction Control (TCL)
 
Sql integrity constraints
Sql integrity constraintsSql integrity constraints
Sql integrity constraints
 
Entigrity constraint
Entigrity constraintEntigrity constraint
Entigrity constraint
 
Oracle SQL Part 2
Oracle SQL Part 2Oracle SQL Part 2
Oracle SQL Part 2
 
RDBMS Lab03 applying constraints (UIU)
RDBMS Lab03 applying constraints (UIU)RDBMS Lab03 applying constraints (UIU)
RDBMS Lab03 applying constraints (UIU)
 
SQL/MX 3.6 Select for update feature
SQL/MX 3.6 Select for update featureSQL/MX 3.6 Select for update feature
SQL/MX 3.6 Select for update feature
 
Bn1037 demo oracle sql
Bn1037 demo  oracle sqlBn1037 demo  oracle sql
Bn1037 demo oracle sql
 
Constraints constraints of oracle data base management systems
Constraints  constraints of oracle data base management systemsConstraints  constraints of oracle data base management systems
Constraints constraints of oracle data base management systems
 
2. DBMS Experiment - Lab 2 Made in SQL Used
2. DBMS Experiment - Lab 2 Made in SQL Used2. DBMS Experiment - Lab 2 Made in SQL Used
2. DBMS Experiment - Lab 2 Made in SQL Used
 
Database constraints
Database constraintsDatabase constraints
Database constraints
 
Dms 22319 micro project
Dms 22319 micro projectDms 22319 micro project
Dms 22319 micro project
 
Sql wksht-2
Sql wksht-2Sql wksht-2
Sql wksht-2
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
Check Constraints in MySQL 8.0. Presented at pre-FOSDEM MySQL Day 2020
Check Constraints in MySQL 8.0. Presented at pre-FOSDEM MySQL Day 2020Check Constraints in MySQL 8.0. Presented at pre-FOSDEM MySQL Day 2020
Check Constraints in MySQL 8.0. Presented at pre-FOSDEM MySQL Day 2020
 
Using_PATSTAT_with_SQL_v2.8.pptx
Using_PATSTAT_with_SQL_v2.8.pptxUsing_PATSTAT_with_SQL_v2.8.pptx
Using_PATSTAT_with_SQL_v2.8.pptx
 

More from Celine George

Multi - checkbox Attribute in the Odoo 17
Multi - checkbox Attribute in the Odoo 17Multi - checkbox Attribute in the Odoo 17
Multi - checkbox Attribute in the Odoo 17Celine George
 
How To Create Record Rules in the Odoo 17
How To Create Record Rules in the Odoo 17How To Create Record Rules in the Odoo 17
How To Create Record Rules in the Odoo 17Celine George
 
Add Products From Catalog in Odoo 17 Sales
Add Products From Catalog in Odoo 17 SalesAdd Products From Catalog in Odoo 17 Sales
Add Products From Catalog in Odoo 17 SalesCeline George
 
New Features in the Odoo 17 Sales Module
New Features in  the Odoo 17 Sales ModuleNew Features in  the Odoo 17 Sales Module
New Features in the Odoo 17 Sales ModuleCeline George
 
Subscription Pause Cancel in Odoo 17
Subscription Pause Cancel in Odoo 17Subscription Pause Cancel in Odoo 17
Subscription Pause Cancel in Odoo 17Celine George
 
How To Create Calendar View In Odoo 16
How To Create Calendar View In Odoo 16How To Create Calendar View In Odoo 16
How To Create Calendar View In Odoo 16Celine George
 
Model Attribute - _description
Model Attribute - _descriptionModel Attribute - _description
Model Attribute - _descriptionCeline George
 
Model Attribute - _transient
Model Attribute - _transientModel Attribute - _transient
Model Attribute - _transientCeline George
 
Model Attribute - _order
Model Attribute - _orderModel Attribute - _order
Model Attribute - _orderCeline George
 
Down Payments In Odoo 16 Sales
Down Payments In Odoo 16 SalesDown Payments In Odoo 16 Sales
Down Payments In Odoo 16 SalesCeline George
 
How to empty an One2many field in Odoo
How to empty an One2many field in OdooHow to empty an One2many field in Odoo
How to empty an One2many field in OdooCeline George
 
Configure Project in Odoo 16
Configure Project in Odoo 16Configure Project in Odoo 16
Configure Project in Odoo 16Celine George
 
Model Constraints In Odoo 16
Model Constraints In Odoo 16Model Constraints In Odoo 16
Model Constraints In Odoo 16Celine George
 
Quick Tips in Odoo 16
Quick Tips in Odoo 16Quick Tips in Odoo 16
Quick Tips in Odoo 16Celine George
 
Model Fields in Odoo 16
Model Fields in Odoo 16Model Fields in Odoo 16
Model Fields in Odoo 16Celine George
 
Building a Module in Odoo 16
Building a Module in Odoo 16Building a Module in Odoo 16
Building a Module in Odoo 16Celine George
 
Module Structure in Odoo 16
Module Structure in Odoo 16Module Structure in Odoo 16
Module Structure in Odoo 16Celine George
 
Composition of a Module in Odoo 16
Composition of a Module in Odoo 16Composition of a Module in Odoo 16
Composition of a Module in Odoo 16Celine George
 
How to Add a Store Attribute to a Field in Odoo 16
How to Add a Store Attribute to a Field in Odoo 16How to Add a Store Attribute to a Field in Odoo 16
How to Add a Store Attribute to a Field in Odoo 16Celine George
 
How to Make Sequence Number in Odoo 16
How to Make Sequence Number in Odoo 16How to Make Sequence Number in Odoo 16
How to Make Sequence Number in Odoo 16Celine George
 

More from Celine George (20)

Multi - checkbox Attribute in the Odoo 17
Multi - checkbox Attribute in the Odoo 17Multi - checkbox Attribute in the Odoo 17
Multi - checkbox Attribute in the Odoo 17
 
How To Create Record Rules in the Odoo 17
How To Create Record Rules in the Odoo 17How To Create Record Rules in the Odoo 17
How To Create Record Rules in the Odoo 17
 
Add Products From Catalog in Odoo 17 Sales
Add Products From Catalog in Odoo 17 SalesAdd Products From Catalog in Odoo 17 Sales
Add Products From Catalog in Odoo 17 Sales
 
New Features in the Odoo 17 Sales Module
New Features in  the Odoo 17 Sales ModuleNew Features in  the Odoo 17 Sales Module
New Features in the Odoo 17 Sales Module
 
Subscription Pause Cancel in Odoo 17
Subscription Pause Cancel in Odoo 17Subscription Pause Cancel in Odoo 17
Subscription Pause Cancel in Odoo 17
 
How To Create Calendar View In Odoo 16
How To Create Calendar View In Odoo 16How To Create Calendar View In Odoo 16
How To Create Calendar View In Odoo 16
 
Model Attribute - _description
Model Attribute - _descriptionModel Attribute - _description
Model Attribute - _description
 
Model Attribute - _transient
Model Attribute - _transientModel Attribute - _transient
Model Attribute - _transient
 
Model Attribute - _order
Model Attribute - _orderModel Attribute - _order
Model Attribute - _order
 
Down Payments In Odoo 16 Sales
Down Payments In Odoo 16 SalesDown Payments In Odoo 16 Sales
Down Payments In Odoo 16 Sales
 
How to empty an One2many field in Odoo
How to empty an One2many field in OdooHow to empty an One2many field in Odoo
How to empty an One2many field in Odoo
 
Configure Project in Odoo 16
Configure Project in Odoo 16Configure Project in Odoo 16
Configure Project in Odoo 16
 
Model Constraints In Odoo 16
Model Constraints In Odoo 16Model Constraints In Odoo 16
Model Constraints In Odoo 16
 
Quick Tips in Odoo 16
Quick Tips in Odoo 16Quick Tips in Odoo 16
Quick Tips in Odoo 16
 
Model Fields in Odoo 16
Model Fields in Odoo 16Model Fields in Odoo 16
Model Fields in Odoo 16
 
Building a Module in Odoo 16
Building a Module in Odoo 16Building a Module in Odoo 16
Building a Module in Odoo 16
 
Module Structure in Odoo 16
Module Structure in Odoo 16Module Structure in Odoo 16
Module Structure in Odoo 16
 
Composition of a Module in Odoo 16
Composition of a Module in Odoo 16Composition of a Module in Odoo 16
Composition of a Module in Odoo 16
 
How to Add a Store Attribute to a Field in Odoo 16
How to Add a Store Attribute to a Field in Odoo 16How to Add a Store Attribute to a Field in Odoo 16
How to Add a Store Attribute to a Field in Odoo 16
 
How to Make Sequence Number in Odoo 16
How to Make Sequence Number in Odoo 16How to Make Sequence Number in Odoo 16
How to Make Sequence Number in Odoo 16
 

Recently uploaded

Understanding Canada's international higher education landscape (2024)
Understanding Canada's international higher education landscape (2024)Understanding Canada's international higher education landscape (2024)
Understanding Canada's international higher education landscape (2024)CaraSkikne1
 
Practical Research 1, Lesson 5: DESIGNING A RESEARCH PROJECT RELATED TO DAILY...
Practical Research 1, Lesson 5: DESIGNING A RESEARCH PROJECT RELATED TO DAILY...Practical Research 1, Lesson 5: DESIGNING A RESEARCH PROJECT RELATED TO DAILY...
Practical Research 1, Lesson 5: DESIGNING A RESEARCH PROJECT RELATED TO DAILY...Katherine Villaluna
 
Dr.M.Florence Dayana-Cloud Computing-Unit - 1.pdf
Dr.M.Florence Dayana-Cloud Computing-Unit - 1.pdfDr.M.Florence Dayana-Cloud Computing-Unit - 1.pdf
Dr.M.Florence Dayana-Cloud Computing-Unit - 1.pdfDr.Florence Dayana
 
Andreas Schleicher_ Strengthening Upper Secondary Education in Lithuania
Andreas Schleicher_ Strengthening Upper Secondary  Education in LithuaniaAndreas Schleicher_ Strengthening Upper Secondary  Education in Lithuania
Andreas Schleicher_ Strengthening Upper Secondary Education in LithuaniaEduSkills OECD
 
Organic Synthesis and Estimation of Functional Groups
Organic Synthesis and Estimation of Functional GroupsOrganic Synthesis and Estimation of Functional Groups
Organic Synthesis and Estimation of Functional GroupsDr.M.Geethavani
 
Dr.M.Florence Dayana-Cloud Computing-unit - 4.pdf
Dr.M.Florence Dayana-Cloud Computing-unit - 4.pdfDr.M.Florence Dayana-Cloud Computing-unit - 4.pdf
Dr.M.Florence Dayana-Cloud Computing-unit - 4.pdfDr.Florence Dayana
 
ADAPTABILITY, Types of Adaptability AND STABILITY ANALYSIS method.pptx
ADAPTABILITY, Types of Adaptability AND STABILITY ANALYSIS  method.pptxADAPTABILITY, Types of Adaptability AND STABILITY ANALYSIS  method.pptx
ADAPTABILITY, Types of Adaptability AND STABILITY ANALYSIS method.pptxAKSHAYMAGAR17
 
MEC MAJUBA SADDENED BY THE PASSING AWAY OF THREE TEACHERS FOLLOWING A CAR ACC...
MEC MAJUBA SADDENED BY THE PASSING AWAY OF THREE TEACHERS FOLLOWING A CAR ACC...MEC MAJUBA SADDENED BY THE PASSING AWAY OF THREE TEACHERS FOLLOWING A CAR ACC...
MEC MAJUBA SADDENED BY THE PASSING AWAY OF THREE TEACHERS FOLLOWING A CAR ACC...SABC News
 
Healthy Habits for Happy School Staff - presentation
Healthy Habits for Happy School Staff - presentationHealthy Habits for Happy School Staff - presentation
Healthy Habits for Happy School Staff - presentationPooky Knightsmith
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...Nguyen Thanh Tu Collection
 
A LABORATORY MANUAL FOR ORGANIC CHEMISTRY.pdf
A LABORATORY MANUAL FOR ORGANIC CHEMISTRY.pdfA LABORATORY MANUAL FOR ORGANIC CHEMISTRY.pdf
A LABORATORY MANUAL FOR ORGANIC CHEMISTRY.pdfDr.M.Geethavani
 
Decision on Curriculum Change Path: Towards Standards-Based Curriculum in Ghana
Decision on Curriculum Change Path: Towards Standards-Based Curriculum in GhanaDecision on Curriculum Change Path: Towards Standards-Based Curriculum in Ghana
Decision on Curriculum Change Path: Towards Standards-Based Curriculum in GhanaPrince Armah, PhD
 
spring_bee_bot_creations_erd primary.pdf
spring_bee_bot_creations_erd primary.pdfspring_bee_bot_creations_erd primary.pdf
spring_bee_bot_creations_erd primary.pdfKonstantina Koutsodimou
 
CATCH UP FRIDAY LESSON PLAN GRADE 6.docx
CATCH UP FRIDAY LESSON PLAN GRADE 6.docxCATCH UP FRIDAY LESSON PLAN GRADE 6.docx
CATCH UP FRIDAY LESSON PLAN GRADE 6.docxAizaPolinarCruz
 
A Free eBook ~ Mental Exercise ...Puzzles to Analyze.pdf
A Free eBook ~ Mental Exercise ...Puzzles to Analyze.pdfA Free eBook ~ Mental Exercise ...Puzzles to Analyze.pdf
A Free eBook ~ Mental Exercise ...Puzzles to Analyze.pdfOH TEIK BIN
 
A TEXTBOOK OF INTELLECTUAL ROPERTY RIGHTS
A TEXTBOOK OF INTELLECTUAL ROPERTY RIGHTSA TEXTBOOK OF INTELLECTUAL ROPERTY RIGHTS
A TEXTBOOK OF INTELLECTUAL ROPERTY RIGHTSDr.M.Geethavani
 
11 CI SINIF SINAQLARI - 9-2023-Aynura-Hamidova.pdf
11 CI SINIF SINAQLARI - 9-2023-Aynura-Hamidova.pdf11 CI SINIF SINAQLARI - 9-2023-Aynura-Hamidova.pdf
11 CI SINIF SINAQLARI - 9-2023-Aynura-Hamidova.pdfAynouraHamidova
 

Recently uploaded (20)

Understanding Canada's international higher education landscape (2024)
Understanding Canada's international higher education landscape (2024)Understanding Canada's international higher education landscape (2024)
Understanding Canada's international higher education landscape (2024)
 
Lipids as Biopolymer
Lipids as Biopolymer Lipids as Biopolymer
Lipids as Biopolymer
 
Practical Research 1, Lesson 5: DESIGNING A RESEARCH PROJECT RELATED TO DAILY...
Practical Research 1, Lesson 5: DESIGNING A RESEARCH PROJECT RELATED TO DAILY...Practical Research 1, Lesson 5: DESIGNING A RESEARCH PROJECT RELATED TO DAILY...
Practical Research 1, Lesson 5: DESIGNING A RESEARCH PROJECT RELATED TO DAILY...
 
Dr.M.Florence Dayana-Cloud Computing-Unit - 1.pdf
Dr.M.Florence Dayana-Cloud Computing-Unit - 1.pdfDr.M.Florence Dayana-Cloud Computing-Unit - 1.pdf
Dr.M.Florence Dayana-Cloud Computing-Unit - 1.pdf
 
Andreas Schleicher_ Strengthening Upper Secondary Education in Lithuania
Andreas Schleicher_ Strengthening Upper Secondary  Education in LithuaniaAndreas Schleicher_ Strengthening Upper Secondary  Education in Lithuania
Andreas Schleicher_ Strengthening Upper Secondary Education in Lithuania
 
Organic Synthesis and Estimation of Functional Groups
Organic Synthesis and Estimation of Functional GroupsOrganic Synthesis and Estimation of Functional Groups
Organic Synthesis and Estimation of Functional Groups
 
Dr.M.Florence Dayana-Cloud Computing-unit - 4.pdf
Dr.M.Florence Dayana-Cloud Computing-unit - 4.pdfDr.M.Florence Dayana-Cloud Computing-unit - 4.pdf
Dr.M.Florence Dayana-Cloud Computing-unit - 4.pdf
 
ADAPTABILITY, Types of Adaptability AND STABILITY ANALYSIS method.pptx
ADAPTABILITY, Types of Adaptability AND STABILITY ANALYSIS  method.pptxADAPTABILITY, Types of Adaptability AND STABILITY ANALYSIS  method.pptx
ADAPTABILITY, Types of Adaptability AND STABILITY ANALYSIS method.pptx
 
MEC MAJUBA SADDENED BY THE PASSING AWAY OF THREE TEACHERS FOLLOWING A CAR ACC...
MEC MAJUBA SADDENED BY THE PASSING AWAY OF THREE TEACHERS FOLLOWING A CAR ACC...MEC MAJUBA SADDENED BY THE PASSING AWAY OF THREE TEACHERS FOLLOWING A CAR ACC...
MEC MAJUBA SADDENED BY THE PASSING AWAY OF THREE TEACHERS FOLLOWING A CAR ACC...
 
Healthy Habits for Happy School Staff - presentation
Healthy Habits for Happy School Staff - presentationHealthy Habits for Happy School Staff - presentation
Healthy Habits for Happy School Staff - presentation
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
 
A LABORATORY MANUAL FOR ORGANIC CHEMISTRY.pdf
A LABORATORY MANUAL FOR ORGANIC CHEMISTRY.pdfA LABORATORY MANUAL FOR ORGANIC CHEMISTRY.pdf
A LABORATORY MANUAL FOR ORGANIC CHEMISTRY.pdf
 
Decision on Curriculum Change Path: Towards Standards-Based Curriculum in Ghana
Decision on Curriculum Change Path: Towards Standards-Based Curriculum in GhanaDecision on Curriculum Change Path: Towards Standards-Based Curriculum in Ghana
Decision on Curriculum Change Path: Towards Standards-Based Curriculum in Ghana
 
spring_bee_bot_creations_erd primary.pdf
spring_bee_bot_creations_erd primary.pdfspring_bee_bot_creations_erd primary.pdf
spring_bee_bot_creations_erd primary.pdf
 
CATCH UP FRIDAY LESSON PLAN GRADE 6.docx
CATCH UP FRIDAY LESSON PLAN GRADE 6.docxCATCH UP FRIDAY LESSON PLAN GRADE 6.docx
CATCH UP FRIDAY LESSON PLAN GRADE 6.docx
 
A Free eBook ~ Mental Exercise ...Puzzles to Analyze.pdf
A Free eBook ~ Mental Exercise ...Puzzles to Analyze.pdfA Free eBook ~ Mental Exercise ...Puzzles to Analyze.pdf
A Free eBook ~ Mental Exercise ...Puzzles to Analyze.pdf
 
A TEXTBOOK OF INTELLECTUAL ROPERTY RIGHTS
A TEXTBOOK OF INTELLECTUAL ROPERTY RIGHTSA TEXTBOOK OF INTELLECTUAL ROPERTY RIGHTS
A TEXTBOOK OF INTELLECTUAL ROPERTY RIGHTS
 
Advance Mobile Application Development class 04
Advance Mobile Application Development class 04Advance Mobile Application Development class 04
Advance Mobile Application Development class 04
 
11 CI SINIF SINAQLARI - 9-2023-Aynura-Hamidova.pdf
11 CI SINIF SINAQLARI - 9-2023-Aynura-Hamidova.pdf11 CI SINIF SINAQLARI - 9-2023-Aynura-Hamidova.pdf
11 CI SINIF SINAQLARI - 9-2023-Aynura-Hamidova.pdf
 
CLUBE PERLINGUAS .
CLUBE PERLINGUAS                        .CLUBE PERLINGUAS                        .
CLUBE PERLINGUAS .
 

Model Constraints - SQL Constraints Odoo 16

  • 1. Model Constraints - SQL Constraints Odoo 16
  • 2. ● SQL Constraints which are defined through the model attribute _sql_constraints. ● SQL Constraints also give the same purpose of python constraints. ● SQL Constraints helps to set validation for the recordsets,which act as a reminder for the user for the workflow.
  • 3. Types Of SQL Constraints 1. Not Null 2. Check 3. Unique
  • 4. How SQL Constraints Work Example Model: Class TestModel(model.Model): _name=’test.model’ _description=’Test Model’ name=fields.Char() channel_type=fields.Selection([(‘chat’,’Chat’),(‘channel’,’Channel’)]) probability=fields.Float()
  • 5. Not Null This constraint ensures that no field can be empty or null. Eg : _sql_constraints=[(‘channel_type_not_null’,’CHECK(channel_type IS NOT NULL)’,The Channel Type Cannot be Empty’)] ● This is a tuple that defines a single check constraint. ● The first member of the tuple “channel_type_not_null” is a string that defines the constraints name.The name may be whatever you like as long as it is unique to the model.
  • 6. Not Null ● The second member of the tuple,CHECK(channel_type IS NOT NULL), defines the check constraint.In this case ,the constraint checks whether the channel_type field is not null.If the channel_type field is null,the constraint will be violated and an error will be raised. ● The third member of the tuple,’The Channel Type Cannot be Empty’,is a string that provides an error message that will be displayed to the user if the constraint is violated.
  • 7. Check This Constraint allows users to define custom rules that must be met for a field. Check Constraint is a rule that restricts the data that can be inserted or updated in a table,to ensure data integrity and consistency. Eg : _sql_constraints=[(‘check_probabilty’,’CHECK(probability>=0 and probability<=0)’,The Probability should be Between 0% and 100%!’ )]
  • 8. Check ● The first member of the tuple “check_probability” is a string that defines the constraints name.The name may be whatever you like as long as it is unique to the model. ● The second member,checks the value of the “probability” field in the table between 0 and 100(inclusive) using the SQL “check” constraint. ● This is a tuple that defines a single check constraint.
  • 9. Unique This constraint ensures that each value in a field is unique. Eg : _sql_constraints = [(‘uniq_name_’,UNIQUE(name)’, ‘Name Must Be Unique’)] ● The First element is the constraint name ● The Second element defines unique constraint,In this case the constraint ensures that each value in the name fields is unique across all records in the table associated with the model. ● The Third element be the warning message.
  • 10. Check our company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo.