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

Product last price_unit

By
Jihen BEN ALI
on 2/16/16, 4:01 AM 287 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
            res['value'].update({'last_price':acc_inv_data.price_unit})
        return res

could you help me please to get the write last_price.

Thanks

1
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"

Jihen BEN ALI
on 2/16/16, 4:31 AM

okay

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/16/16, 4:01 AM
Seen: 287 times
Last updated: 2/16/16, 4:31 AM