[REF] account_move_name_sequence: Moves with name '/' can not be posted

After remove required=True for journal.sequence_id field it is possible to post an invoice with misconfigured journal with empty sequence

So, this constraint will raise an error for this kind of cases since that using '/' could raise the unique constraint for all other moves
This commit is contained in:
Moises Lopez
2022-05-13 16:14:51 +00:00
committed by Marcos Oitaben
parent 93547ac668
commit 8f518c23ba
3 changed files with 17 additions and 1 deletions

View File

@@ -6,7 +6,7 @@
{
"name": "Account Move Number Sequence",
"version": "14.0.1.0.1",
"version": "14.0.1.1.0",
"category": "Accounting",
"license": "AGPL-3",
"summary": "Generate journal entry number from sequence",

View File

@@ -13,6 +13,13 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: account_move_name_sequence
#: model:ir.model.constraint,message:account_move_name_sequence.constraint_account_move_name_state_diagonal
msgid ""
"A move can not be posted with name \"/\" or empty value\n"
"Check the journal sequence, please"
msgstr ""
#. module: account_move_name_sequence
#: model:ir.model.fields,help:account_move_name_sequence.field_account_journal__refund_sequence
msgid ""

View File

@@ -15,6 +15,15 @@ class AccountMove(models.Model):
sequence_prefix = fields.Char(compute=False)
sequence_number = fields.Integer(compute=False)
_sql_constraints = [
(
"name_state_diagonal",
"CHECK(COALESCE(name, '') NOT IN ('/', '') OR state!='posted')",
'A move can not be posted with name "/" or empty value\n'
"Check the journal sequence, please",
),
]
@api.depends("state", "journal_id", "date")
def _compute_name_by_sequence(self):
for move in self: