changeset a1999dbdd3e3 in modules/sale_product_customer:default
details: 
https://hg.tryton.org/modules/sale_product_customer?cmd=changeset;node=a1999dbdd3e3
description:
        Allow product customer to be deactivated

        issue8062
        review333461002
diffstat:

 CHANGELOG                      |   2 ++
 product.py                     |  24 ++++++++++++++++--------
 view/product_customer_form.xml |   8 ++++++--
 3 files changed, 24 insertions(+), 10 deletions(-)

diffs (99 lines):

diff -r f52acf277dd0 -r a1999dbdd3e3 CHANGELOG
--- a/CHANGELOG Sat Dec 19 17:08:46 2020 +0100
+++ b/CHANGELOG Sun Jan 17 01:25:01 2021 +0100
@@ -1,3 +1,5 @@
+* Allow product customer to be deactivated
+
 Version 5.8.0 - 2020-11-02
 * Bug fixes (see mercurial logs for details)
 * Remove support for Python 3.5
diff -r f52acf277dd0 -r a1999dbdd3e3 product.py
--- a/product.py        Sat Dec 19 17:08:46 2020 +0100
+++ b/product.py        Sun Jan 17 01:25:01 2021 +0100
@@ -1,14 +1,16 @@
 # This file is part of Tryton.  The COPYRIGHT file at the top level of
 # this repository contains the full copyright notices and license terms.
 
-from trytond.model import (fields, ModelSQL, ModelView, sequence_ordered,
-    MatchMixin)
+from trytond.model import (
+    ModelSQL, ModelView, sequence_ordered, MatchMixin, DeactivableMixin,
+    fields)
 from trytond.pool import PoolMeta, Pool
 from trytond.pyson import If, Eval, Bool
 from trytond.tools import lstrip_wildcard
 
 
-class ProductCustomer(sequence_ordered(), ModelSQL, ModelView, MatchMixin):
+class ProductCustomer(
+        sequence_ordered(), DeactivableMixin, ModelSQL, ModelView, MatchMixin):
     'Product Customer'
     __name__ = 'sale.product_customer'
 
@@ -18,17 +20,19 @@
         domain=[
             If(Bool(Eval('product')),
                 ('products', '=', Eval('product')),
-                ())
+                ()),
+            If(Eval('active'), ('active', '=', True), ()),
             ],
-        depends=['product'])
+        depends=['product', 'active'])
     product = fields.Many2One(
         'product.product', "Variant", select=True,
         domain=[
             If(Bool(Eval('template')),
                 ('template', '=', Eval('template')),
                 ()),
+            If(Eval('active'), ('active', '=', True), ()),
             ],
-        depends=['template'])
+        depends=['template', 'active'])
     party = fields.Many2One('party.party', "Customer", required=True,
         ondelete='CASCADE')
     name = fields.Char("Name", translate=True)
@@ -77,7 +81,10 @@
         states={
             'invisible': ~Eval('salable', False),
             },
-        depends=['salable'])
+        domain=[
+            If(~Eval('active'), ('active', '=', False), ()),
+            ],
+        depends=['salable', 'active'])
 
     def product_customer_used(self, **pattern):
         for product_customer in self.product_customers:
@@ -116,11 +123,12 @@
         'sale.product_customer', 'product', "Customers",
         domain=[
             ('template', '=', Eval('template')),
+            If(~Eval('active'), ('active', '=', False), ()),
             ],
         states={
             'invisible': ~Eval('salable', False),
             },
-        depends=['template', 'salable'])
+        depends=['template', 'salable', 'active'])
 
     def product_customer_used(self, **pattern):
         for product_customer in self.product_customers:
diff -r f52acf277dd0 -r a1999dbdd3e3 view/product_customer_form.xml
--- a/view/product_customer_form.xml    Sat Dec 19 17:08:46 2020 +0100
+++ b/view/product_customer_form.xml    Sun Jan 17 01:25:01 2021 +0100
@@ -8,8 +8,12 @@
     <field name="product" colspan="3"/>
     <label name="party"/>
     <field name="party"/>
-    <label name="sequence"/>
-    <field name="sequence"/>
+    <group id="sequence-active" col="-1" colspan="2">
+        <label name="sequence"/>
+        <field name="sequence"/>
+        <label name="active"/>
+        <field name="active"/>
+    </group>
     <label name="name"/>
     <field name="name"/>
     <label name="code"/>

Reply via email to