This question has been flagged
1 Reply
2590 Views

Hi everyone.

I have the form where there are a lot of fields. And there is the only button to operate with the fields.

So, my problem is: I need to get data from all fields (all of them - boolean) and correct it with my program. How can I do that?

P.S. the form is located on popup window, if it's important

Thanks

Avatar
Discard
Best Answer

In some function in your model's class, cycle through all of self._columns and store the output of each.

class my_model(osv.osv):
    _name = 'my.model'

    # ...

    def some_action(self, cr, uid, ids, context=None):
        if context is None: context = {}
        output = {}
        for my_model_rec in self.browse(cr, uid, ids, context=context):
            output[my_model_rec.id] = {}
            for col in self._columns:
                output[my_model_rec.id][col['name']] = my_model_rec[col['name']]
        return output

The output should look something like this:

{
    1: {
        'field_one': True,
        'field_two': False,
    }
}
Avatar
Discard