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

Discount on invoices from purchase orders

By
Roberto Barreiro
on 11/26/14, 7:46 AM 1,032 views

I added a discount field to my purchase orders, I make my purchase invoices based on them, and I need discount passes from purchase orders to purchase invoices. I was looking for the method who reads the lines from purchase orders, and writes it on purchase invoices, but I don't find it. Anyone knows wich function make this operation? Thanks in advice.

purchase/purchase.py - method: _prepare_inv_line(self, cr, uid, account_id, order_line, context=None)

zbik
on 11/26/14, 9:45 AM

Thanks zbik, it helps to break my mind on the next step ;)

Roberto Barreiro
on 11/26/14, 1:06 PM
0
Roberto Barreiro
On 11/26/14, 1:10 PM

zbkik solves my problem. He said:

If your Default invoicing control method = Based on incoming shipments, you see _get_invoice_line_vals in stock_account/stock.py
 

0

Bole

--Bole--
2385
| 5 4 6
Zagreb | Karlovac, Croatia
--Bole--

there is only 10 kind of people the ones that understand binary ... and others

Bole
On 11/26/14, 9:53 AM

if you are looking for discount on order lines.. take a look here:
https://www.odoo.com/apps/7.0/purchase_discount/

if youre looking for additional discount (on total of invoice) maybe google a bit over partners repositories ... you will find some interesting stuf...

That module is not working for 8.0, i'm doing a new module based on purchase_discount existing addon. It has this code, to do what I want, but it doesn,t work: class purchase_order(orm.Model): def _prepare_inv_line(self, cr, uid, account_id, order_line, context=None): result = super(purchase_order, self)._prepare_inv_line(cr, uid, account_id, order_line, context) result['discount'] = order_line.discount or 0.0 return result class stock_picking(orm.Model): _inherit = 'stock.picking' def _invoice_line_hook(self, cr, uid, move_line, invoice_line_id): if move_line.purchase_line_id: line = {'discount': move_line.purchase_line_id.discount} self.pool.get('account.invoice.line').write(cr, uid, [invoice_line_id], line) return super(stock_picking, self)._invoice_line_hook(cr, uid, move_line, invoice_line_id)

Roberto Barreiro
on 11/26/14, 10:01 AM

I have new objetcs on my addon inheriting purchase.order and stock.picking, with new functions to _prepare_inv_line from purchase.order and _invoice_line_hook from stock.picking, but them seems not to be called from the invoice process, because the code I have for these methods does nothing. I put a message with raise osv.except_osv into the code, to be sure the functions are called from the make invoice process, but it isn't showed. Because of this, I think odoo 8 uses another functions to the invoice process, but I can find them.

Roberto Barreiro
on 11/26/14, 10:13 AM

If your Default invoicing control method = Based on incoming shipments, you see _get_invoice_line_vals in stock_account/stock.py

zbik
on 11/26/14, 10:49 AM

Thanks zbik, it helps to break my mind on the next step ;)

Roberto Barreiro
on 11/26/14, 1:07 PM

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: 11/26/14, 7:46 AM
Seen: 1032 times
Last updated: 3/16/15, 8:10 AM