• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python api.sysparam函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中stoqlib.api.api.sysparam函数的典型用法代码示例。如果您正苦于以下问题:Python sysparam函数的具体用法?Python sysparam怎么用?Python sysparam使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sysparam函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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')
开发者ID:qman1989,项目名称:stoq,代码行数:30,代码来源:test_batchselectiondialog.py


示例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)
开发者ID:leandrorchaves,项目名称:stoq,代码行数:29,代码来源:test_maintenance.py


示例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
开发者ID:romaia,项目名称:stoq,代码行数:7,代码来源:financial.py


示例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)
开发者ID:rosalin,项目名称:stoq,代码行数:30,代码来源:test_maintenance.py


示例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)
开发者ID:LeonamSilva,项目名称:stoq,代码行数:25,代码来源:test_purchase.py


示例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)
开发者ID:romaia,项目名称:stoq,代码行数:28,代码来源:test_sale.py


示例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)
开发者ID:romaia,项目名称:stoq,代码行数:34,代码来源:test_sale.py


示例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
开发者ID:leandrorchaves,项目名称:stoq,代码行数:8,代码来源:financial.py


示例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))
开发者ID:romaia,项目名称:stoq,代码行数:13,代码来源:test_purchase.py


示例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')
开发者ID:qman1989,项目名称:stoq,代码行数:48,代码来源:test_batchselectiondialog.py


示例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())
开发者ID:LeonamSilva,项目名称:stoq,代码行数:26,代码来源:purchase.py


示例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])
开发者ID:qman1989,项目名称:stoq,代码行数:25,代码来源:batchselectiondialog.py


示例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()
开发者ID:qman1989,项目名称:stoq,代码行数:7,代码来源:batchselectiondialog.py


示例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
开发者ID:leandrorchaves,项目名称:stoq,代码行数:31,代码来源:pos.py


示例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
开发者ID:romaia,项目名称:stoq,代码行数:25,代码来源:shell.py


示例16: cookie_login

    def cookie_login(self):
        if api.sysparam(api.get_default_store()).DISABLE_COOKIES:
            log.info("Cookies disable by parameter")
            return

        cookie_file = get_utility(ICookieFile)
        try:
            username, password = cookie_file.get()
        except CookieError:
            log.info("Not using cookie based login")
            return

        def is_md5(password):
            # This breaks for passwords that are 32 characters long,
            # uses only digits and lowercase a-f, pretty unlikely as
            # real-world password
            if len(password) != 32:
                return False
            for c in '1234567890abcdef':
                password = password.replace(c, '')
            return password == ''

        # Migrate old passwords to md5 hashes.
        if not is_md5(password):
            password = _encrypt_password(password)
            cookie_file.store(username, password)

        try:
            user = self._check_user(username, password)
        except (LoginError, UserProfileError, DatabaseError) as e:
            log.info("Cookie login failed: %r" % e)
            return

        log.info("Logging in using cookie credentials")
        return user
开发者ID:leandrorchaves,项目名称:stoq,代码行数:35,代码来源:login.py


示例17: _delete_account

    def _delete_account(self, account_view):
        store = api.new_store()
        account = store.fetch(account_view.account)
        methods = PaymentMethod.get_by_account(store, account)
        if methods.count() > 0:
            if not yesno(
                _('This account is used in at least one payment method.\n'
                  'To be able to delete it the payment methods needs to be'
                  're-configured first'), gtk.RESPONSE_NO,
                _("Configure payment methods"), _("Keep account")):
                store.close()
                return
        elif not yesno(
            _('Are you sure you want to remove account "%s" ?') % (
                (account_view.description, )), gtk.RESPONSE_NO,
            _("Remove account"), _("Keep account")):
            store.close()
            return

        if account_view.id in self._pages:
            account_page = self._pages[account_view.id]
            self._close_page(account_page)

        self.accounts.remove(account_view)
        self.accounts.flush()

        imbalance = api.sysparam(store).IMBALANCE_ACCOUNT
        for method in methods:
            method.destination_account = imbalance

        account.remove(store)
        store.commit(close=True)
开发者ID:leandrorchaves,项目名称:stoq,代码行数:32,代码来源:financial.py


示例18: create_ui

    def create_ui(self):
        if api.sysparam(self.store).SMART_LIST_LOADING:
            self.search.enable_lazy_search()

        self.popup = self.uimanager.get_widget('/StockSelection')
        self.window.add_new_items([self.NewReceiving, self.NewTransfer,
                                   self.NewStockDecrease, self.LoanNew])
        self.window.add_search_items([
            self.SearchStockItems,
            self.SearchStockDecrease,
            self.SearchClosedStockItems,
            self.SearchProductHistory,
            self.SearchPurchasedStockItems,
            self.SearchTransfer,
        ])
        self.window.Print.set_tooltip(
            _("Print a report of these products"))
        self._inventory_widgets = [self.NewTransfer, self.NewReceiving,
                                   self.StockInitial, self.NewStockDecrease,
                                   self.LoanNew, self.LoanClose]
        self.register_sensitive_group(self._inventory_widgets,
                                      lambda: not self.has_open_inventory())

        self.image_viewer = None

        self.image = gtk.Image()
        self.edit_button = self.uimanager.get_widget('/toolbar/AppToolbarPH/EditProduct')
        self.edit_button.set_icon_widget(self.image)
        self.image.show()

        self.search.set_summary_label(column='stock',
                                      label=_('<b>Stock Total:</b>'),
                                      format='<b>%s</b>',
                                      parent=self.get_statusbar_message_area())
开发者ID:tmaxter,项目名称:stoq,代码行数:34,代码来源:stock.py


示例19: on_estimated_start__validate

    def on_estimated_start__validate(self, widget, value):
        sysparam_ = api.sysparam(self.store)
        if (value < datetime.date.today() and
                not sysparam_.ALLOW_OUTDATED_OPERATIONS):
            return ValidationError(u"The start date cannot be on the past")

        self.estimated_finish.validate(force=True)
开发者ID:romaia,项目名称:stoq,代码行数:7,代码来源:workorderslave.py


示例20: get_namespace

    def get_namespace(self):
        store = self.loan.store
        sysparam_ = api.sysparam(store)

        order_identifier = unicode(self.loan.identifier)
        print_promissory_note = sysparam_.PRINT_PROMISSORY_NOTE_ON_LOAN
        branch = api.get_current_branch(store)
        drawer_person = self.loan.branch.person
        drawee_person = self.loan.client.person
        emission_address = branch.person.get_main_address()
        emission_location = emission_address.city_location

        promissory_data = Settable(
            order_identifier=order_identifier,
            payment_number=None,
            drawee=drawee_person.name,
            drawer=branch.get_description(),
            drawee_document=self._get_person_document(drawee_person),
            drawer_document=self._get_person_document(drawer_person),
            drawee_address=self._get_person_address(drawee_person),
            drawer_address=self._get_person_address(drawer_person),
            due_date=self.loan.expire_date,
            value=self.loan.get_total_amount(),
            emission_city=emission_location.city,
            emission_date=datetime.date.today(),
        )

        return dict(
            subtitle=_("Loan number: %s") % order_identifier,
            loan=self.loan,
            print_promissory_note=print_promissory_note,
            promissory_data=promissory_data,
        )
开发者ID:LeonamSilva,项目名称:stoq,代码行数:33,代码来源:loanreceipt.py



注:本文中的stoqlib.api.api.sysparam函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python api.trans函数代码示例发布时间:2022-05-27
下一篇:
Python api.prepare_test函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap