本文整理汇总了Python中stoqlib.domain.payment.method.PaymentMethod.get_creatable_methods方法的典型用法代码示例。如果您正苦于以下问题:Python PaymentMethod.get_creatable_methods方法的具体用法?Python PaymentMethod.get_creatable_methods怎么用?Python PaymentMethod.get_creatable_methods使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.domain.payment.method.PaymentMethod
的用法示例。
在下文中一共展示了PaymentMethod.get_creatable_methods方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setup_comboboxentry_slave
# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_creatable_methods [as 别名]
def _setup_comboboxentry_slave(self, data=None):
widget = ProxyComboEntry()
widget.props.sensitive = self.sensitive
widget.model_attribute = "field_value"
widget.data_type = unicode
detail = sysparam.get_detail_by_name(self.model.field_name)
is_mandatory = not detail.allow_none
self._block_none_value = is_mandatory
widget.set_property('mandatory', is_mandatory)
if not data:
field_type = detail.get_parameter_type()
# FIXME: DEFAULT_PAYMENT_METHOD needs to filter information from
# domain because it cannot be any non-creatable method.
# Find a way to implement this in a generic on ParameterDetails
if self.model.field_name == "DEFAULT_PAYMENT_METHOD":
result = PaymentMethod.get_creatable_methods(
self.store, Payment.TYPE_IN, False)
else:
result = self.store.find(field_type)
data = [(res.get_description(), unicode(res.id)) for res in result]
widget.prefill(data)
self.proxy.add_widget("field_value", widget)
self.container.add(widget)
widget.show()
widget.connect('validation-changed',
self._on_entry__validation_changed)
示例2: _setup_widgets
# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_creatable_methods [as 别名]
def _setup_widgets(self):
self.remove_button.hide()
if isinstance(self.model, (PaymentRenegotiation, Sale, ReturnedSale,
StockDecrease)):
payment_type = Payment.TYPE_IN
elif isinstance(self.model, PurchaseOrder):
payment_type = Payment.TYPE_OUT
else:
raise AssertionError
money_method = PaymentMethod.get_by_name(self.store, u'money')
self._add_method(money_method)
for method in PaymentMethod.get_creatable_methods(
self.store, payment_type, separate=False):
if method.method_name in [u'multiple', u'money']:
continue
self._add_method(method)
self.payments.set_columns(self._get_columns())
self.payments.add_list(self.model.group.payments)
self.total_value.set_bold(True)
self.received_value.set_bold(True)
self.missing_value.set_bold(True)
self.total_value.update(self._total_value)
self.remove_button.set_sensitive(False)
self._update_values()
示例3: _setup_payment_methods
# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_creatable_methods [as 别名]
def _setup_payment_methods(self, payment_type):
methods = PaymentMethod.get_creatable_methods(self.store, payment_type, separate=False)
group = None
for method in methods:
method_name = method.method_name
widget = gtk.RadioButton(group, N_(method.description))
widget.connect("toggled", self._on_method__toggled)
widget.set_data("method", method)
if group is None:
group = widget
self.methods_box.pack_start(widget, False, False, 6)
widget.show()
self._methods[method_name] = method
self._widgets[method_name] = widget
self.method_set_sensitive(method_name, True)
# Don't allow the user to change the kind of payment method if
# there's only one
if len(methods) == 1:
self._widgets[methods[0].method_name].set_sensitive(False)
else:
# Money should be the first
widget = self._widgets.get(u"money")
if widget is not None:
self.methods_box.reorder_child(widget, 0)
# Multiple should be the last
widget = self._widgets.get(u"multiple")
if widget is not None:
self.methods_box.reorder_child(widget, len(self.methods_box) - 1)
示例4: testGetCreditableMethodsSeparate
# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_creatable_methods [as 别名]
def testGetCreditableMethodsSeparate(self):
methods = PaymentMethod.get_creatable_methods(
self.store, Payment.TYPE_IN, separate=True)
self.assertTrue(methods)
self.assertEquals(len(methods), 6)
self.assertEquals(methods[0].method_name, u'bill')
self.assertEquals(methods[1].method_name, u'card')
self.assertEquals(methods[2].method_name, u'check')
self.assertEquals(methods[3].method_name, u'deposit')
self.assertEquals(methods[4].method_name, u'money')
self.assertEquals(methods[5].method_name, u'store_credit')
methods = PaymentMethod.get_creatable_methods(
self.store, Payment.TYPE_OUT, separate=True)
self.assertTrue(methods)
self.assertEquals(len(methods), 4)
self.assertEquals(methods[0].method_name, u'bill')
self.assertEquals(methods[1].method_name, u'check')
self.assertEquals(methods[2].method_name, u'deposit')
self.assertEquals(methods[3].method_name, u'money')
示例5: populate
# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_creatable_methods [as 别名]
def populate(self, value):
from stoqlib.domain.payment.method import PaymentMethod
assert self.payment_type is not None
store = get_store_for_field(self)
methods = set(PaymentMethod.get_creatable_methods(
store, self.payment_type, separate=self.separate))
# Add the current value, just in case the payment method is not
# currently creatable
methods.add(value)
self.widget.prefill(api.for_combo(methods))
if value is not None:
self.widget.select(value)
示例6: test_get_creditable_methods
# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_creatable_methods [as 别名]
def test_get_creditable_methods(self):
# Incoming payments
methods = PaymentMethod.get_creatable_methods(
self.store, Payment.TYPE_IN, separate=False)
self.assertTrue(methods)
self.assertEquals(len(methods), 8)
self.assertEquals(methods[0].method_name, u'bill')
self.assertEquals(methods[1].method_name, u'card')
self.assertEquals(methods[2].method_name, u'check')
self.assertEquals(methods[3].method_name, u'credit')
self.assertEquals(methods[4].method_name, u'deposit')
self.assertEquals(methods[5].method_name, u'money')
self.assertEquals(methods[6].method_name, u'multiple')
self.assertEquals(methods[7].method_name, u'store_credit')
methods = PaymentMethod.get_creatable_methods(
self.store, Payment.TYPE_OUT, separate=False)
self.assertTrue(methods)
self.assertEquals(len(methods), 4)
self.assertEquals(methods[0].method_name, u'bill')
self.assertEquals(methods[1].method_name, u'check')
self.assertEquals(methods[2].method_name, u'deposit')
self.assertEquals(methods[3].method_name, u'money')
示例7: _setup_payment_methods
# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_creatable_methods [as 别名]
def _setup_payment_methods(self, payment_type):
methods = PaymentMethod.get_creatable_methods(
self.store, payment_type, separate=False)
group = None
for method in methods:
method_name = method.method_name
widget = gtk.RadioButton(group, N_(method.description))
widget.connect('toggled', self._on_method__toggled)
widget.set_data('method', method)
if group is None:
group = widget
self.methods_box.pack_start(widget, False, False, 6)
widget.show()
self._methods[method_name] = method
self._widgets[method_name] = widget
self.method_set_visible(method_name, True)
if len(methods) == 1:
self._default_method = methods[0].method_name
else:
# Money should be the first
widget = self._widgets.get(u'money')
if widget is not None:
self.methods_box.reorder_child(widget, 0)
# Multiple should be the last
widget = self._widgets.get(u'multiple')
if widget is not None:
self.methods_box.reorder_child(
widget, len(self.methods_box) - 1)
# The default method could not have been passed to the constructor,
# or if it was, it could not be active. Fallback to the parameters'
# one or money in case it's not active too
if (self._default_method is None or
self._default_method not in self._widgets):
default = api.sysparam.get_object(self.store,
"DEFAULT_PAYMENT_METHOD")
if default.method_name in self._widgets:
self._default_method = default.method_name
else:
self._default_method = u'money'
self._select_default_method()
示例8: _setup_payment_methods
# 需要导入模块: from stoqlib.domain.payment.method import PaymentMethod [as 别名]
# 或者: from stoqlib.domain.payment.method.PaymentMethod import get_creatable_methods [as 别名]
def _setup_payment_methods(self, payment_type):
methods = PaymentMethod.get_creatable_methods(
self.store, payment_type, separate=False)
group = None
for method in methods:
widget = self._add_method(method, group)
if group is None:
group = widget
if self._no_payments:
self._add_method(None, group)
if len(methods) == 1:
self._default_method = methods[0].method_name
else:
# Money should be the first
widget = self._widgets.get(u'money')
if widget is not None:
self.methods_box.reorder_child(widget, 0)
# Multiple should be the last
widget = self._widgets.get(u'multiple')
if widget is not None:
self.methods_box.reorder_child(
widget, len(self.methods_box) - 1)
# The default method could not have been passed to the constructor,
# or if it was, it could not be active. Fallback to the parameters'
# one or money in case it's not active too
if (self._default_method is None or
self._default_method not in self._widgets):
default = api.sysparam.get_object(self.store,
"DEFAULT_PAYMENT_METHOD")
if default.method_name in self._widgets:
self._default_method = default.method_name
else:
self._default_method = u'money'
self._select_default_method()