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': {