changeset 31d86d487e28 in modules/product:default
details: https://hg.tryton.org/modules/product?cmd=changeset;node=31d86d487e28
description:
        Deactivate variants when product is deactivated

        issue4347
        review339361002
diffstat:

 CHANGELOG  |   1 +
 product.py |  10 +++++++++-
 2 files changed, 10 insertions(+), 1 deletions(-)

diffs (42 lines):

diff -r eb57aee81609 -r 31d86d487e28 CHANGELOG
--- a/CHANGELOG Sun Jan 17 00:56:53 2021 +0100
+++ b/CHANGELOG Sun Jan 17 01:25:27 2021 +0100
@@ -1,3 +1,4 @@
+* Deactivate variants when product is deactivated
 * Allow multiple templates to be added/removed on a category
 
 Version 5.8.0 - 2020-11-02
diff -r eb57aee81609 -r 31d86d487e28 product.py
--- a/product.py        Sun Jan 17 00:56:53 2021 +0100
+++ b/product.py        Sun Jan 17 01:25:27 2021 +0100
@@ -14,7 +14,7 @@
 from trytond.model import (
     ModelView, ModelSQL, Model, UnionMixin, DeactivableMixin, sequence_ordered,
     Exclude, fields)
-from trytond.pyson import Eval
+from trytond.pyson import Eval, If
 from trytond.transaction import Transaction
 from trytond.pool import Pool
 from trytond import backend
@@ -106,6 +106,10 @@
         'template', 'category', "Categories", readonly=True)
     products = fields.One2Many(
         'product.product', 'template', "Variants",
+        domain=[
+            If(~Eval('active'), ('active', '=', False), ()),
+            ],
+        depends=['active'],
         help="The different variants the product comes in.")
 
     @classmethod
@@ -310,6 +314,10 @@
         'product.template', "Product Template",
         required=True, ondelete='CASCADE', select=True,
         search_context={'default_products': False},
+        domain=[
+            If(Eval('active'), ('active', '=', True), ()),
+            ],
+        depends=['active'],
         help="The product that defines the common properties "
         "inherited by the variant.")
     code_readonly = fields.Function(fields.Boolean('Code Readonly'),

Reply via email to