From 4cbbbaddd5735c8f91c2ccecc33f9e2d4dc6af61 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 18 May 2017 11:09:37 +0200 Subject: [PATCH] [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 --- addons/account/models/account_invoice.py | 2 +- addons/account/wizard/account_invoice_refund.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 81540697766..6c8c160aaba 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -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 diff --git a/addons/account/wizard/account_invoice_refund.py b/addons/account/wizard/account_invoice_refund.py index bb30c799611..729d2bd325d 100644 --- a/addons/account/wizard/account_invoice_refund.py +++ b/addons/account/wizard/account_invoice_refund.py @@ -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: