2
votes

I have this class that represents a URL bookmark

from openerp.osv import osv, fields

class jbbookmark_jbbookmark(osv.osv):

    _name = "jbbookmark.jbbookmark"
    _description = "Bookmark"

    def default_get(self, cr, uid, fields, context=None):
        res = super(jbbookmark_jbbookmark, self).default_get(cr, uid, fields,     context=context)

        res.update({'name': 'initial value test'})
        res.update({'description': 'initial value test'})
        return res

     _columns = {
         'name': fields.char('URL', required=True, translate=True),
         'description': fields.text('Description'),
         'title': fields.char('Name', size=20, required=True),
    }
     _defaults = {
         'name':'test URL',
    }

i try to set initial value of my form fields when i add a record, but the fields are just blank. How can i get these values to show in the form view

1

1 Answers

3
votes

You should assign the values to keys in the dictionary rather than updating.

This will work for sure.

def default_get(self, cr, uid, fields, context=None):
    res = super(jbbookmark_jbbookmark, self).default_get(cr, uid, fields,     context=context)
    res['name'] = 'initial value test'
    res['description'] = 'initial value test'
    return res