From 27a6a3e0b32a15611ab5365332a8903c474b11cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 11 Feb 2026 09:38:43 +0100 Subject: [PATCH] Allow cancellation stock group to cancel running and done productions Closes #13899 --- modules/production/CHANGELOG | 1 + modules/production/production.py | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/production/CHANGELOG b/modules/production/CHANGELOG index 773ee8341b..f5914bf8fc 100644 --- a/modules/production/CHANGELOG +++ b/modules/production/CHANGELOG @@ -1,3 +1,4 @@ +* Allow cancellation stock group to cancel running and done productions Version 7.8.0 - 2025-12-15 -------------------------- diff --git a/modules/production/production.py b/modules/production/production.py index fa34122679..e0ea63689f 100644 --- a/modules/production/production.py +++ b/modules/production/production.py @@ -16,7 +16,7 @@ from trytond.modules.company.model import employee_field, set_employee from trytond.modules.product import price_digits, round_price from trytond.modules.stock.shipment import ShipmentAssignMixin from trytond.pool import Pool, PoolMeta -from trytond.pyson import Bool, Eval, If +from trytond.pyson import Bool, Eval, Id, If from trytond.transaction import Transaction from .exceptions import CostWarning @@ -201,8 +201,12 @@ class Production( )) cls._buttons.update({ 'cancel': { - 'invisible': ~Eval('state').in_(['request', 'draft', - 'assigned']), + 'invisible': ( + (Eval('state') == 'cancelled') + | (Eval('state').in_(['running', 'done']) + & ~Id('stock', + 'group_stock_cancellation').in_( + Eval('context', {}).get('groups', [])))), 'depends': ['state'], }, 'draft': {