From 9b2b437df400af9c01aebff62858e6b8d34bc0f5 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 12 May 2015 10:38:24 +0200 Subject: [PATCH] [FIX] sale_stock: add check on invoice type during generation of invoice from delivery If route is set on dropshipping and the PO invoice is generated from picking, the unit price used in the supplier invoice must be the cost price. In this particular configuration, this was not the case because the unit price was replaced by the sale price. opw-634898 --- addons/sale_stock/sale_stock.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index 5d4430da3f3..57634684e47 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -381,7 +381,7 @@ class stock_move(osv.osv): if move.procurement_id and move.procurement_id.sale_line_id and move.procurement_id.sale_line_id.order_id.order_policy == 'picking': sale_order = move.procurement_id.sale_line_id.order_id return sale_order.partner_invoice_id, sale_order.user_id.id, sale_order.pricelist_id.currency_id.id - elif move.picking_id.sale_id and context.get('inv_type') == 'out_invoice': + elif move.picking_id.sale_id and context.get('inv_type') in ('out_invoice', 'out_refund'): # In case of extra move, it is better to use the same data as the original moves sale_order = move.picking_id.sale_id return sale_order.partner_invoice_id, sale_order.user_id.id, sale_order.pricelist_id.currency_id.id @@ -389,7 +389,7 @@ class stock_move(osv.osv): def _get_invoice_line_vals(self, cr, uid, move, partner, inv_type, context=None): res = super(stock_move, self)._get_invoice_line_vals(cr, uid, move, partner, inv_type, context=context) - if move.procurement_id and move.procurement_id.sale_line_id: + if inv_type in ('out_invoice', 'out_refund') and move.procurement_id and move.procurement_id.sale_line_id: sale_line = move.procurement_id.sale_line_id res['invoice_line_tax_id'] = [(6, 0, [x.id for x in sale_line.tax_id])] res['account_analytic_id'] = sale_line.order_id.project_id and sale_line.order_id.project_id.id or False