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

Can selection fields save floats to the DB or just integers and strings?

By
Eric
on 3/5/14, 1:58 PM 1,412 views

Hello, I am creating a module with a selection field. I would like a float number to be saved to the DB when a user selects a choice from the selection drop down, but when I make a selection then I get an error like this:

DataError: invalid input syntax for integer: "0.25"

So my question is, can floating numbers be used as values for a selection field, or can you use only integers or strings? Thank you

0

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 3/6/14, 2:29 AM

Yes Selection Field value save characters or Integer in Database.

Format of the selection parameter: tuple of tuples of strings of the form: (('key_or_value', 'string_to_display'), ... )

The below code shows display float value as string in Front view and Back-end store key value.

 'type': fields.selection([('CodeA', '0.25'), ('CodeB', '0.50')], 'Type'),

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

0 follower(s)

Stats

Asked: 3/5/14, 1:58 PM
Seen: 1412 times
Last updated: 3/16/15, 8:10 AM