Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Default value in form view

on 4/21/16, 4:13 AM 919 views

i want my field int the form <when i create a new record> to have some text inside like

when we use placeholder but i want it to be a value not a place holder

how can i do that :

     i tried  <field  name="may_field" value="my_value"/>

                 <field name⁼"may_field" default="my_value"/>

but nothing



| 6 5 7
Tbilisi, Georgia
On 4/21/16, 5:59 AM

If you like to set default value in XML, for a particular page or view, than you can consider following option: In the "action" record that opens your Form View, you can add an entry in a "context" dictionary, like this:

"default_field_name" : "default value for field_name field",

so that key should be the field's name prefixed by "default_" and value should be whatever you like to be default value for that field in this form.


Prakash Sharma

--Prakash Sharma--
| 2 1 4
Delhi, India
--Prakash Sharma--

I like to surround myself with brave, creative people.

My motivation for learning different technologies and algos drive me. I love challenges of a steep learning curve which I believe makes me a better learner. I have a strong desire to learn different technologies, which would enable me to become a full stack developer.

Prakash Sharma
On 4/21/16, 4:21 AM

Try it another ways

Here is step for filling default  value in ODOO8/9.

  1. Go to Setting->Technical->Actions->User defined Defaults.

  2. Create a record  for your model.

  3. Inside name place your filed name(my_field).

  4. Inside model place your model name(my.model).

  5. inside Default value  place the default value (my_value) 

In python you can do it this way:

link_text = fields.Char(string='Link Text',default='Size Guide',required=True)
On 4/21/16, 5:02 AM

You have to do this in .py file

Some examples from  sale.py

Odoo 9:

  • date_order = fields.Datetime(string='Order Date', required=True, readonly=True, index=True, states={'draft': [('readonly',     False)], 'sent': [('readonly', False)]}, copy=False, default=fields.Datetime.now)

  • price_unit = fields.Float('Unit Price', required=True, digits=dp.get_precision('Product Price'), default=0.0)

Odoo 8:

'date_order': fields.datetime('Date', required=True, readonly=True, select=True, states={'draft': [('readonly', False)], 'sent':     [('readonly', False)]}, copy=False),

'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Product Price'), readonly=True,     states={'draft': [('readonly', False)]}),

_defaults = {

        'date_order': fields.datetime.now,

        'price_unit': 0.0,


On 4/21/16, 4:31 AM

i want to do this in code when i write my form structure



     <field name="field_name" value="defaul_value"/> // when i clique on create button my field will have the value defaul_value not empty text did understand me


link_text = fields.Char(string='Link Text',default='Size Guide',required=True)

Prakash Sharma
on 4/21/16, 5:43 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 4/21/16, 4:13 AM
Seen: 919 times
Last updated: 7/21/16, 4:37 PM