本文整理汇总了Python中stoqlib.api.api.sysparam函数的典型用法代码示例。如果您正苦于以下问题:Python sysparam函数的具体用法?Python sysparam怎么用?Python sysparam使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sysparam函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_batch_number_suggestion
def test_batch_number_suggestion(self):
branch = api.get_current_branch(self.store)
branch.acronym = u'AB'
storable = self.create_storable(is_batch=True)
storable2 = self.create_storable(is_batch=True)
dialog = BatchIncreaseSelectionDialog(self.store, storable, 10)
self.assertEqual(dialog._last_entry.get_text(), '')
api.sysparam(self.store).update_parameter(u'SUGGEST_BATCH_NUMBER', u'1')
try:
storable.register_initial_stock(1, self.create_branch(), 0,
batch_number=u'123')
dialog = BatchIncreaseSelectionDialog(self.store, storable, 10)
# Make sure it suggested right
self.assertEqual(dialog._last_entry.get_text(), '124')
spinbutton = dialog.get_spin_by_entry(dialog._last_entry)
spinbutton.update(5)
# Updating the spinbutton should append a new entry with the suggestion
self.assertEqual(dialog._last_entry.get_text(), '125')
self.click(dialog.main_dialog.ok_button)
dialog = BatchIncreaseSelectionDialog(self.store, storable2, 10)
# Since the dialog above was confirmed on the same store this one is,
# it should consider it's batch numbers for the next suggestion
self.assertEqual(dialog._last_entry.get_text(), '126')
finally:
api.sysparam(self.store).update_parameter(u'SUGGEST_BATCH_NUMBER', u'0')
示例2: test_cancel_workorder_confirm
def test_cancel_workorder_confirm(self, new_store, yesno):
new_store.return_value = self.store
self.clean_domain([WorkOrderItem, WorkOrder])
workorder = self.create_workorder()
api.sysparam(self.store).update_parameter(u'SMART_LIST_LOADING', u'0')
app = self.create_app(MaintenanceApp, u'maintenance')
olist = app.results
olist.select(olist[0])
# Initial status for the order is Opened
self.assertEquals(workorder.status, WorkOrder.STATUS_OPENED)
self.assertSensitive(app, ['Cancel'])
with mock.patch.object(self.store, 'close'):
with mock.patch.object(self.store, 'commit'):
# Click the cancel order, and confirm the change
yesno.return_value = True
self.activate(app.Cancel)
yesno.assert_called_once_with(u"This will cancel the selected "
u"order. Are you sure?",
gtk.RESPONSE_NO, u"Cancel order",
u"Don't cancel")
# Status should be updated to cancelled.
self.assertEquals(workorder.status, WorkOrder.STATUS_CANCELLED)
示例3: __init__
def __init__(self, app, store=None):
self._pages = {}
self.accounts = AccountTree()
AppWindow.__init__(self, app, store=store)
self._tills_account = api.sysparam(self.store).TILLS_ACCOUNT
self._imbalance_account = api.sysparam(self.store).IMBALANCE_ACCOUNT
self._banks_account = api.sysparam(self.store).BANKS_ACCOUNT
示例4: test_cancel_workorder_confirm
def test_cancel_workorder_confirm(self, new_store, run_dialog):
new_store.return_value = self.store
self.clean_domain([WorkOrderItem, WorkOrder])
workorder = self.create_workorder()
api.sysparam(self.store).update_parameter(u'SMART_LIST_LOADING', u'0')
app = self.create_app(MaintenanceApp, u'maintenance')
olist = app.results
olist.select(olist[0])
# Initial status for the order is Opened
self.assertEquals(workorder.status, WorkOrder.STATUS_OPENED)
self.assertSensitive(app, ['Cancel'])
with mock.patch.object(self.store, 'close'):
with mock.patch.object(self.store, 'commit'):
# Click the cancel order, and confirm the change
run_dialog.return_value = Note(notes=u'xxx')
self.activate(app.Cancel)
run_dialog.assert_called_once_with(
NoteEditor, self.store,
message_text=(u'This will cancel the selected order. '
u'Are you sure?'),
model=Note(), mandatory=True, label_text=u'Reason')
# Status should be updated to cancelled.
self.assertEquals(workorder.status, WorkOrder.STATUS_CANCELLED)
示例5: test_confirm_order
def test_confirm_order(self, new_store, yesno):
new_store.return_value = self.store
yesno.return_value = True
self.clean_domain([ReceivingOrderItem, ReceivingOrder,
PurchaseItem, PurchaseOrder])
purchase = self.create_purchase_order()
purchase.add_item(self.create_sellable(), 2)
purchase.status = PurchaseOrder.ORDER_PENDING
api.sysparam(self.store).update_parameter(u'SMART_LIST_LOADING', u'0')
app = self.create_app(PurchaseApp, u'purchase')
olist = app.results
olist.select(olist[0])
with mock.patch.object(self.store, 'close'):
with mock.patch.object(self.store, 'commit'):
self.activate(app.Confirm)
yesno.assert_called_once_with(u'The selected order will be '
u'marked as sent.',
gtk.RESPONSE_YES,
u"Confirm order", u"Don't confirm")
self.assertEquals(purchase.status, PurchaseOrder.ORDER_CONFIRMED)
示例6: testCommissionCreateOnPay
def testCommissionCreateOnPay(self):
api.sysparam(self.store).update_parameter(
u'SALE_PAY_COMMISSION_WHEN_CONFIRMED', u'0')
sale = self.create_sale()
self.add_product(sale, quantity=1, price=200)
sale.order()
self.add_payments(sale, method_type=u'bill', installments=10)
for p in sale.payments:
self.assertEqual(
self.store.find(Commission, payment=p).count(), 0)
sale.confirm()
for p in sale.payments:
# Confirming should not create commissions
self.assertEqual(
self.store.find(Commission, payment=p).count(), 0)
# Paying should create the commission
p.pay()
self.assertEqual(
self.store.find(Commission, payment=p).count(), 1)
# Setting as paid should not create another commission
sale.set_paid()
for p in sale.payments:
self.assertEqual(
self.store.find(Commission, payment=p).count(), 1)
示例7: testCommissionCreateAtEnd
def testCommissionCreateAtEnd(self):
api.sysparam(self.store).update_parameter(
u'SALE_PAY_COMMISSION_WHEN_CONFIRMED', u'0')
sale = self.create_sale()
self.add_product(sale, quantity=1, price=200)
sale.order()
self.add_payments(sale, method_type=u'bill', installments=10)
for p in sale.payments:
self.assertEqual(
self.store.find(Commission, payment=p).count(), 0)
sale.confirm()
transaction = IPaymentTransaction(sale)
fake = lambda p: None
# Mimic out old behaviour of only creating commissions for payments
# when all payments on a sale are set as paid.
with mock.patch.object(transaction, 'create_commission', new=fake):
for p in sale.payments:
# Confirming should not create commissions
self.assertEqual(
self.store.find(Commission, payment=p).count(), 0)
# Since we are mimicking the old behaviour, commission
# should not be created here.
p.pay()
self.assertEqual(
self.store.find(Commission, payment=p).count(), 0)
# Setting as paid should create all the missing commissions
sale.set_paid()
for p in sale.payments:
self.assertEqual(
self.store.find(Commission, payment=p).count(), 1)
示例8: __init__
def __init__(self, window, store=None):
# Account id -> TransactionPage
self._pages = {}
self.accounts = AccountTree()
ShellApp.__init__(self, window, store=store)
self._tills_account = api.sysparam(self.store).TILLS_ACCOUNT
self._imbalance_account = api.sysparam(self.store).IMBALANCE_ACCOUNT
self._banks_account = api.sysparam(self.store).BANKS_ACCOUNT
示例9: test_print_report
def test_print_report(self, print_report):
api.sysparam(self.store).update_parameter(u'SMART_LIST_LOADING', u'0')
app = self.create_app(PurchaseApp, u'purchase')
self.activate(app.launcher.Print)
self.assertEquals(print_report.call_count, 1)
args, kwargs = print_report.call_args
report, results, views = args
self.assertEquals(report, PurchaseReport)
self.assertTrue(isinstance(results, SearchResults))
for view in views:
self.assertTrue(isinstance(view, PurchaseOrderView))
示例10: test_batch_number_suggestion_synchronized_mode
def test_batch_number_suggestion_synchronized_mode(self):
branch = api.get_current_branch(self.store)
branch.acronym = u'AB'
storable = self.create_storable(is_batch=True)
storable2 = self.create_storable(is_batch=True)
dialog = BatchIncreaseSelectionDialog(self.store, storable, 10)
self.assertEqual(dialog._last_entry.get_text(), '')
try:
api.sysparam(self.store).update_parameter(u'SUGGEST_BATCH_NUMBER', u'1')
# We need to do this by hand sincr update_parameter won't let us
# update value for some parameters (SYNCHRONIZED_MODE is one of them)
api.sysparam(self.store).SYNCHRONIZED_MODE = u'1'
api.sysparam(self.store).rebuild_cache_for(u'SYNCHRONIZED_MODE')
storable.register_initial_stock(1, self.create_branch(), 0,
batch_number=u'130')
dialog = BatchIncreaseSelectionDialog(self.store, storable, 10)
# Make sure it suggested right
self.assertEqual(dialog._last_entry.get_text(), '131-AB')
spinbutton = dialog.get_spin_by_entry(dialog._last_entry)
spinbutton.update(5)
# Updating the spinbutton should append a new entry with the suggestion
self.assertEqual(dialog._last_entry.get_text(), '132-AB')
self.click(dialog.main_dialog.ok_button)
dialog = BatchIncreaseSelectionDialog(self.store, storable2, 10)
# Since the dialog above was confirmed on the same store this one is,
# it should consider it's batch numbers for the next suggestion
self.assertEqual(dialog._last_entry.get_text(), '133-AB')
branch.acronym = None
spinbutton = dialog.get_spin_by_entry(dialog._last_entry)
# FIXME: Why is this not working? If i put a print before .update
# and one after, I can see the traceback raises between the prints,
# GUITest will say that there was an unhandled exception (this one)
# and assertRaisesRegexp will say that ValueError wasn't raised. WTF???
#with self.assertRaisesRegexp(
# ValueError,
# ("branch 'Moda Stoq' needs an acronym since we are on "
# "synchronized mode")):
# spinbutton.update(1)
finally:
api.sysparam(self.store).update_parameter(u'SUGGEST_BATCH_NUMBER', u'0')
api.sysparam(self.store).SYNCHRONIZED_MODE = u'0'
api.sysparam(self.store).rebuild_cache_for(u'SYNCHRONIZED_MODE')
示例11: create_ui
def create_ui(self):
if api.sysparam(self.store).SMART_LIST_LOADING:
self.search.enable_lazy_search()
self.window.add_new_items([
self.NewOrder,
self.NewQuote,
self.NewProduct,
self.NewConsignment])
self.window.add_search_items([
self.Products,
self.Suppliers,
self.SearchQuotes,
self.Services])
self.search.set_summary_label(column='total',
label=('<b>%s</b>' %
api.escape(_('Orders total:'))),
format='<b>%s</b>',
parent=self.get_statusbar_message_area())
self.results.set_selection_mode(gtk.SELECTION_MULTIPLE)
self.Confirm.set_sensitive(False)
self._inventory_widgets = [self.NewConsignment,
self.CloseInConsignment]
self.register_sensitive_group(self._inventory_widgets,
lambda: not self.has_open_inventory())
示例12: _get_next_batch_number
def _get_next_batch_number(self):
max_db = StorableBatch.get_max_value(self.store,
StorableBatch.batch_number)
max_used = max_value_for(self._get_used_batches() | set([max_db]))
if not api.sysparam(self.store).SYNCHRONIZED_MODE:
return next_value_for(max_used)
# On synchronized mode we need to append the branch acronym
# to avoid conflicts
max_used_list = max_used.split('-')
if len(max_used_list) == 1:
# '123'
max_used = max_used_list[0]
elif len(max_used_list) == 2:
# '123-AB'
max_used = max_used_list[0]
else:
# '123-456-AB'
max_used = ''.join(max_used_list[:-1])
branch = api.get_current_branch(self.store)
if not branch.acronym:
raise ValueError("branch '%s' needs an acronym since we are on "
"synchronized mode" % (branch.get_description(),))
return '-'.join([next_value_for(max_used), branch.acronym])
示例13: get_batch_item
def get_batch_item(self, batch):
if batch is not None:
return batch.batch_number
if not api.sysparam(self.store).SUGGEST_BATCH_NUMBER:
return None
return self._get_next_batch_number()
示例14: _get_sellable
def _get_sellable(self):
barcode = self.barcode.get_text()
if not barcode:
raise StoqlibError("_get_sellable needs a barcode")
barcode = unicode(barcode)
fmt = api.sysparam(self.store).SCALE_BARCODE_FORMAT
# Check if this barcode is from a scale
info = parse_barcode(barcode, fmt)
if info:
barcode = info.code
weight = info.weight
sellable = self.store.find(Sellable, barcode=barcode,
status=Sellable.STATUS_AVAILABLE).one()
# If the barcode didnt match, maybe the user typed the product code
if not sellable:
sellable = self.store.find(Sellable, code=barcode,
status=Sellable.STATUS_AVAILABLE).one()
# If the barcode has the price information, we need to calculate the
# corresponding weight.
if info and sellable and info.mode == BarcodeInfo.MODE_PRICE:
weight = info.price / sellable.price
if info and sellable:
self.quantity.set_value(weight)
return sellable
示例15: run_embedded
def run_embedded(self, appdesc, app_window, params=None):
app = self._load_app(appdesc, app_window)
app.launcher = app_window
self._current_app = app
self._appname = appdesc.name
if appdesc.name in self._blocked_apps:
app_window.show()
return
app.run(params)
# Possibly correct window position (livecd workaround for small
# screens)
from stoqlib.lib.pluginmanager import get_plugin_manager
manager = get_plugin_manager()
from stoqlib.api import api
if (api.sysparam(api.get_default_store()).DEMO_MODE
and manager.is_active(u'ecf')):
pos = app.main_window.toplevel.get_position()
if pos[0] < 220:
app.main_window.toplevel.move(220, pos[1])
return app