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.


Openerp override product_id_change function for sale orders

M. Carmo Leal
on 6/5/14, 1:18 PM 1,952 views


I need to override the product_id_change function defined in sale.order.line, so it doesn't change the unit_price every time I update the quantity.

I understand I have to use super, but I'm not sure how it all works.

Can anyone help?

Thank you.

On 6/5/14, 3:42 PM

Using super() allows to change behavior (returned value or any logic before that) of the method you are super'ing. In this particular case you may find it convenient to replicate all code of the supered method (as it contains significant amount of logic, you dont want to lose it), and only change what is necessary.

To make the change, super the product_id_change() in your module:

class SaleOrderLine(orm.Model):

    _inherit = 'sale.order.line'

    def product_id_change(
        self, cr, uid, ids,
        pricelist, product, qty=0,
        uom=False, qty_uos=0, uos=False,
        name='', partner_id=False,
        lang=False, update_tax=True,
        date_order=False, packaging=False,
        fiscal_position=False, flag=False,

        super(SaleOrderLine, self).product_id_change(
            cr, uid, ids, pricelist,
            product, qty, uom, qty_uos,
            uos, name, partner_id, lang,
            update_tax, date_order, packaging=packaging,
            flag=flag, context=context)
       # Your changes here

        return {'value': result, 'domain': domain, 'warning': warning}


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: 6/5/14, 1:18 PM
Seen: 1952 times
Last updated: 3/16/15, 8:10 AM