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.

2

Odoo8. Get data from all fields from a form

By
Keywoker
on 2/26/15, 1:34 PM 523 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

0

Brett Lehrer

--Brett Lehrer--
1252
| 5 4 8
Milwaukee, United States
--Brett Lehrer--
Director of IT and open source enthusiast.
Brett Lehrer
On 4/16/15, 11:44 PM

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,
    }
}

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: 2/26/15, 1:34 PM
Seen: 523 times
Last updated: 4/16/15, 11:44 PM