Odoo Help


onchange method on one2many ?

Farid Ghanchi
on 10/21/13, 9:34 AM 1,572 views

I have create on_change method on one2many field and set value in another one2many fields. Now First I have add two line in one2many and another one2many set then we saved. Saved successfully.But issue is now we update record and add another line(means Third line) so onchange method call and set another one2many fields unlink old two line and set new one. I need updated line set in third one.not old remove.I hope you understand.

    new_values = []
    res = {}
    self_rec  = self.browse(cr,uid,ids)[0]
    if data_sheet_sales_id:       
        for row in data_sheet_sales_id:
             product = self.pool.get('product.product').browse(cr, uid, row[2]['up_lighting_type'])
                              'location': row[2]['location'] or False,
                               'partner_name': self_rec.saver_name.id,
                               'up_lighting_type': row[2]['up_lighting_type'],
                               'qty_original': row[2]['qty_original'],
                               'qty_upgraded': row[2]['qty_upgraded'],
                               'hours_per_year': row[2]['hours_per_year'],
                               'unit_cost': product.list_price or 0.00,
                               'install_cost': product.installation_cost or 0.00,
                               'total_supply_ins': product.product_cost + product.installation_cost,
                               'max_min_discnt': product.max_min_discount or 0.00, 

    return {'value':{'sales_quotation_id':[{
                            'name': self_rec.saver_name.id,
                            'date_order': datetime.date.today().strftime('%Y-%m-%d'),
                            'order_line': new_values


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

0 follower(s)


Asked: 10/21/13, 9:34 AM
Seen: 1572 times
Last updated: 3/16/15, 8:10 AM