SlideShare a Scribd company logo
How to Setup Default Value
for a Field in Odoo 17
Enterprise
Introduction
Enterprise
In Odoo, we can set a default value for a field during the
creation of a record for a model. We have many methods in
odoo for setting a default value to the field.
1. Passing Values Through Kwargs
2. Setting value with default_get function
Enterprise
Passing Values Through Kwargs
● A field can have numerous kwargs specified, such as
necessary, read-only, and many more.
● The Kwargs are special symbols used to pass arguments,
known as keyword arguments.
● kwarg is the default, which aids in setting a field's default
value at the moment a model is created.
Enterprise
1. Set Values Directly
● In this, 'state' field is a selection field and the default value
of the 'state' field is set as draft i.e, Draft.
state = fields.Selection([('draft', 'Draft'),
('posted', 'Posted'),('cancel', 'Cancelled')],
default='draft')
Enterprise
Enterprise
2. Set Values using default lambda function
● The syntax of the lambda function:
lambda arguments: expression
user_id = fields.Many2one(
'res.users', string='Salesperson',
default=lambda self:self.env.user,
Enterprise
Enterprise
3. Execute a function and return values
def _default_employee(self):
return self.env.user.employee_id
employee_id = fields.Many2one('hr.employee',
string="Employee",default=_default_employee,
required=True, ondelete='cascade', index=True)
Enterprise
● In the execute a function and return values method, we
can set the default value of the field by executing a
function.
● define a function _default_employee() and then define a
field employee_id and set default=_default_employee.
Enterprise
Enterprise
Setting value with default_get function
● To setting default values for custom fields using the
default_get function in Odoo, you can define a method
named default_get within your model class.
● This method should return a dictionary where the keys are
the field names and the values are the default values you
want to set.
Enterprise
class SaleOrder(models.Model):
_inherit = 'sale.order'
sales_person_contact = fields.Many2one('res.partner',
string="Salesperson
Contact")
sales_person_email = fields.Char(string="Salesperson Email")
@api.model
def default_get(self, fields):
res = super(SaleOrder, self).default_get(fields)
res.update({
'sales_person_contact': self.env.user.partner_id.id
or False,
'sales_person_email' : self.env.user.partner_id.email
or False
})
return res
Enterprise
● In this example, when a new record of SaleOrder is created, the
default_get function will be called automatically, and it will return
a dictionary containing default values for the specified fields
(sales_person_contact and sales_person_email). These default
values will be populated in the form when creating a new record
unless overridden by the user.
● You can adjust the default values as per your requirements in the
default_get method. This method allows you to dynamically set
default values based on certain conditions if needed.
For More Info.
Check our company website for related
blogs and Odoo book.
Check our YouTube channel for
functional and technical videos in Odoo.
Enterprise
www.cybrosys.com
Ad

More Related Content

What's hot (11)

Oracle hcm cloud configuring approval workflow
Oracle hcm cloud configuring approval workflowOracle hcm cloud configuring approval workflow
Oracle hcm cloud configuring approval workflow
Feras Ahmad
 
10. Το Παλάτι, ο Ιππόδρομος και οι Δήμοι
10. Το Παλάτι, ο Ιππόδρομος και οι Δήμοι10. Το Παλάτι, ο Ιππόδρομος και οι Δήμοι
10. Το Παλάτι, ο Ιππόδρομος και οι Δήμοι
Maniatis Kostas
 
Sap FICO Resume
Sap FICO Resume Sap FICO Resume
Sap FICO Resume
MuhammadAleem55
 
SAP CO step by step config guide & user manual part 1
SAP CO step by step config guide & user manual part 1SAP CO step by step config guide & user manual part 1
SAP CO step by step config guide & user manual part 1
Srinivas Kasireddy
 
Script logic primer-bpc_nw
Script logic primer-bpc_nwScript logic primer-bpc_nw
Script logic primer-bpc_nw
Erptimal RA
 
App b intercompanytrans
App b intercompanytransApp b intercompanytrans
App b intercompanytrans
Naresh Kumar SAHU
 
Personalization how to restrict transaction type list of values
Personalization how to restrict transaction type list of valuesPersonalization how to restrict transaction type list of values
Personalization how to restrict transaction type list of values
Ahmed Elshayeb
 
How to Create Aged Receivables & Payable Reports in Odoo 15
How to Create Aged Receivables & Payable Reports in Odoo 15How to Create Aged Receivables & Payable Reports in Odoo 15
How to Create Aged Receivables & Payable Reports in Odoo 15
Celine George
 
SAP BCM.pdf
SAP BCM.pdfSAP BCM.pdf
SAP BCM.pdf
raman2664
 
Oracle Fusion Employment Models
Oracle Fusion Employment ModelsOracle Fusion Employment Models
Oracle Fusion Employment Models
Feras Ahmad
 
JV SAP Practice.pptx
JV SAP Practice.pptxJV SAP Practice.pptx
JV SAP Practice.pptx
Ekhlesia1
 
Oracle hcm cloud configuring approval workflow
Oracle hcm cloud configuring approval workflowOracle hcm cloud configuring approval workflow
Oracle hcm cloud configuring approval workflow
Feras Ahmad
 
10. Το Παλάτι, ο Ιππόδρομος και οι Δήμοι
10. Το Παλάτι, ο Ιππόδρομος και οι Δήμοι10. Το Παλάτι, ο Ιππόδρομος και οι Δήμοι
10. Το Παλάτι, ο Ιππόδρομος και οι Δήμοι
Maniatis Kostas
 
SAP CO step by step config guide & user manual part 1
SAP CO step by step config guide & user manual part 1SAP CO step by step config guide & user manual part 1
SAP CO step by step config guide & user manual part 1
Srinivas Kasireddy
 
Script logic primer-bpc_nw
Script logic primer-bpc_nwScript logic primer-bpc_nw
Script logic primer-bpc_nw
Erptimal RA
 
Personalization how to restrict transaction type list of values
Personalization how to restrict transaction type list of valuesPersonalization how to restrict transaction type list of values
Personalization how to restrict transaction type list of values
Ahmed Elshayeb
 
How to Create Aged Receivables & Payable Reports in Odoo 15
How to Create Aged Receivables & Payable Reports in Odoo 15How to Create Aged Receivables & Payable Reports in Odoo 15
How to Create Aged Receivables & Payable Reports in Odoo 15
Celine George
 
Oracle Fusion Employment Models
Oracle Fusion Employment ModelsOracle Fusion Employment Models
Oracle Fusion Employment Models
Feras Ahmad
 
JV SAP Practice.pptx
JV SAP Practice.pptxJV SAP Practice.pptx
JV SAP Practice.pptx
Ekhlesia1
 

Similar to How to Setup Default Value for a Field in Odoo 17 (20)

Set Default Values to Fields in Odoo 15
Set Default Values to Fields in Odoo 15Set Default Values to Fields in Odoo 15
Set Default Values to Fields in Odoo 15
Celine George
 
Setting Default Value for Fields in Odoo 16
Setting Default Value for Fields in Odoo 16Setting Default Value for Fields in Odoo 16
Setting Default Value for Fields in Odoo 16
Celine George
 
ADBMS ASSIGNMENT
ADBMS ASSIGNMENTADBMS ASSIGNMENT
ADBMS ASSIGNMENT
Lori Moore
 
What is Property Fields in Odoo 17 ERP Module
What is Property Fields in Odoo 17 ERP ModuleWhat is Property Fields in Odoo 17 ERP Module
What is Property Fields in Odoo 17 ERP Module
Celine George
 
Presentation of the new OpenERP API. Raphael Collet, OpenERP
Presentation of the new OpenERP API. Raphael Collet, OpenERPPresentation of the new OpenERP API. Raphael Collet, OpenERP
Presentation of the new OpenERP API. Raphael Collet, OpenERP
Odoo
 
Flex Maniacs 2007
Flex Maniacs 2007Flex Maniacs 2007
Flex Maniacs 2007
rtretola
 
How to Load Custom Field to POS in Odoo 17 - Odoo 17 Slides
How to Load Custom Field to POS in Odoo 17 - Odoo 17 SlidesHow to Load Custom Field to POS in Odoo 17 - Odoo 17 Slides
How to Load Custom Field to POS in Odoo 17 - Odoo 17 Slides
Celine George
 
How to Customize POS Receipts in the Odoo 17
How to Customize POS Receipts in the Odoo 17How to Customize POS Receipts in the Odoo 17
How to Customize POS Receipts in the Odoo 17
Celine George
 
AngularJS
AngularJSAngularJS
AngularJS
LearningTech
 
How to Super Create Write Functions in Odoo 17
How to Super Create Write Functions in Odoo 17How to Super Create Write Functions in Odoo 17
How to Super Create Write Functions in Odoo 17
Celine George
 
Filters in AngularJS
Filters in AngularJSFilters in AngularJS
Filters in AngularJS
Brajesh Yadav
 
Oracle: Basic SQL
Oracle: Basic SQLOracle: Basic SQL
Oracle: Basic SQL
oracle content
 
Oracle: Basic SQL
Oracle: Basic SQLOracle: Basic SQL
Oracle: Basic SQL
DataminingTools Inc
 
Patterns in PHP
Patterns in PHPPatterns in PHP
Patterns in PHP
Diego Lewin
 
PyCon KR 2018 Effective Tips for Django ORM in Practice
PyCon KR 2018 Effective Tips for Django ORM in PracticePyCon KR 2018 Effective Tips for Django ORM in Practice
PyCon KR 2018 Effective Tips for Django ORM in Practice
Seomgi Han
 
Function oneshot with python programming .pptx
Function oneshot with python programming .pptxFunction oneshot with python programming .pptx
Function oneshot with python programming .pptx
lionsconvent1234
 
How to add Many2Many fields in odoo website form.pptx
How to add Many2Many fields in odoo website form.pptxHow to add Many2Many fields in odoo website form.pptx
How to add Many2Many fields in odoo website form.pptx
Celine George
 
What is Monkey Patching & How It Can Be Applied in Odoo 17
What is Monkey Patching & How It Can Be Applied in Odoo 17What is Monkey Patching & How It Can Be Applied in Odoo 17
What is Monkey Patching & How It Can Be Applied in Odoo 17
Celine George
 
Day1Structured_Query_Lang3For PL SQL Notes.ppt
Day1Structured_Query_Lang3For PL SQL Notes.pptDay1Structured_Query_Lang3For PL SQL Notes.ppt
Day1Structured_Query_Lang3For PL SQL Notes.ppt
consravs
 
How to Use Filtered Function in Odoo 17 - Odoo Slides
How to Use Filtered Function in Odoo 17 - Odoo SlidesHow to Use Filtered Function in Odoo 17 - Odoo Slides
How to Use Filtered Function in Odoo 17 - Odoo Slides
Celine George
 
Set Default Values to Fields in Odoo 15
Set Default Values to Fields in Odoo 15Set Default Values to Fields in Odoo 15
Set Default Values to Fields in Odoo 15
Celine George
 
Setting Default Value for Fields in Odoo 16
Setting Default Value for Fields in Odoo 16Setting Default Value for Fields in Odoo 16
Setting Default Value for Fields in Odoo 16
Celine George
 
ADBMS ASSIGNMENT
ADBMS ASSIGNMENTADBMS ASSIGNMENT
ADBMS ASSIGNMENT
Lori Moore
 
What is Property Fields in Odoo 17 ERP Module
What is Property Fields in Odoo 17 ERP ModuleWhat is Property Fields in Odoo 17 ERP Module
What is Property Fields in Odoo 17 ERP Module
Celine George
 
Presentation of the new OpenERP API. Raphael Collet, OpenERP
Presentation of the new OpenERP API. Raphael Collet, OpenERPPresentation of the new OpenERP API. Raphael Collet, OpenERP
Presentation of the new OpenERP API. Raphael Collet, OpenERP
Odoo
 
Flex Maniacs 2007
Flex Maniacs 2007Flex Maniacs 2007
Flex Maniacs 2007
rtretola
 
How to Load Custom Field to POS in Odoo 17 - Odoo 17 Slides
How to Load Custom Field to POS in Odoo 17 - Odoo 17 SlidesHow to Load Custom Field to POS in Odoo 17 - Odoo 17 Slides
How to Load Custom Field to POS in Odoo 17 - Odoo 17 Slides
Celine George
 
How to Customize POS Receipts in the Odoo 17
How to Customize POS Receipts in the Odoo 17How to Customize POS Receipts in the Odoo 17
How to Customize POS Receipts in the Odoo 17
Celine George
 
How to Super Create Write Functions in Odoo 17
How to Super Create Write Functions in Odoo 17How to Super Create Write Functions in Odoo 17
How to Super Create Write Functions in Odoo 17
Celine George
 
Filters in AngularJS
Filters in AngularJSFilters in AngularJS
Filters in AngularJS
Brajesh Yadav
 
PyCon KR 2018 Effective Tips for Django ORM in Practice
PyCon KR 2018 Effective Tips for Django ORM in PracticePyCon KR 2018 Effective Tips for Django ORM in Practice
PyCon KR 2018 Effective Tips for Django ORM in Practice
Seomgi Han
 
Function oneshot with python programming .pptx
Function oneshot with python programming .pptxFunction oneshot with python programming .pptx
Function oneshot with python programming .pptx
lionsconvent1234
 
How to add Many2Many fields in odoo website form.pptx
How to add Many2Many fields in odoo website form.pptxHow to add Many2Many fields in odoo website form.pptx
How to add Many2Many fields in odoo website form.pptx
Celine George
 
What is Monkey Patching & How It Can Be Applied in Odoo 17
What is Monkey Patching & How It Can Be Applied in Odoo 17What is Monkey Patching & How It Can Be Applied in Odoo 17
What is Monkey Patching & How It Can Be Applied in Odoo 17
Celine George
 
Day1Structured_Query_Lang3For PL SQL Notes.ppt
Day1Structured_Query_Lang3For PL SQL Notes.pptDay1Structured_Query_Lang3For PL SQL Notes.ppt
Day1Structured_Query_Lang3For PL SQL Notes.ppt
consravs
 
How to Use Filtered Function in Odoo 17 - Odoo Slides
How to Use Filtered Function in Odoo 17 - Odoo SlidesHow to Use Filtered Function in Odoo 17 - Odoo Slides
How to Use Filtered Function in Odoo 17 - Odoo Slides
Celine George
 
Ad

More from Celine George (20)

How to Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 SalesHow to Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 Sales
Celine George
 
How to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale OrderHow to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale Order
Celine George
 
How to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 InventoryHow to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 Inventory
Celine George
 
How to Use Upgrade Code Command in Odoo 18
How to Use Upgrade Code Command in Odoo 18How to Use Upgrade Code Command in Odoo 18
How to Use Upgrade Code Command in Odoo 18
Celine George
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
How to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo SlidesHow to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo Slides
Celine George
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
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 Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 SalesHow to Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 Sales
Celine George
 
How to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale OrderHow to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale Order
Celine George
 
How to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 InventoryHow to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 Inventory
Celine George
 
How to Use Upgrade Code Command in Odoo 18
How to Use Upgrade Code Command in Odoo 18How to Use Upgrade Code Command in Odoo 18
How to Use Upgrade Code Command in Odoo 18
Celine George
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
How to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo SlidesHow to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo Slides
Celine George
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
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
 
Ad

Recently uploaded (20)

INSULIN.pptx by Arka Das (Bsc. Critical care technology)
INSULIN.pptx by Arka Das (Bsc. Critical care technology)INSULIN.pptx by Arka Das (Bsc. Critical care technology)
INSULIN.pptx by Arka Das (Bsc. Critical care technology)
ArkaDas54
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
MICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdfMICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdf
DHARMENDRA SAHU
 
COPA Apprentice exam Questions and answers PDF
COPA Apprentice exam Questions and answers PDFCOPA Apprentice exam Questions and answers PDF
COPA Apprentice exam Questions and answers PDF
SONU HEETSON
 
IPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdf
IPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdfIPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdf
IPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdf
Quiz Club of PSG College of Arts & Science
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docxPeer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
19lburrell
 
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdfGENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
Quiz Club of PSG College of Arts & Science
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
The History of Kashmir Lohar Dynasty NEP.ppt
The History of Kashmir Lohar Dynasty NEP.pptThe History of Kashmir Lohar Dynasty NEP.ppt
The History of Kashmir Lohar Dynasty NEP.ppt
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
Look Up, Look Down: Spotting Local History Everywhere
Look Up, Look Down: Spotting Local History EverywhereLook Up, Look Down: Spotting Local History Everywhere
Look Up, Look Down: Spotting Local History Everywhere
History of Stoke Newington
 
Module_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptxModule_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptx
drroxannekemp
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
Quiz Club of PSG College of Arts & Science
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
libbys peer assesment.docx..............
libbys peer assesment.docx..............libbys peer assesment.docx..............
libbys peer assesment.docx..............
19lburrell
 
INSULIN.pptx by Arka Das (Bsc. Critical care technology)
INSULIN.pptx by Arka Das (Bsc. Critical care technology)INSULIN.pptx by Arka Das (Bsc. Critical care technology)
INSULIN.pptx by Arka Das (Bsc. Critical care technology)
ArkaDas54
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
MICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdfMICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdf
DHARMENDRA SAHU
 
COPA Apprentice exam Questions and answers PDF
COPA Apprentice exam Questions and answers PDFCOPA Apprentice exam Questions and answers PDF
COPA Apprentice exam Questions and answers PDF
SONU HEETSON
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docxPeer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
19lburrell
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
Look Up, Look Down: Spotting Local History Everywhere
Look Up, Look Down: Spotting Local History EverywhereLook Up, Look Down: Spotting Local History Everywhere
Look Up, Look Down: Spotting Local History Everywhere
History of Stoke Newington
 
Module_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptxModule_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptx
drroxannekemp
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
libbys peer assesment.docx..............
libbys peer assesment.docx..............libbys peer assesment.docx..............
libbys peer assesment.docx..............
19lburrell
 

How to Setup Default Value for a Field in Odoo 17

  • 1. How to Setup Default Value for a Field in Odoo 17 Enterprise
  • 2. Introduction Enterprise In Odoo, we can set a default value for a field during the creation of a record for a model. We have many methods in odoo for setting a default value to the field. 1. Passing Values Through Kwargs 2. Setting value with default_get function
  • 3. Enterprise Passing Values Through Kwargs ● A field can have numerous kwargs specified, such as necessary, read-only, and many more. ● The Kwargs are special symbols used to pass arguments, known as keyword arguments. ● kwarg is the default, which aids in setting a field's default value at the moment a model is created.
  • 4. Enterprise 1. Set Values Directly ● In this, 'state' field is a selection field and the default value of the 'state' field is set as draft i.e, Draft. state = fields.Selection([('draft', 'Draft'), ('posted', 'Posted'),('cancel', 'Cancelled')], default='draft')
  • 6. Enterprise 2. Set Values using default lambda function ● The syntax of the lambda function: lambda arguments: expression user_id = fields.Many2one( 'res.users', string='Salesperson', default=lambda self:self.env.user,
  • 8. Enterprise 3. Execute a function and return values def _default_employee(self): return self.env.user.employee_id employee_id = fields.Many2one('hr.employee', string="Employee",default=_default_employee, required=True, ondelete='cascade', index=True)
  • 9. Enterprise ● In the execute a function and return values method, we can set the default value of the field by executing a function. ● define a function _default_employee() and then define a field employee_id and set default=_default_employee.
  • 11. Enterprise Setting value with default_get function ● To setting default values for custom fields using the default_get function in Odoo, you can define a method named default_get within your model class. ● This method should return a dictionary where the keys are the field names and the values are the default values you want to set.
  • 12. Enterprise class SaleOrder(models.Model): _inherit = 'sale.order' sales_person_contact = fields.Many2one('res.partner', string="Salesperson Contact") sales_person_email = fields.Char(string="Salesperson Email") @api.model def default_get(self, fields): res = super(SaleOrder, self).default_get(fields) res.update({ 'sales_person_contact': self.env.user.partner_id.id or False, 'sales_person_email' : self.env.user.partner_id.email or False }) return res
  • 13. Enterprise ● In this example, when a new record of SaleOrder is created, the default_get function will be called automatically, and it will return a dictionary containing default values for the specified fields (sales_person_contact and sales_person_email). These default values will be populated in the form when creating a new record unless overridden by the user. ● You can adjust the default values as per your requirements in the default_get method. This method allows you to dynamically set default values based on certain conditions if needed.
  • 14. For More Info. Check our company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo. Enterprise www.cybrosys.com
  翻译: