[FIX] account: Block archival of journals with auto post entries
At the moment, it is possible to archive a journal for which some entries are still waiting to be auto-posted in the future. Add a constrains to avoid make sure that it is no longer possible, since it shouldn't. Task id #2585454 closes odoo/odoo#74690 X-original-commit: 850eb5100d6405d3a7293e06910a1c5355fdb8d8 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com> Signed-off-by: Nicolas Viseur <vin-odoo@users.noreply.github.com>
This commit is contained in:
@@ -14143,6 +14143,18 @@ msgid ""
|
||||
"is the Odoo reference."
|
||||
msgstr ""
|
||||
|
||||
#. module: account
|
||||
#: code:addons/account/models/account_journal.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"You can not archive a journal containing draft journal entries.\n"
|
||||
"\n"
|
||||
"To proceed:\n"
|
||||
"1/ click on the top-right button 'Journal Entries' from this journal form\n"
|
||||
"2/ then filter on 'Draft' entries\n"
|
||||
"3/ select them all and post or delete them through the action menu"
|
||||
msgstr ""
|
||||
|
||||
#. module: account
|
||||
#: code:addons/account/models/account_payment_term.py:0
|
||||
#, python-format
|
||||
|
||||
@@ -429,6 +429,21 @@ class AccountJournal(models.Model):
|
||||
raise ValidationError(_("Some payment methods supposed to be unique already exists somewhere else.\n"
|
||||
"(%s)", ', '.join([method.display_name for method in methods])))
|
||||
|
||||
@api.constrains('active')
|
||||
def _check_auto_post_draft_entries(self):
|
||||
for journal in self:
|
||||
pending_moves = self.env['account.move'].search([
|
||||
('journal_id', '=', journal.id),
|
||||
('state', '=', 'draft')
|
||||
], limit=1)
|
||||
|
||||
if pending_moves:
|
||||
raise ValidationError(_("You can not archive a journal containing draft journal entries.\n\n"
|
||||
"To proceed:\n"
|
||||
"1/ click on the top-right button 'Journal Entries' from this journal form\n"
|
||||
"2/ then filter on 'Draft' entries\n"
|
||||
"3/ select them all and post or delete them through the action menu"))
|
||||
|
||||
@api.onchange('type')
|
||||
def _onchange_type(self):
|
||||
self.refund_sequence = self.type in ('sale', 'purchase')
|
||||
|
||||
Reference in New Issue
Block a user