This question has been flagged
1 Reply
3005 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?

Avatar
Discard

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

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?

Author Best Answer

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.

Avatar
Discard