Odoo Help


How do i fill an one2many field with an on_change event in 8.0?

Artur Bertram
on 8/4/14, 8:15 AM 1,637 views

In v7 i could fill the one2many field with the following code, without creating an entry in the datebase.

from_template = self.pool.get('mrp.eq_routing_template').browse(cr, uid, routing_template, context)

            wclist = []
            #Creates the workcenter.lines and saves them in a list.
            for workcenter in from_template.eq_workcenter_lines:
                wc_vals = {
                    'workcenter_id': workcenter.eq_workcenter_id.id,
                    'name': workcenter.eq_name,
                    'sequence': workcenter.eq_sequence,
                    'cycle_nbr': workcenter.eq_cycle_nbr,
                    'hour_nbr': workcenter.eq_hour_nbr,
                    'note': workcenter.eq_note,
            #Data for the return
            vals_from_template = {
                'name': from_template.eq_name,
                'active': True,
                'code': from_template.eq_code,
                'note': from_template.eq_note,
                'location_id': from_template.eq_location_id.id,
                'workcenter_lines': wclist,
            return {'value': vals_from_template}

When i use this on_change Method with v8 it creates empty lines.

How am I able to do the same in v 8.0?

Wang Yue Ming
On 8/6/14, 1:47 AM

I think it is a bug in odoo 8.

I now accomplished it by hacking the line 1397 in ./server/openerp/fields.py file


    if fnames is None:


    if fnames is None or len(fnames) == 0:


Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
| 6 6 8
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. Your Odoo/OpenERP Solution, just an email away!

Serpent Consulting Services Pvt. Ltd.
On 8/4/14, 1:58 PM


It should be :

return {'value': {'one2many_field_name': [dictionary1, dictionary2]}}


About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 8/4/14, 8:15 AM
Seen: 1637 times
Last updated: 3/16/15, 8:10 AM