Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
4531 มุมมอง

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)

ผู้เขียน

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

ผู้เขียน คำตอบที่ดีที่สุด

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
 

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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)

ผู้เขียน

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.

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

ผู้เขียน

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ม.ค. 23
8830
2
ก.ค. 19
3059
0
พ.ค. 16
3661
2
เม.ย. 16
5704
0
มี.ค. 15
3842