本文整理汇总了Python中stoqlib.gui.slaves.paymentmethodslave.SelectPaymentMethodSlave.get_selected_method方法的典型用法代码示例。如果您正苦于以下问题:Python SelectPaymentMethodSlave.get_selected_method方法的具体用法?Python SelectPaymentMethodSlave.get_selected_method怎么用?Python SelectPaymentMethodSlave.get_selected_method使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.gui.slaves.paymentmethodslave.SelectPaymentMethodSlave
的用法示例。
在下文中一共展示了SelectPaymentMethodSlave.get_selected_method方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_default_method
# 需要导入模块: from stoqlib.gui.slaves.paymentmethodslave import SelectPaymentMethodSlave [as 别名]
# 或者: from stoqlib.gui.slaves.paymentmethodslave.SelectPaymentMethodSlave import get_selected_method [as 别名]
def test_default_method(self):
method = self.store.find(PaymentMethod, method_name=u'multiple').one()
with self.sysparam(DEFAULT_PAYMENT_METHOD=method):
slave = SelectPaymentMethodSlave(store=self.store,
payment_type=Payment.TYPE_IN)
self.assertEqual(
slave.get_selected_method().method_name, u'multiple')
# If the default method is not created (setting is_active to False
# does the trick), it should fallback to money
method.is_active = False
slave = SelectPaymentMethodSlave(store=self.store,
payment_type=Payment.TYPE_IN)
self.assertEqual(
slave.get_selected_method().method_name, u'money')
示例2: test_created_methods
# 需要导入模块: from stoqlib.gui.slaves.paymentmethodslave import SelectPaymentMethodSlave [as 别名]
# 或者: from stoqlib.gui.slaves.paymentmethodslave.SelectPaymentMethodSlave import get_selected_method [as 别名]
def test_created_methods(self):
# Payment.TYPE_IN
slave = SelectPaymentMethodSlave(store=self.store,
payment_type=Payment.TYPE_IN)
methods = ['bill', 'card', 'check', 'credit', 'deposit',
'money', 'multiple', 'store_credit']
self.assertEqual(set(slave._widgets.keys()), set(methods))
for method in methods:
widget = slave._widgets.get(method)
self.assertTrue(widget.get_visible())
# Payment.TYPE_OUT
slave = SelectPaymentMethodSlave(store=self.store,
payment_type=Payment.TYPE_OUT)
methods = ['bill', 'check', 'deposit', 'money']
self.assertEqual(set(slave._widgets.keys()), set(methods))
for method in methods:
widget = slave._widgets.get(method)
self.assertTrue(widget.get_visible())
# Only 1 method available
for method in self.store.find(PaymentMethod,
PaymentMethod.method_name != u'money'):
method.is_active = False
slave = SelectPaymentMethodSlave(store=self.store,
payment_type=Payment.TYPE_IN)
self.assertEqual(set(slave._widgets.keys()), set([u'money']))
self.assertEqual(slave.get_selected_method().method_name, u'money')
示例3: test_method_set_sensitive
# 需要导入模块: from stoqlib.gui.slaves.paymentmethodslave import SelectPaymentMethodSlave [as 别名]
# 或者: from stoqlib.gui.slaves.paymentmethodslave.SelectPaymentMethodSlave import get_selected_method [as 别名]
def test_method_set_sensitive(self):
inactive = self.store.find(PaymentMethod, method_name=u'bill').one()
inactive.is_active = False
slave = SelectPaymentMethodSlave(store=self.store,
payment_type=Payment.TYPE_IN,
default_method=u'check')
self.assertEqual(
slave.get_selected_method().method_name, u'check')
slave.method_set_sensitive(u'check', False)
self.assertFalse(slave._widgets[u'check'].get_sensitive())
self.assertEqual(
slave.get_selected_method().method_name, u'money')
# Test when the widget is not there
slave.method_set_sensitive(u'bill', True)
示例4: test_init_default_method
# 需要导入模块: from stoqlib.gui.slaves.paymentmethodslave import SelectPaymentMethodSlave [as 别名]
# 或者: from stoqlib.gui.slaves.paymentmethodslave.SelectPaymentMethodSlave import get_selected_method [as 别名]
def test_init_default_method(self):
check_method = self.store.find(PaymentMethod,
method_name=u'check').one()
multiple_method = self.store.find(PaymentMethod,
method_name=u'multiple').one()
money_method = self.store.find(PaymentMethod,
method_name=u'money').one()
# Check should be selected here since it was passed as default ethod
slave = SelectPaymentMethodSlave(store=self.store,
payment_type=Payment.TYPE_IN,
default_method=u'check')
self.assertEqual(slave.get_selected_method(), check_method)
with self.sysparam(DEFAULT_PAYMENT_METHOD=multiple_method):
# Even with multiple as default, the constructor default
# should overwrite it
slave = SelectPaymentMethodSlave(store=self.store,
payment_type=Payment.TYPE_IN,
default_method=u'check')
self.assertEqual(slave.get_selected_method(), check_method)
# Making check inactive should make the DEFAULT_PAYMENT_METHOD
# the default one on the slave
check_method.is_active = False
slave = SelectPaymentMethodSlave(store=self.store,
payment_type=Payment.TYPE_IN,
default_method=u'check')
self.assertEqual(slave.get_selected_method(), multiple_method)
# Making check and the DEFAULT_PAYMENT_METHOD inactive,
# the default should fallback to money
multiple_method.is_active = False
slave = SelectPaymentMethodSlave(store=self.store,
payment_type=Payment.TYPE_IN,
default_method=u'check')
self.assertEqual(slave.get_selected_method(), money_method)
示例5: PurchasePaymentStep
# 需要导入模块: from stoqlib.gui.slaves.paymentmethodslave import SelectPaymentMethodSlave [as 别名]
# 或者: from stoqlib.gui.slaves.paymentmethodslave.SelectPaymentMethodSlave import get_selected_method [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()