changeset ec5c763b708d in modules/sale_subscription:default
details: 
https://hg.tryton.org/modules/sale_subscription?cmd=changeset&node=ec5c763b708d
description:
        Display subscription services on product form

        issue11627
        review435571003
diffstat:

 CHANGELOG             |   2 ++
 __init__.py           |   4 +++-
 product.py            |  19 +++++++++++++++++++
 product.xml           |  12 ++++++++++++
 service.py            |   2 +-
 service.xml           |   2 +-
 tryton.cfg            |   1 +
 view/product_form.xml |  10 ++++++++++
 8 files changed, 49 insertions(+), 3 deletions(-)

diffs (116 lines):

diff -r 3d84c6d70e8d -r ec5c763b708d CHANGELOG
--- a/CHANGELOG Mon May 02 17:32:03 2022 +0200
+++ b/CHANGELOG Thu Sep 08 12:59:38 2022 +0200
@@ -1,3 +1,5 @@
+* Display subscription services on product form
+
 Version 6.4.0 - 2022-05-02
 * Bug fixes (see mercurial logs for details)
 * Use customer currency as default
diff -r 3d84c6d70e8d -r ec5c763b708d __init__.py
--- a/__init__.py       Mon May 02 17:32:03 2022 +0200
+++ b/__init__.py       Thu Sep 08 12:59:38 2022 +0200
@@ -4,7 +4,8 @@
 from trytond.pool import Pool
 
 from . import (
-    configuration, invoice, ir, party, recurrence, service, subscription)
+    configuration, invoice, ir, party, product, recurrence, service,
+    subscription)
 
 
 def register():
@@ -22,6 +23,7 @@
         subscription.CreateLineConsumptionStart,
         subscription.CreateSubscriptionInvoiceStart,
         invoice.InvoiceLine,
+        product.Product,
         ir.Cron,
         module='sale_subscription', type_='model')
     Pool.register(
diff -r 3d84c6d70e8d -r ec5c763b708d product.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/product.py        Thu Sep 08 12:59:38 2022 +0200
@@ -0,0 +1,19 @@
+# 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
+from trytond.pool import PoolMeta
+from trytond.pyson import Eval, If
+
+
+class Product(metaclass=PoolMeta):
+    __name__ = 'product.product'
+
+    subscription_services = fields.One2Many(
+        'sale.subscription.service', 'product', "Subscription Services",
+        domain=[
+            If(~Eval('active'), ('active', '=', False), ()),
+            ],
+        states={
+            'invisible': Eval('type') != 'service',
+            })
diff -r 3d84c6d70e8d -r ec5c763b708d product.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/product.xml       Thu Sep 08 12:59:38 2022 +0200
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<tryton>
+    <data>
+        <record model="ir.ui.view" id="product_view_form">
+            <field name="model">product.product</field>
+            <field name="inherit" ref="product.product_view_form"/>
+            <field name="name">product_form</field>
+        </record>
+    </data>
+</tryton>
diff -r 3d84c6d70e8d -r ec5c763b708d service.py
--- a/service.py        Mon May 02 17:32:03 2022 +0200
+++ b/service.py        Thu Sep 08 12:59:38 2022 +0200
@@ -9,7 +9,7 @@
     __name__ = 'sale.subscription.service'
 
     product = fields.Many2One(
-        'product.product', "Product", required=True,
+        'product.product', "Product", required=True, ondelete='CASCADE',
         domain=[
             ('type', '=', 'service'),
             ])
diff -r 3d84c6d70e8d -r ec5c763b708d service.xml
--- a/service.xml       Mon May 02 17:32:03 2022 +0200
+++ b/service.xml       Thu Sep 08 12:59:38 2022 +0200
@@ -30,7 +30,7 @@
             <field name="act_window" ref="act_service_form"/>
         </record>
         <menuitem
-            parent="product.menu_main_product"
+            parent="product.menu_template"
             action="act_service_form"
             sequence="20"
             id="menu_service_form"/>
diff -r 3d84c6d70e8d -r ec5c763b708d tryton.cfg
--- a/tryton.cfg        Mon May 02 17:32:03 2022 +0200
+++ b/tryton.cfg        Thu Sep 08 12:59:38 2022 +0200
@@ -15,4 +15,5 @@
     service.xml
     subscription.xml
     party.xml
+    product.xml
     message.xml
diff -r 3d84c6d70e8d -r ec5c763b708d view/product_form.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/view/product_form.xml     Thu Sep 08 12:59:38 2022 +0200
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<data>
+    <xpath expr="/form/notebook" position="inside">
+        <page name="subscription_services">
+            <field name="subscription_services" colspan="4"/>
+        </page>
+    </xpath>
+</data>

Reply via email to