details: https://code.tryton.org/tryton/commit/ef17378de8c9
branch: default
user: Cédric Krier <[email protected]>
date: Thu Mar 05 10:46:50 2026 +0100
description:
Unpublish the products from the web shops when deactivating them
Closes #14649
diffstat:
modules/web_shop/product.py | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diffs (37 lines):
diff -r 8b54aacc9ad7 -r ef17378de8c9 modules/web_shop/product.py
--- a/modules/web_shop/product.py Tue Mar 03 19:52:55 2026 +0100
+++ b/modules/web_shop/product.py Thu Mar 05 10:46:50 2026 +0100
@@ -3,7 +3,7 @@
from trytond.model import DeactivableMixin, ModelSQL, ModelView, fields
from trytond.pool import Pool, PoolMeta
-from trytond.pyson import Eval
+from trytond.pyson import Eval, If
class Template(metaclass=PoolMeta):
@@ -20,10 +20,24 @@
states={
'invisible': ~Eval('salable'),
},
+ domain=[
+ If(~Eval('active'),
+ ('id', '=', -1),
+ ()),
+ ],
help="The list of web shops on which the product is published.")
web_shop_urls = fields.One2Many(
'product.web_shop_url', 'product', "Web Shop URLs", readonly=True)
+ @fields.depends('active', 'web_shops')
+ def on_change_active(self):
+ try:
+ super().on_change_active()
+ except AttributeError:
+ pass
+ if not self.active and self.web_shops:
+ self.web_shops = None
+
@classmethod
def copy(cls, products, default=None):
default = default.copy() if default is not None else {}