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.

1

Error While trying to return value

By
DM
on 4/20/15, 8:33 AM 587 views

Hello Odoo Community,
I got a issue i was trying to return the results, the strange thing is on the log i can see corrent value Result 58.77 but if i add return the same value it get

new_values = dict(values)

ValueError: dictionary update sequence element #0 has length 1; 2 is required

If i add        

return {'distance':("%.2f" % round(distance,2))}

I get error:

vals[f] = res2[vals['id']]

KeyError: 276


My code:

class launch_map(osv.osv):

_inherit = "res.partner" 

def open_map2(self, cr, uid, ids, R, lat1, lon1, context=None):

R = 3961.0

partner = self.browse(cr, uid, ids[0], context=context)

lat2 = radians(partner.partner_latitude)

lon2 = radians(partner.partner_longitude)

lat1 = radians(51.749204)

lon1 = radians(-1.258504)

dlon = lon2 - lon1

dlat = lat2 - lat1

a = (sin(dlat/2))**2 + cos(lat1) * cos(lat2) * (sin(dlon/2))**2

c = 2 * atan2(sqrt(a), sqrt(1-a))

distance = R * c

print partner.partner_latitude

print partner.partner_longitude

print "Result", distance

print ("%.2f" % round(distance,2))

return ("%.2f" % round(distance,2))


Any examples and assistance would be appreaciated

Thank you,

could you please provide the field defined also?

Omal Bastin
on 9/24/15, 2:22 AM

I think the call to the method you have defined is coming from the functional field. If yes, then from your functional field, please remove the attribute 'multi'.

Omal Bastin
on 9/24/15, 2:25 AM
1
DM
On 4/21/15, 8:42 AM

Nvm Solved it

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: 4/20/15, 8:33 AM
Seen: 587 times
Last updated: 10/23/15, 9:18 AM