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

Is there a smooth way of transitioning the Task Summary to a dropdown list?

By
Scott Daniel Lentz
on 4/16/13, 12:57 PM 786 views

In project_report.py the Task Summary field is defined as:

_columns = {
    'name': fields.char('Task Summary', size=128, readonly=True),
    ...
}

Already, I have entered data into this field. Recently I convert it to a dropdown list, like this:

_columns = {
    'name': fields.selection([('do_this_task_first','Do This Task First'),
    ('do_this_task_next','Do This Task Next'),
    ('do_this_task_last', 'Do This Task Last')],
    'Task Summary', help="What the task is."),
}

But the previous data now shows as undefined. Is there an elegant way to keep the old data and assign it to one of the dropdown list options, or will all the previous tasks have to be re-entered?

I wonder if there's a way to specify that anything could be typed in, or pick one from the list.

Moore Works, Dale E. Moore
on 4/16/13, 5:54 PM

Do you have to accept from the fields.selection then in your module.py class move that data into the fields.char in the DB?

How would you coordinate reading the fields.char into the fields.selection when you get a different record?

Moore Works, Dale E. Moore
on 4/16/13, 6:40 PM
1
Scott Daniel Lentz
On 5/8/13, 4:44 PM

I was able to take care of the Task Summary as a dropdown box with two devices. First I created a new class to modify the original:

class task_summary_drop_down(osv.osv):
    _inherit = "project.task"
    _columns = {
        'name': fields.selection([(
        'What The Old Data Was For First','Do This Task First'),
        ('What The Old Data Was For Next','Do This Task Next'),
        ('What The Old Data Was For Last', 'Do This Task Last')],
        'Task Summary', help="Task to be completed."),
    }
task_summary_drop_down()

Note the second half of the solution, I changed the data (in the first set of single quotes) that is to be saved to the DB. It now exactly matches the characters that were already in the DB from the original data. And now (since the data matches) it displays normally in the view (not "Undefined" as before) as if it were selected from the dropdown.

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/16/13, 12:57 PM
Seen: 786 times
Last updated: 3/16/15, 8:10 AM