[FIX] account: Sales team on refund

When doing a refund of an invoice, the sales team is not kept. At the
same time, remove fields which don't exist anymore.

opw-743093
This commit is contained in:
Nicolas Martinelli
2017-05-18 11:11:37 +02:00
parent 64eb5ce48e
commit 4cbbbaddd5
2 changed files with 3 additions and 4 deletions
+1 -1
View File
@@ -1019,7 +1019,7 @@ class AccountInvoice(models.Model):
:return: dict of value to create() the refund
"""
values = {}
for field in ['name', 'reference', 'comment', 'date_due', 'partner_id', 'company_id',
for field in ['name', 'reference', 'comment', 'date_due', 'partner_id', 'company_id', 'team_id',
'account_id', 'currency_id', 'payment_term_id', 'user_id', 'fiscal_position_id']:
if invoice._fields[field].type == 'many2one':
values[field] = invoice[field].id
@@ -79,8 +79,7 @@ class AccountInvoiceRefund(models.TransientModel):
invoice = inv.read(
['name', 'type', 'number', 'reference',
'comment', 'date_due', 'partner_id',
'partner_insite', 'partner_contact',
'partner_ref', 'payment_term_id', 'account_id',
'payment_term_id', 'account_id', 'team_id',
'currency_id', 'invoice_line_ids', 'tax_line_ids',
'journal_id', 'date'])
invoice = invoice[0]
@@ -101,7 +100,7 @@ class AccountInvoiceRefund(models.TransientModel):
'fiscal_position_id': inv.fiscal_position_id.id,
})
for field in ('partner_id', 'account_id', 'currency_id',
'payment_term_id', 'journal_id'):
'payment_term_id', 'journal_id', 'team_id'):
invoice[field] = invoice[field] and invoice[field][0]
inv_refund = inv_obj.create(invoice)
if inv_refund.payment_term_id.id: