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.

0

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

By
Artur Bertram
on 8/4/14, 8:15 AM 956 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,
                    }
                wclist.append((wc_vals))
            #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?

1
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

Change 

    if fnames is None:

to

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

0

Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
4341
| 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

Artur,

It should be :

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

Thanks.

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: 8/4/14, 8:15 AM
Seen: 956 times
Last updated: 3/16/15, 8:10 AM