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.


Compare category in sale order line

on 8/9/13, 9:10 AM 857 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?

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: 8/9/13, 9:10 AM
Seen: 857 times
Last updated: 3/16/15, 8:10 AM