Odoo Help

Welcome!

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.

0

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

By
Eric
on 8/29/14, 3:03 PM 835 views

Hello

  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" />

1

Grover Menacho

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

Systems Engineer + MBA

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

Eric
on 8/29/14, 5:13 PM

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)

Stats

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