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

Python sysparam.set_bool函数代码示例

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

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



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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


示例16: test_work_order_editor

    def test_work_order_editor(self):
        sysparam.set_bool(self.store,
                          'ALLOW_OUTDATED_OPERATIONS',
                          True)

        sale = self.create_sale()
        workorder = self.create_workorder()
        workorder.identifier = 1234
        workorder.open_date = localdate(2012, 1, 1)
        workorder.sale = sale

        editor = WorkOrderEditor(store=self.store, model=workorder)
        self.check_editor(editor, u'editor-work-order-optical-plugin')

        # FIXME: baseditor should probably add an api for getting a list
        #        of buttons
        print_button = editor.main_dialog.action_area.get_children()[0]
        assert print_button.get_label() == gtk.STOCK_PRINT
        with mock.patch('plugins.optical.opticalui.print_report') as print_report_:
            self.click(print_button)
            print_report_.assert_called_once_with(
                OpticalWorkOrderReceiptReport, [editor.model])
开发者ID:Joaldino,项目名称:stoq,代码行数:22,代码来源:test_optical_ui.py


示例17: test_create

    def test_create(self, localnow):
        sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', False)

        localnow.return_value = localdatetime(2013, 1, 1)

        # Create those before initializating the editor so they get prefilled
        category = WorkOrderCategory(store=self.store,
                                     name=u'Categoty XXX')
        client = self.create_client()

        with self.sysparam(DEFECT_DETECTED_TEMPLATE=u"XXX\nYYY"):
            editor = WorkOrderEditor(self.store)
            self.assertEqual(editor.model.defect_detected, u"XXX\nYYY")

        editor.model.identifier = 654
        self.assertEqual(editor.supplier_order.read(), u"")
        editor.supplier_order.update(u"A1234")
        editor.proxy.update('identifier')
        editor.proxy.update('supplier_order')
        self.assertEqual(editor.supplier_order.read(), u"A1234")
        opening_slave = editor.opening_slave
        execution_slave = editor.execution_slave
        item_slave = execution_slave.sellable_item_slave
        quote_slave = editor.quote_slave
        self.assertSensitive(editor, ['client'])
        self.assertSensitive(editor, ['supplier_order'])
        self.assertNotSensitive(editor, ['category_edit'])
        # Check creation state
        self.assertEqual(editor.model.status, WorkOrder.STATUS_OPENED)
        self.check_editor(editor, 'editor-workorder-create')

        editor.description.update(u"Test equipment")
        editor.category.update(category)
        self.assertNotSensitive(editor, ['toggle_status_btn'])
        editor.client_gadget.set_value(client)
        self.assertSensitive(editor, ['toggle_status_btn'])
        opening_slave.defect_reported.update(u"Defect reported")
        # Check initial state
        self.assertEqual(editor.model.status, WorkOrder.STATUS_OPENED)
        self.check_editor(editor, 'editor-workorder-create-initial')

        quote_slave.defect_detected.update(u"Defect detected")
        quote_slave.estimated_hours.update(10)
        quote_slave.estimated_hours.update(100)
        quote_slave.estimated_start.update(localdatetime(2013, 1, 1))
        quote_slave.estimated_finish.update(localdatetime(2013, 1, 2))
        self.assertInvalid(quote_slave, ['estimated_start'])

        sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', True)
        quote_slave.estimated_start.validate(force=True)
        self.assertValid(quote_slave, ['estimated_start'])
        # Clicking the first time will approve the order (put it on waiting state)
        self.click(editor.toggle_status_btn)
        self.assertEqual(editor.model.status, WorkOrder.STATUS_WORK_WAITING)
        # The second time will start thr work
        self.click(editor.toggle_status_btn)
        self.assertEqual(editor.model.status, WorkOrder.STATUS_WORK_IN_PROGRESS)
        _adjust_history_date(editor.model)
        # FIXME: For some reason, history_slave.update_items is not really
        # updating the list (it calls add_list that should do that) and because
        # of that the items' dates are not updated when they should
        # (update_items will call add_list that should call clear before).
        # Calling clear here fixes the problem, but it should not be necessary.
        # This is probably a kiwi issue
        editor.history_slave.details_list.clear()
        editor.history_slave.update_items()
        self.check_editor(editor, 'editor-workorder-create-approved')

        product_sellable = self.create_product(stock=100).sellable
        product_sellable.barcode = u'9988776655'
        service_sellable = self.create_service().sellable
        service_sellable.barcode = u'5566778899'
        item_slave.barcode.set_text(product_sellable.barcode)
        item_slave.barcode.activate()
        item_slave.cost.update(50)
        item_slave.quantity.update(101)
        self.assertNotSensitive(item_slave, ['add_sellable_button'])
        item_slave.quantity.update(99)
        self.assertSensitive(item_slave, ['add_sellable_button'])
        self.click(item_slave.add_sellable_button)
        item_slave.barcode.set_text(service_sellable.barcode)
        item_slave.barcode.activate()
        item_slave.cost.update(100)
        item_slave.quantity.update(2)
        self.click(item_slave.add_sellable_button)
        # Check work in progress state
        self.check_editor(editor, 'editor-workorder-create-in-progress')

        self.click(editor.main_dialog.ok_button)
        storable = product_sellable.product_storable
        # This should be 1 since we created it with 100 and used 99 in the order
        self.assertEqual(
            storable.get_balance_for_branch(editor.model.branch), 1)
开发者ID:Guillon88,项目名称:stoq,代码行数:93,代码来源:test_workordereditor.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python permissions.PermissionManager类代码示例发布时间:2022-05-27
下一篇:
Python sysparam.get_string函数代码示例发布时间: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