Odoo Help


Product last price_unit

on 2/16/16, 4:01 AM 358 views

Hi everyone,

For a specific partner and a specific product I want to get the last price for that I tried this one but I get not the last_price

def product_id_change(self, cr, uid, ids, product, uom_id, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, currency_id=False, company_id=None, context=None):
        res = super(kms_account_invoice_line, self).product_id_change(cr, uid, ids, product, uom_id, qty, name, type, partner_id, fposition_id, price_unit, currency_id=currency_id, company_id=company_id, context=context)
        acc_inv_obj = self.pool.get('account.invoice.line')
 acc_inv_ids = acc_inv_obj.search(cr, uid,[('partner_id', '=', partner_id),('product_id','=',product)], context=context)
        for acc_inv_data in acc_inv_obj.browse(cr, uid, acc_inv_ids, context=context):
            print 'last_price',acc_inv_data.price_unit
        return res

could you help me please to get the write last_price.


Krupesh Laiya
On 2/16/16, 4:24 AM
acc_inv_ids = acc_inv_obj.search(cr, uid,[('partner_id', '=', partner_id),('product_id','=',product), ('id', 'not in', [ids])], ,order="asc", limit=1, context=context)

Use this domain in your search so it will return latest id of the invoice line and return only single id at a time because we used limit=1 and in case you didn't get any id from the search then please remove ('id', 'not in', [ids]) this domain from search.
hope this will help you.

Thanks for your answer it was very helpful but I had to remove order="asc"

on 2/16/16, 4:31 AM


Krupesh Laiya
on 2/16/16, 4:35 AM

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 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: 2/16/16, 4:01 AM
Seen: 358 times
Last updated: 2/16/16, 4:31 AM