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 !!!
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 !!!