From 0f0ad7d1d4223cbcd5f66c4ffcb1df06016852bf Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 11 Jan 2019 15:36:39 +0000 Subject: [PATCH] [FIX] account: default account When importing an invoice without specifying the type, the invoice type is set to `out_invoice`, but the account set is the supplier account. At this point, the invoice type is simply undefined (`False`). It will be set by default at creation to `out_invoice`. Therefore, we reach the `else` condition which uses the supplier info. We simply inverse the condition, so it creates a consistent object. However, it raises a bigger question about how the action context should be kept at invoice. We won't address it :-) opw-1925547 closes odoo/odoo#30154 --- addons/account/models/account_invoice.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 0f8d901c4f4..655de63597f 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -772,12 +772,12 @@ class AccountInvoice(models.Model): msg = _('Cannot find a chart of accounts for this company, You should configure it. \nPlease go to Account Configuration.') raise RedirectWarning(msg, action.id, _('Go to the configuration panel')) - if type in ('out_invoice', 'out_refund'): - account_id = rec_account.id - payment_term_id = p.property_payment_term_id.id - else: + if type in ('in_invoice', 'in_refund'): account_id = pay_account.id payment_term_id = p.property_supplier_payment_term_id.id + else: + account_id = rec_account.id + payment_term_id = p.property_payment_term_id.id delivery_partner_id = self.get_delivery_partner_id() fiscal_position = self.env['account.fiscal.position'].get_fiscal_position(self.partner_id.id, delivery_id=delivery_partner_id)