From 45bab967033531e0391a923ef1a2186955c36eeb Mon Sep 17 00:00:00 2001
From: PNO <pno@odoo.com>
Date: Thu, 17 Aug 2023 12:20:57 +0000
Subject: [PATCH] [FIX] stock: change error message

The error can be raised either when a move is in state done or cancel. However, the error message only says we cannot split split if the move is in done, which can be misleading.

closes odoo/odoo#132205

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
---
 addons/stock/i18n/stock.pot       | 2 +-
 addons/stock/models/stock_move.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/addons/stock/i18n/stock.pot b/addons/stock/i18n/stock.pot
index b306a658c1fc..976f94aa4eb3 100644
--- a/addons/stock/i18n/stock.pot
+++ b/addons/stock/i18n/stock.pot
@@ -7685,7 +7685,7 @@ msgstr ""
 #. module: stock
 #: code:addons/stock/models/stock_move.py:0
 #, python-format
-msgid "You cannot split a stock move that has been set to 'Done'."
+msgid "You cannot split a stock move that has been set to 'Done' or 'Cancel'."
 msgstr ""
 
 #. module: stock
diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py
index 52d1910f7ef4..b83ff8d51b39 100644
--- a/addons/stock/models/stock_move.py
+++ b/addons/stock/models/stock_move.py
@@ -1614,7 +1614,7 @@ class StockMove(models.Model):
         :returns: list of dict. stock move values """
         self.ensure_one()
         if self.state in ('done', 'cancel'):
-            raise UserError(_('You cannot split a stock move that has been set to \'Done\'.'))
+            raise UserError(_('You cannot split a stock move that has been set to \'Done\' or \'Cancel\'.'))
         elif self.state == 'draft':
             # we restrict the split of a draft move because if not confirmed yet, it may be replaced by several other moves in
             # case of phantom bom (with mrp module). And we don't want to deal with this complexity by copying the product that will explode.
-- 
GitLab