summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2019-01-11 15:36:39 +0000
committerNicolas Martinelli <nim@odoo.com>2019-01-11 15:36:39 +0000
commit0f0ad7d1d4223cbcd5f66c4ffcb1df06016852bf (patch)
tree9c44bdf5eee6f6eddca785ed237fa3fe5a938100
parent1e224d244c97c54aaae46364f88c6d5b3f8f0e6c (diff)
[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
-rw-r--r--addons/account/models/account_invoice.py8
1 files 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)