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

Year to Display in Range

By
Arun
on 6/17/13, 10:45 AM 1,048 views

I have a requirement to display year in the field='year of passing' , I created this field as selection. But my values should be 1965 - 2020. Its very hard to hardcore the values is there any option to auto generate the year in range of 5 0r 10

3

Sandeep

--Sandeep--
6083
| 6 5 8
Delhi, India
--Sandeep--
Python OpenERP Developer http://in.linkedin.com/pub/sandeep-rana/3b/a16/786/
Sandeep
On 6/17/13, 10:52 AM

Hi

you should create a dynamic or functional selection field ( based on object) and create function that use the python timeand date module so you can give range in that function from start to end (1965 to 2020) so all the year can be created at once in that object and then you will see all the year's in selection field

Thanks
Sandeep

0

answered just now Arun gravatar image Arun 21 ● 1

Thanks Sandeep, If i want to select only 5 years dynamically based on 5 years how sholu i achieve that Ex : current year is 2013 , so my selection value should show only 2013-2018 and then if i again edit the field to 2018 it sholud show 2018-2023 :-) i s any way to achieve this

Arun
on 6/24/13, 3:50 AM
0
Arun
On 6/24/13, 3:50 AM

Thanks Sandeep, If i want to select only 5 years dynamically based on 5 years how sholu i achieve that Ex : current year is 2013 , so my selection value should show only 2013-2018 and then if i again edit the field to 2018 it sholud show 2018-2023 :-) i s any way to achieve this

0

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


Ahmed M.Elmubarak
On 6/24/13, 4:46 AM

Hello, You can specify a function to populate your selection field like this

    _columns = {
   'sel' : fields.selection(
       _get_selection,
       'What do you want ?')
}

and the function could be like:

def _get_selection(self, cursor, user_id, context=None):
    return (
       ('choice1', 'This is the choice 1'),
       ('choice2', 'This is the choice 2'))

as mentioned on the website... but the problem is that the selection field populated only when the form/tree loaded and it couldn't be dynamic 'as I know' thanks....

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: 6/17/13, 10:45 AM
Seen: 1048 times
Last updated: 3/16/15, 8:10 AM