changeset d5fcacac5a2f in modules/sale_subscription:default
details:
https://hg.tryton.org/modules/sale_subscription?cmd=changeset;node=d5fcacac5a2f
description:
Remove global variables used for field definitions
They give the false idea that they can be extended or reused which is
not the
case.
issue8967
review252851012
diffstat:
subscription.py | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 deletions(-)
diffs (59 lines):
diff -r e2fd32513f5f -r d5fcacac5a2f subscription.py
--- a/subscription.py Sat Dec 14 10:47:54 2019 +0100
+++ b/subscription.py Sat Jan 25 20:18:49 2020 +0100
@@ -21,17 +21,6 @@
from trytond.modules.product import price_digits
from .exceptions import InvoiceError
-__all__ = ['Subscription', 'Line', 'LineConsumption',
- 'CreateLineConsumption', 'CreateLineConsumptionStart',
- 'CreateSubscriptionInvoice', 'CreateSubscriptionInvoiceStart']
-STATES = [
- ('draft', 'Draft'),
- ('quotation', 'Quotation'),
- ('running', 'Running'),
- ('closed', 'Closed'),
- ('canceled', 'Canceled'),
- ]
-
class Subscription(Workflow, ModelSQL, ModelView):
"Subscription"
@@ -140,8 +129,13 @@
},
depends=['state'])
- state = fields.Selection(
- STATES, "State", readonly=True, required=True,
+ state = fields.Selection([
+ ('draft', "Draft"),
+ ('quotation', "Quotation"),
+ ('running', "Running"),
+ ('closed', "Closed"),
+ ('canceled', "Canceled"),
+ ], "State", readonly=True, required=True,
help="The current state of the subscription.")
@classmethod
@@ -395,7 +389,7 @@
depends=['subscription_state'],
help="Add the line below the subscription.")
subscription_state = fields.Function(
- fields.Selection(STATES, "Subscription State"),
+ fields.Selection('get_subscription_states', "Subscription State"),
'on_change_with_subscription_state')
subscription_start_date = fields.Function(
fields.Date("Subscription Start Date"),
@@ -532,6 +526,12 @@
table.end_date)), else_=Null)]))
table_h.drop_column('consumed')
+ @classmethod
+ def get_subscription_states(cls):
+ pool = Pool()
+ Subscription = pool.get('sale.subscription')
+ return Subscription.fields_get(['state'])['state']['selection']
+
@fields.depends('subscription', '_parent_subscription.state')
def on_change_with_subscription_state(self, name=None):
if self.subscription: