Odoo Help


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.


How to get the current content of a one2many field?

Juan Formoso
on 11/24/14, 8:02 AM 664 views

I declared an onchange function for a one2many field. What I want is to get the current value of the that field at the moment of the onchange. I did this:

<field name="meetings" required="1" nolabel="1"
    <tree string="Meetings">
        <field name="name" />
        <field name="begin_date" />
        <field name="end_date" />

I think it would be enough, but in the Python code, the variable meetings is giving me only the altered fields. For example, if I change only the begin_date, the variable meetings only returns the begin_date of one record and I can't get the rest of the records.

I need them because I want to know which is the earliest beginning date (comparing the begin_date of all the records) and the latest ending date (comparing the end_date of all the records). But to know that, I need to get all the current records of meetings, including even those which aren't stored in the database yet.

Can anyone help me, please?

Matt Choplin
On 11/26/14, 11:27 AM


can you please share what is the code of your onchange_meetings method?
In order to solve your issue, we need the id of the instance on which your are calling the onchange method.

I believe the signature of your method would be:

def onchange_meetings(self, cr, uid, id, meetings, context=None)

Then, if we have the id of the current record, we can loop over all the meetings and find the earliest begin_date and the oldest end_date.

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)


Asked: 11/24/14, 8:02 AM
Seen: 664 times
Last updated: 3/16/15, 8:10 AM