From ce2d00f3467e616de2e75a445bb6f2cb76d30495 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 13 Sep 2017 15:22:42 +0200 Subject: [PATCH] [FIX] account: Register a payment with no sequence for account.payment When registring a supplier invoice, if no sequence exists for code "account.payment.supplier.invoice" then it failed for the creation of the counterpart lines because a name is required to create an account move line. ps: check function "_get_liquidity_move_line_vals" for the condition. opw:767224 --- addons/account/i18n/account.pot | 6 ++++++ addons/account/models/account_payment.py | 2 ++ 2 files changed, 8 insertions(+) diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index 0b7b1461634..81687316647 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -9674,6 +9674,12 @@ msgstr "" msgid "You have" msgstr "" +#. module: account +#: code:addons/account/models/account_payment.py:360 +#, python-format +msgid "You have to define a sequence for %s in your company." +msgstr "" + #. module: account #: code:addons/account/wizard/account_report_general_ledger.py:21 #, python-format diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 4a49bb3b5f9..fcc2dbd0319 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -356,6 +356,8 @@ class account_payment(models.Model): if rec.payment_type == 'outbound': sequence_code = 'account.payment.supplier.invoice' rec.name = self.env['ir.sequence'].with_context(ir_sequence_date=rec.payment_date).next_by_code(sequence_code) + if not rec.name and self.payment_type != 'transfer': + raise UserError(_("You have to define a sequence for %s in your company.") % (sequence_code,)) # Create the journal entry amount = rec.amount * (rec.payment_type in ('outbound', 'transfer') and 1 or -1)