This question has been flagged
1 Reply
2519 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"
    on_change="onchange_meetings(meetings)">
    <tree string="Meetings">
        <field name="name" />
        <field name="begin_date" />
        <field name="end_date" />
    </tree>
</field>

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?

Avatar
Discard
Best Answer

Hi,

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.

Avatar
Discard