Odoo Help


Compare category in sale order line

on 8/9/13, 9:10 AM 1,413 views

Hello I have to compare the category id from the sale order line of each product, because I need to change the price unit for this category with a price category, for example all the laps category have half price for 10 units.

I make this: In the def product_id_change

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, context=None):

res = super(sale_order_line, self).product_id_change(cr, uid, ids,

pricelist, product, qty, uom, qty_uos, uos, name, partner_id,

lang, update_tax, date_order, packaging, fiscal_position, flag,


    result = res['value']
    product_category_obj = self.pool.get('product.category')
    product_obj = self.pool.get('product.product')
    product_ids = product_obj.search(cr, uid, [], context=context)
    product_category_ids =  product_category_obj.search(cr, uid, [], context=context)
    products = product_obj.browse(cr, uid, product_ids, context=context)

prod = self.pool.get(product.product).browse(cr, uid, product, context=context)

    fields_product = product_obj.read(cr, uid, product_ids, ['prhalfc','prhighc'], context=context)
    fields_product_category = product_category_obj.read(cr, uid, product_category_ids, ['halfcontop','highcontop'], context=context)
    if not product_id:
        return {}
    prod = self.pool.get('product.product').read(cr, uid, [product_id], context=context)
    if prod:
        return {'value': {'name': prod[0]['code']}}
    return {}
    for l in fields_product:
        if prod.category_id == fields_product_category.category.id :
            result['price_unit'] = l['prhalfc']

but i don't know how call the product id , can someone help me?

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

1 follower(s)


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