[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
This commit is contained in:
Nicolas Martinelli 2015-05-12 10:38:24 +02:00
parent c5a613840f
commit 9b2b437df4
1 changed files with 2 additions and 2 deletions

View File

@ -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