odoo: write function save old data
<p>I created an onchange function that link some object lines to the current one</p>

<pre><code>mo_lines_g1 = fields.One2many(comodel_name='object.order', inverse_name='mo_id1', copy=False )

@api.onchange('date')
def change_date(self):  
    if self.date:
        g1=self.env['object.order'].search(['&amp;'('date_order','&gt;=',self.date),('date_order','&lt;=',self.date)])
        self.mo_lines_g1 = [(6,0, g1.ids )]
</code></pre>

<p>here everything is ok, but when I save the view, Odoo try to delete the linked lines from the <code>object.order</code> 
<br/>
so I tried to see what the write function send I found it send the old records  :<br/>
 <code>vals[ 'mo_lines_g1'] = [[2, 61, False], [2, 62, False], [2, 63, False]]</code>
<br/>
normaly it must be :<br/> <code>vals['mo_lines_g1']=[] # or [(6,0,[])]</code>
<br/>
any ideas ?</p>

<p>I think there is a bug on v8, it doesn't work automaticly <br/>
I replaced the <code>(2,id,_)</code>  in the vals with <code>(3,id,_)</code> on the <strong>write</strong> funciton </p>

<pre><code>@api.multi
def write(self, vals): 
    if vals.has_key('mo_lines_g1'):
        g1=[]
        for line in vals['mo_lines_g1']:
            if line[0] == 2:
                line[0]=3  
            g1.append(line)
     return super(object_order, self).write( vals)
</code></pre>

python openerp edit v8