本文整理汇总了Python中stoqlib.lib.parameters.sysparam.set_bool函数的典型用法代码示例。如果您正苦于以下问题:Python set_bool函数的具体用法?Python set_bool怎么用?Python set_bool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_bool函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create
def test_create(self):
# Allow creating purchases in the past.
sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', True)
self.wizard = PurchaseWizard(self.store)
purchase_branch = self.create_branch()
purchase_order = PurchaseOrder(branch=purchase_branch)
sellable = self.create_sellable()
purchase_order.add_item(sellable=sellable)
self.wizard.model.identifier = 12345
self.wizard.model.open_date = localdate(2010, 1, 3).date()
self._check_start_step('wizard-purchase-start-step')
self._check_item_step('wizard-purchase-item-step')
self._check_payment_step('wizard-purchase-payment-step')
purchase = self.wizard.model
models = [purchase]
models.extend(purchase.get_items())
models.extend(purchase.payments)
models.append(purchase.group)
self.check_wizard(self.wizard, 'wizard-purchase-finish-step',
models=models)
self.click(self.wizard.next_button)
示例2: _payComissionWhenConfirmed
def _payComissionWhenConfirmed(self):
sysparam.set_bool(
self.store,
"SALE_PAY_COMMISSION_WHEN_CONFIRMED",
True)
self.failUnless(
sysparam.get_bool('SALE_PAY_COMMISSION_WHEN_CONFIRMED'))
示例3: _check_param_online_services
def _check_param_online_services(self):
from stoqlib.database.runtime import new_store
from stoqlib.lib.parameters import sysparam
from gi.repository import Gtk
if sysparam.get_bool('ONLINE_SERVICES') is None:
from kiwi.ui.dialogs import HIGAlertDialog
# FIXME: All of this is to avoid having to set markup as the default
# in kiwi/ui/dialogs:HIGAlertDialog.set_details, after 1.0
# this can be simplified when we fix so that all descriptions
# sent to these dialogs are properly escaped
dialog = HIGAlertDialog(
parent=None,
flags=Gtk.DialogFlags.MODAL,
type=Gtk.MessageType.WARNING)
dialog.add_button(_("Not right now"), Gtk.ResponseType.NO)
dialog.add_button(_("Enable online services"), Gtk.ResponseType.YES)
dialog.set_primary(_('Do you want to enable Stoq online services?'))
dialog.set_details(PRIVACY_STRING, use_markup=True)
dialog.set_default_response(Gtk.ResponseType.YES)
response = dialog.run()
dialog.destroy()
store = new_store()
sysparam.set_bool(store, 'ONLINE_SERVICES', response == Gtk.ResponseType.YES)
store.commit()
store.close()
示例4: sysparam
def sysparam(self, **kwargs):
"""
Updates a set of system parameters within a context.
The values will be reverted when leaving the scope.
kwargs contains a dictionary of parameter name->value
"""
from stoqlib.lib.parameters import sysparam
old_values = {}
for param, value in kwargs.items():
if type(value) is bool:
old_values[param] = sysparam.get_bool(param)
sysparam.set_bool(self.store, param, value)
elif isinstance(value, Domain) or value is None:
old_values[param] = sysparam.get_object(self.store, param)
sysparam.set_object(self.store, param, value)
else:
raise NotImplementedError(type(value))
try:
yield
finally:
for param, value in old_values.items():
if type(value) is bool:
sysparam.set_bool(self.store, param, value)
elif isinstance(value, Domain) or value is None:
sysparam.set_object(self.store, param, value)
else:
raise NotImplementedError(type(value))
示例5: test_sales_person_report
def test_sales_person_report(self):
sysparam.set_bool(self.store, "SALE_PAY_COMMISSION_WHEN_CONFIRMED", True)
salesperson = self.create_sales_person()
product = self.create_product(price=100)
sellable = product.sellable
sale = self.create_sale()
sale.salesperson = salesperson
sale.add_sellable(sellable, quantity=1)
self.create_storable(product, get_current_branch(self.store), stock=100)
CommissionSource(sellable=sellable, direct_value=Decimal(10), installments_value=1, store=self.store)
sale.order()
method = PaymentMethod.get_by_name(self.store, u"money")
method.create_payment(Payment.TYPE_IN, sale.group, sale.branch, sale.get_sale_subtotal())
sale.confirm()
sale.group.pay()
salesperson = salesperson
commissions = list(self.store.find(CommissionView))
commissions[0].identifier = 1
commissions[1].identifier = 139
self._diff_expected(SalesPersonReport, "sales-person-report", commissions, salesperson)
# Also test when there is no salesperson selected
self._diff_expected(SalesPersonReport, "sales-person-report-without-salesperson", commissions, None)
示例6: test_wizard_create_payment
def test_wizard_create_payment(self, yesno):
yesno.return_value = False
sysparam.set_bool(self.store, 'CREATE_PAYMENTS_ON_STOCK_DECREASE', True)
till = self.create_till()
till.open_till()
branch = api.get_current_branch(self.store)
storable = self.create_storable(branch=branch, stock=1)
sellable = storable.product.sellable
wizard = StockDecreaseWizard(self.store)
step = wizard.get_current_step()
self.assertTrue(step.create_payments.get_visible())
step.create_payments.update(True)
step.reason.update('reason')
self.check_wizard(wizard, 'start-stock-decrease-step-create-payments')
self.assertSensitive(wizard, ['next_button'])
self.click(wizard.next_button)
step = wizard.get_current_step()
step.barcode.set_text(sellable.barcode)
step.sellable_selected(sellable)
step.quantity.update(1)
self.click(step.add_sellable_button)
self.click(wizard.next_button)
step = wizard.get_current_step()
self.assertTrue(isinstance(step, PaymentMethodStep))
示例7: test_wizard_with_cost_center
def test_wizard_with_cost_center(self, yesno):
sysparam.set_bool(self.store, 'CREATE_PAYMENTS_ON_STOCK_DECREASE', True)
yesno.return_value = False
branch = api.get_current_branch(self.store)
storable = self.create_storable(branch=branch, stock=1)
sellable = storable.product.sellable
cost_center = self.create_cost_center()
wizard = StockDecreaseWizard(self.store)
entry = self.store.find(CostCenterEntry,
cost_center=wizard.model.cost_center)
self.assertEqual(len(list(entry)), 0)
step = wizard.get_current_step()
step.reason.update('test')
step.cost_center.select(cost_center)
self.check_wizard(wizard, 'stock-decrease-with-cost-center')
self.click(wizard.next_button)
step = wizard.get_current_step()
step.barcode.set_text(sellable.barcode)
step.sellable_selected(sellable)
step.quantity.update(1)
self.click(step.add_sellable_button)
with mock.patch.object(self.store, 'commit'):
self.click(wizard.next_button)
self.assertEqual(wizard.model.cost_center, cost_center)
entry = self.store.find(CostCenterEntry,
cost_center=wizard.model.cost_center)
self.assertEqual(len(list(entry)), 1)
示例8: test_show
def test_show(self, localnow):
sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', True)
localnow.return_value = localdatetime(2013, 2, 1)
sellable = self.create_sellable(code=u'Code')
workorder = self.create_workorder(description=u'Test equipment')
workorder.identifier = 666
workorder.supplier_order = u"A1234"
workorder.client = self.create_client()
workorder.sellable = sellable
workorder.category = WorkOrderCategory(store=self.store,
name=u'Categoty XXX')
workorder.defect_reported = u"Defect reported"
# Create the editor and check initial state
editor = WorkOrderEditor(self.store, model=workorder)
self.check_editor(editor, 'editor-workorder-show-initial')
self.assertEqual(editor.supplier_order.read(), u'A1234')
self.assertSensitive(editor, ['client'])
self.assertSensitive(editor, ['category', 'category_create'])
self.assertSensitive(editor, ['supplier_order'])
workorder.defect_detected = u"Defect detected"
workorder.estimated_hours = 10
workorder.estimated_hours = 100
workorder.estimated_start = localdatetime(2013, 1, 1)
workorder.estimated_finish = localdatetime(2013, 1, 2)
workorder.approve()
_adjust_history_date(workorder)
# Create another editor to check approved state
editor = WorkOrderEditor(self.store, model=workorder)
self.check_editor(editor, 'editor-workorder-show-approved')
workorder.add_sellable(self.create_sellable(description=u"Product A"),
price=99, quantity=2)
workorder.add_sellable(self.create_sellable(description=u"Product B"),
price=5, quantity=100)
workorder.work()
_adjust_history_date(workorder)
# Create another editor to check work in progress state
editor = WorkOrderEditor(self.store, model=workorder)
self.check_editor(editor, 'editor-workorder-show-in-progress')
workorder.finish()
_adjust_history_date(workorder)
# Create another editor to check finished state
editor = WorkOrderEditor(self.store, model=workorder)
self.check_editor(editor, 'editor-workorder-show-finished')
for item in workorder.order_items:
item.reserve(item.quantity)
workorder.close()
_adjust_history_date(workorder)
# Create another editor to check closed state
editor = WorkOrderEditor(self.store, model=workorder)
self.check_editor(editor, 'editor-workorder-show-closed')
示例9: test_check_payment_mandatory_check_number
def test_check_payment_mandatory_check_number(self):
sysparam.set_bool(self.store, 'MANDATORY_CHECK_NUMBER', True)
wizard = PurchaseWizard(self.store)
method = PaymentMethod.get_by_name(self.store, u'check')
order = self.create_purchase_order()
order.identifier = 123456
CheckMethodSlave(wizard, None, self.store, order, method, Decimal(200))
self.assertNotSensitive(wizard, ['next_button'])
示例10: test_create
def test_create(self):
sysparam.set_bool(self.store, 'MANDATORY_CHECK_NUMBER', True)
wizard = PurchaseWizard(self.store)
method = PaymentMethod.get_by_name(self.store, u'check')
order = self.create_purchase_order()
order.identifier = 12345
slave = CheckMethodSlave(wizard, None, self.store, order, method,
Decimal(200))
self.check_slave(slave, 'slave-check-method')
示例11: test_outdated
def test_outdated(self):
sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', False)
wizard = PurchaseWizard(self.store)
method = PaymentMethod.get_by_name(self.store, u'bill')
order = self.create_purchase_order()
today = localtoday().date()
slave = BillMethodSlave(wizard, None, self.store, order, method,
Decimal(200), today)
self.assertValid(slave, ['first_duedate'])
slave.first_duedate.update(datetime.date(2012, 01, 01))
self.assertInvalid(slave, ['first_duedate'])
示例12: test_installments
def test_installments(self):
sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', True)
wizard = PurchaseWizard(self.store)
method = PaymentMethod.get_by_name(self.store, u'bill')
order = self.create_purchase_order()
order.identifier = 12345
slave = BillMethodSlave(wizard, None, self.store, order, method,
Decimal(200), localdate(2012, 01, 01).date())
self.check_slave(slave, 'slave-bill-method-1-installments')
slave.installments_number.update(2)
self.check_slave(slave, 'slave-bill-method-2-installments')
示例13: test_show_with_sale
def test_show_with_sale(self, localnow):
sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', True)
localnow.return_value = localdatetime(2013, 12, 1)
# Create a work order with sale
workorder = self.create_workorder(description=u'Test equipment')
workorder.identifier = 1234
workorder.sale = self.create_sale()
workorder.client = self.create_client()
# Create the editor
editor = WorkOrderEditor(self.store, model=workorder)
self.assertNotSensitive(editor, ['client'])
self.assertNotSensitive(editor, ['category', 'category_create'])
self.check_editor(editor, 'editor-workorder-with-sale-show')
示例14: test_create
def test_create(self, yesno, run_dialog):
# Allow creating purchases in the past.
sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', True)
quotation = self.create_quotation()
quotation.identifier = 12345
quotation.group.identifier = 67890
def _purchase_clone():
self.purchase_clone = Domain.clone(self.purchase)
return self.purchase_clone
purchase = self.purchase = quotation.purchase
purchase.clone = _purchase_clone
purchase.open_date = localdate(2012, 1, 1).date()
self.create_purchase_order_item(purchase)
self.wizard = ReceiveQuoteWizard(self.store)
start_step = self.wizard.get_current_step()
start_step.search.refresh()
start_step.search.results.select(start_step.search.results[0])
self._check_start_step('wizard-receivequote-start-step')
self._check_start_step('wizard-receivequote-item-step')
item_step = self.wizard.get_current_step()
new_store = 'stoqlib.gui.wizards.purchasequotewizard.api.new_store'
with mock.patch(new_store) as new_store:
with mock.patch.object(self.store, 'commit'):
with mock.patch.object(self.store, 'close'):
new_store.return_value = self.store
self.click(item_step.create_order_button)
run_dialog.assert_called_once_with(PurchaseWizard,
self.wizard,
self.store,
self.purchase_clone)
yesno.assert_called_once_with(
'Should we close the quotes used to compose the '
'purchase order ?', gtk.RESPONSE_NO, 'Close quotes',
"Don't close")
self.click(self.wizard.next_button)
models = [quotation, quotation.group, purchase]
models.extend(purchase.get_items())
self.check_wizard(self.wizard, 'wizard-receivequote-finish-step',
models=models)
示例15: test_sale_selection_step_unknown_sale
def test_sale_selection_step_unknown_sale(self):
sysparam.set_bool(self.store, 'ALLOW_TRADE_NOT_REGISTERED_SALES', True)
wizard = SaleTradeWizard(self.store)
step = wizard.get_current_step()
results = step.slave.results
# Since ALLOW_TRADE_NOT_REGISTERED_SALES is True,
# the user should be able to check this
self.assertVisible(step, ['unknown_sale_check'])
# next_button should only be sensitive if a sale is selected
self.assertNotSensitive(wizard, ['next_button'])
results.select(results[0])
self.assertSensitive(wizard, ['next_button'])
results.unselect_all()
self.assertNotSensitive(wizard, ['next_button'])
self.click(step.unknown_sale_check)
self.assertSensitive(wizard, ['next_button'])
self.check_wizard(wizard, 'wizard-trade-sale-selection-step-unknown-sale')