From fda04e2153f541ddf88afc60be4662a0d78ea7ce Mon Sep 17 00:00:00 2001
From: "Thomas Lefebvre (thle)" <thle@odoo.com>
Date: Fri, 18 Nov 2022 10:35:22 +0000
Subject: [PATCH] [FIX] account_edi: check fiscal period for an EDI
 cancellation

Steps to reproduce:
    - install a localization which uses the account_edi module;
    - define Lock date for the fiscal period;
    - choose an invoice which was sent before this date;
    - click on the "REQUEST EDI CANCELLATION" button.

Issue:
    We try to cancel the EDI document despite exceeding the fiscal period.

Cause:
	The verification of the fiscal period is done when clicking on the "RESET TO DRAFT" button which, in the flow, is after the request for cancellation of the EDI document.

Solution:
    Make a verification of the fiscal period when clicking on the "REQUEST EDI CANCELLATION" button.

opw-2990873

closes odoo/odoo#106014

Signed-off-by: Josse Colpaert <jco@odoo.com>
---
 addons/account_edi/models/account_move.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/addons/account_edi/models/account_move.py b/addons/account_edi/models/account_move.py
index 8d4f0479d8fc..dce69677324c 100644
--- a/addons/account_edi/models/account_move.py
+++ b/addons/account_edi/models/account_move.py
@@ -394,6 +394,7 @@ class AccountMove(models.Model):
         '''
         to_cancel_documents = self.env['account.edi.document']
         for move in self:
+            move._check_fiscalyear_lock_date()
             is_move_marked = False
             for doc in move.edi_document_ids:
                 if doc.edi_format_id._needs_web_services() \
-- 
GitLab