[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

closes odoo/odoo#31373
This commit is contained in:
Nicolas Martinelli
2019-02-22 14:58:51 +00:00
parent b431f8eadc
commit f886bdfffa
+4 -4
View File
@@ -486,12 +486,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)