[FIX] account: Nicely warn the user that no sequence is set when refund_sequence is True.
Avoid a traceback when the refund_sequence is not set Closes #14666 OPW #697292
This commit is contained in:
@@ -6427,6 +6427,12 @@ msgstr ""
|
||||
msgid "Please create some invoice lines."
|
||||
msgstr ""
|
||||
|
||||
#. module: account
|
||||
#: code:addons/account/models/account_move.py:140
|
||||
#, python-format
|
||||
msgid "Please define a sequence for the refunds"
|
||||
msgstr ""
|
||||
|
||||
#. module: account
|
||||
#: code:addons/account/models/account_move.py:143
|
||||
#, python-format
|
||||
|
||||
@@ -123,7 +123,6 @@ class AccountMove(models.Model):
|
||||
def post(self):
|
||||
invoice = self._context.get('invoice', False)
|
||||
self._post_validate()
|
||||
|
||||
for move in self:
|
||||
move.line_ids.create_analytic_lines()
|
||||
if move.name == '/':
|
||||
@@ -137,7 +136,10 @@ class AccountMove(models.Model):
|
||||
# If invoice is actually refund and journal has a refund_sequence then use that one or use the regular one
|
||||
sequence = journal.sequence_id
|
||||
if invoice and invoice.type in ['out_refund', 'in_refund'] and journal.refund_sequence:
|
||||
if not journal.refund_sequence_id:
|
||||
raise UserError(_('Please define a sequence for the refunds'))
|
||||
sequence = journal.refund_sequence_id
|
||||
|
||||
new_name = sequence.with_context(ir_sequence_date=move.date).next_by_id()
|
||||
else:
|
||||
raise UserError(_('Please define a sequence on the journal.'))
|
||||
|
||||
Reference in New Issue
Block a user