Thursday 28 May 2015

How to set default value in Odoo ?

When User open a form view at that time default value display and than after save record it will display value based on our requirement.

Here is char type field example which will display a string before save record default and than it will show different string.

We will use function filed for that. This field will not take input from the user click that will only used for information purpose.

Here is code example:

def _default_get(self, cr, uid, context=None):
    print " This function called before new record create "
    res = 'bhavesh'
    return res     

def _set_value(self, cr, uid, ids, name, args, context=None):
    print " This function called at time of saving record and form view load "
    res = {}
    for i in self.browse(cr, uid, ids, context=context):
        res[i.id] = 'odedra'
    return res

_columns = {
    'value': fields.function(_set_value, type='char', string='Value'),
}

_defaults = {
    'value': _default_get,
}

I hope you like this article. Share your views to improve content. Happy Learning !!! 

ImportError: cannot import name 'utils' from 'PyPDF2'

Odoo 15: Traceback (most recent call last):   File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner     self...