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

onchange method on one2many ?

By
Farid Ghanchi
on 10/21/13, 9:34 AM 1,042 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'])
             new_values.append((0,0,{
                              '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,
                               'control_sys1_original':row[2]['control_sys1_original'],
                               'control_sys2_original':row[2]['control_sys2_original'],
                               'up_control_sys1':row[2]['up_control_sys1'],
                               'up_control_sys2':row[2]['up_control_sys2'],
                               '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
                    }],

        }}

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

0 follower(s)

Stats

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