[FIX] sale: Wrong invoice settings
On a sale order for a customer A where the invoice address is the address of the customer B, the payment term, the receivable account and the fiscal position must be set from customer B which is the partner invoice. opw:630962
This commit is contained in:
parent
397892a6c8
commit
57c1b07ebf
|
@ -330,7 +330,8 @@ class sale_order(osv.osv):
|
|||
part = self.pool.get('res.partner').browse(cr, uid, part, context=context)
|
||||
addr = self.pool.get('res.partner').address_get(cr, uid, [part.id], ['delivery', 'invoice', 'contact'])
|
||||
pricelist = part.property_product_pricelist and part.property_product_pricelist.id or False
|
||||
payment_term = part.property_payment_term and part.property_payment_term.id or False
|
||||
invoice_part = self.pool.get('res.partner').browse(cr, uid, addr['invoice'], context=context)
|
||||
payment_term = invoice_part.property_payment_term and invoice_part.property_payment_term.id or False
|
||||
dedicated_salesman = part.user_id and part.user_id.id or uid
|
||||
val = {
|
||||
'partner_invoice_id': addr['invoice'],
|
||||
|
@ -394,14 +395,14 @@ class sale_order(osv.osv):
|
|||
'origin': order.name,
|
||||
'type': 'out_invoice',
|
||||
'reference': order.client_order_ref or order.name,
|
||||
'account_id': order.partner_id.property_account_receivable.id,
|
||||
'account_id': order.partner_invoice_id.property_account_receivable.id,
|
||||
'partner_id': order.partner_invoice_id.id,
|
||||
'journal_id': journal_ids[0],
|
||||
'invoice_line': [(6, 0, lines)],
|
||||
'currency_id': order.pricelist_id.currency_id.id,
|
||||
'comment': order.note,
|
||||
'payment_term': order.payment_term and order.payment_term.id or False,
|
||||
'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id,
|
||||
'fiscal_position': order.fiscal_position.id or order.partner_invoice_id.property_account_position.id,
|
||||
'date_invoice': context.get('date_invoice', False),
|
||||
'company_id': order.company_id.id,
|
||||
'user_id': order.user_id and order.user_id.id or False,
|
||||
|
|
Loading…
Reference in New Issue