Odoo Help


Why does a function field show [object Object] in the view?

on 8/29/14, 3:03 PM 1,271 views


  I have a function field that returns a string.  The string is supposed to be a url pointing to a pdf file on the server.  I have the function created and I know that the correct url is getting generated.  The problem is that string is not showing correctly on the view.

The field on the view is using a 'url' widget so that it becomes a hyperlink that can be clicked

The link looks like this right now:  http://[object Object]

I would like it to show something like this:  http://127.0.01/document_folder/some_pdf_file.pdf

Here is my python function:

def _append_inv_url_2_uuid(self, cr, uid, ids, field, args, context=None):
        res = {}
        for rec in self.browse(cr, uid, ids, context):
            # look up the invoice url by the key name instead of the value.
            # this way if the value changes then no changes will have to be made here
            def_url_id = self.pool.get('ir.config_parameter').search(cr, uid, [('key','=','Invoice uuid URL')])[0]
            # get the value of the url key
            url_str = self.pool.get('ir.config_parameter').browse(cr, uid, def_url_id).value

            # get the uuid from the sale order
            uuid = "so?id=%s" % self.browse(cr, uid, ids[0]).uuid

            whole_string = "%s%s" % (url_str, uuid)
            res.update({rec.id: {'invoice_url': str(whole_string)}})
        return res


Here is the field in the form view:   <field name="invoice_url" widget="url" />


Grover Menacho

--Grover Menacho--
| 5 7 8
La Paz, Bolivia
--Grover Menacho--

Odoo Developer

Grover Menacho
On 8/29/14, 3:16 PM

Because your field is not multi, so you have {'invoice_url': 'URL'} on that field instead the URL. You have to return

res.update({rec.id: str(whole_string)})

Thank you Grover! That fixed my problem

on 8/29/14, 5:13 PM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 8/29/14, 3:03 PM
Seen: 1271 times
Last updated: 3/16/15, 8:10 AM