_do_create_subscription wizard 'create_subscription'

This commit is contained in:
sinergia 2022-07-09 00:13:59 -05:00
parent d453653bfc
commit 425c7e225a
2 changed files with 42 additions and 3 deletions

38
sale.py
View File

@ -2,7 +2,8 @@ from trytond.pool import Pool, PoolMeta
from trytond.model import ModelView, ModelSQL, fields
from trytond.pyson import Eval, Bool, If
from trytond.transaction import Transaction
from trytond.exceptions import UserError
from trytond.wizard import (
Button, StateAction, StateTransition, StateView, Wizard)
@ -17,7 +18,22 @@ class CreateSubscriptionStart(ModelView):
required=True)
invoice_start_date = fields.Date("Invoice Start Date",
help='Billing start date')
service = fields.Many2One('sale.subscription.service', "Service")
quantity = fields.Float("Quantity", digits='unit')
@classmethod
def default_start_date(cls):
pool = Pool()
Date = pool.get('ir.date')
return Date.today()
@classmethod
@fields.depends(methods=['default_start_date'])
def default_invoice_start_date(self):
invoice_start_date = self.default_start_date()
return invoice_start_date
class CreateSubscription(Wizard):
'Create Subscription'
__name__ = 'sale.create.subscription'
@ -25,9 +41,27 @@ class CreateSubscription(Wizard):
start = StateView('sale.create.subscription.start',
'optical_equipment.create_subscription_view_form',[
Button('Cancel', 'end', 'tryton-cancel'),
Button('Create', 'create', 'tryton-ok', default=True),
Button('Create', 'create_subscription', 'tryton-ok', default=True),
])
create_subscription = StateAction('sale_subscription.act_subscription_form')
@property
def _subscription_start(self):
return dict(
start_date = self.start.start_date,
end_date = self.start.end_date,
invoice_recurrence = self.start.invoice_recurrence,
invoice_start_date = self.start.invoice_start_date,
service = self.start.service,
quantity = self.start.quantity)
def do_create_subscription(self, action):
pool = Pool()
Subscription = pool.get('sale.subscription')
#subscription = subscription()
self._subscription_start
class SaleLine(metaclass=PoolMeta):
'SaleLine'
__name__ = 'sale.line'

View File

@ -3,11 +3,12 @@
this repository contains the full copyright notices and license terms. -->
<form col="2">
<image name="tryton-warning" xexpand="0" xfill="0"/>
<group col="2" id="create_subscription">
<group col="4" id="create_subscription">
<label
string="Are you sure to create one subscription these/this sale(s)?"
id="create_subscription" colspan="2"
yalign="0.0" xalign="0.0" xexpand="1"/>
<newline/>
<label name="start_date"/>
<field name="start_date"/>
<label name="end_date"/>
@ -16,5 +17,9 @@ this repository contains the full copyright notices and license terms. -->
<field name="invoice_recurrence"/>
<label name="invoice_start_date"/>
<field name="invoice_start_date"/>
<label name="service"/>
<field name="service"/>
<label name="quantity"/>
<field name="quantity"/>
</group>
</form>