本文整理汇总了Python中stoqlib.gui.slaves.paymentmethodslave.SelectPaymentMethodSlave.connect_after方法的典型用法代码示例。如果您正苦于以下问题:Python SelectPaymentMethodSlave.connect_after方法的具体用法?Python SelectPaymentMethodSlave.connect_after怎么用?Python SelectPaymentMethodSlave.connect_after使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.gui.slaves.paymentmethodslave.SelectPaymentMethodSlave
的用法示例。
在下文中一共展示了SelectPaymentMethodSlave.connect_after方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PurchasePaymentStep
# 需要导入模块: from stoqlib.gui.slaves.paymentmethodslave import SelectPaymentMethodSlave [as 别名]
# 或者: from stoqlib.gui.slaves.paymentmethodslave.SelectPaymentMethodSlave import connect_after [as 别名]
class PurchasePaymentStep(WizardEditorStep):
gladefile = 'PurchasePaymentStep'
model_type = PaymentGroup
def __init__(self, wizard, previous, store, model,
outstanding_value=currency(0)):
self.order = model
self.slave = None
self.discount_surcharge_slave = None
self.outstanding_value = outstanding_value
if not model.payments.count():
# Default values
self._installments_number = None
self._first_duedate = None
self._method = 'bill'
else:
# FIXME: SqlObject returns count as long, but we need it as int.
self._installments_number = int(model.payments.count())
self._method = model.payments[0].method.method_name
# due_date is datetime.datetime. Converting it to datetime.date
due_date = model.payments[0].due_date.date()
self._first_duedate = (due_date >= localtoday().date() and
due_date or None)
WizardEditorStep.__init__(self, store, wizard, model.group, previous)
def _setup_widgets(self):
register_payment_slaves()
self._ms = SelectPaymentMethodSlave(store=self.store,
payment_type=Payment.TYPE_OUT,
default_method=self._method,
no_payments=True)
self._ms.connect_after('method-changed',
self._after_method_select__method_changed)
self.attach_slave('method_select_holder', self._ms)
self._update_payment_method_slave()
def _set_method_slave(self):
"""Sets the payment method slave"""
method = self._ms.get_selected_method()
if not method:
return
domain_mapper = get_utility(IDomainSlaveMapper)
slave_class = domain_mapper.get_slave_class(method)
if slave_class:
self.wizard.payment_group = self.model
self.slave = slave_class(self.wizard, self,
self.store, self.order, method,
outstanding_value=self.outstanding_value,
first_duedate=self._first_duedate,
installments_number=self._installments_number,
temporary_identifiers=self.wizard.is_for_another_branch())
self.attach_slave('method_slave_holder', self.slave)
def _update_payment_method_slave(self):
"""Updates the payment method slave """
holder_name = 'method_slave_holder'
if self.get_slave(holder_name):
self.slave.get_toplevel().hide()
self.detach_slave(holder_name)
self.slave = None
# remove all payments created last time, if any
self.model.clear_unused()
if not self.slave:
self._set_method_slave()
#
# WizardStep hooks
#
def validate_step(self):
if self.slave:
return self.slave.finish()
return True
def next_step(self):
return FinishPurchaseStep(self.store, self.wizard, self.order, self)
def post_init(self):
self.model.clear_unused()
self.main_box.set_focus_chain([self.method_select_holder,
self.method_slave_holder])
self.register_validate_function(self.wizard.refresh_next)
self.force_validation()
def setup_proxies(self):
self._setup_widgets()
#
# callbacks
#
def _after_method_select__method_changed(self, slave, method):
self._update_payment_method_slave()