How to Set Default Values
to Fields in Odoo 15
www.cybrosys.com
INTRODUCTION
 In Odoo, sometimes we have to set a specific value for a field by default every time we
create a record of that model.
 Set default value for fields have several methods in this slide we discuss some of that
methods
Passing value through kwargs
A field in Odoo has multiple kwargs namely string, read-only, required, etc. Among one of them is
the kwarg called default.
We can pass a value through default kwarg in different ways
● set values directly
● set values using default lambda function
● execute a function and return values
Set values directly
We can set the default value directly by assigning the value like this.
Create a new record on that model the default value is today’s date.
Set value using default lambda function
For returning a value from a function t, we can run an anonymous lambda function or write the
function name to be called.
Execute a function and return values
To compute a default value through a function call, the function should be defined before
the field is defined.
Creating a new record the all default fields will be fill automatically
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 Set Default Values to Fields in Odoo 15
Thank You

Set Default Values to Fields in Odoo 15

  • 1.
    How to SetDefault Values to Fields in Odoo 15 www.cybrosys.com
  • 2.
    INTRODUCTION  In Odoo,sometimes we have to set a specific value for a field by default every time we create a record of that model.  Set default value for fields have several methods in this slide we discuss some of that methods
  • 3.
    Passing value throughkwargs A field in Odoo has multiple kwargs namely string, read-only, required, etc. Among one of them is the kwarg called default. We can pass a value through default kwarg in different ways ● set values directly ● set values using default lambda function ● execute a function and return values
  • 4.
    Set values directly Wecan set the default value directly by assigning the value like this. Create a new record on that model the default value is today’s date.
  • 5.
    Set value usingdefault lambda function For returning a value from a function t, we can run an anonymous lambda function or write the function name to be called.
  • 6.
    Execute a functionand return values To compute a default value through a function call, the function should be defined before the field is defined.
  • 7.
    Creating a newrecord the all default fields will be fill automatically
  • 8.
    For More Details Check ourcompany website for related blogs and Odoo book. Odoo Book V15 Check our YouTube channel for functional and technical videos in Odoo. How to Set Default Values to Fields in Odoo 15
  • 10.