[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:
parent
c5a613840f
commit
9b2b437df4
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue