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

Python sysparam.get_object函数代码示例

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

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



在下文中一共展示了get_object函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: create_from_payment

    def create_from_payment(cls, payment, account=None):
        """Create a new transaction based on a |payment|.
        It's normally used when creating a transaction which represents
        a payment, for instance when you receive a bill or a check from
        a |client| which will enter a |bankaccount|.

        :param payment: the |payment| to create the transaction for.
        :param account: if an outgoing payment, the |account| will be the source of
          transaction. Otherwise will be the destination account.
        :returns: the transaction
        """
        if not payment.is_paid():
            raise PaymentError(_("Payment needs to be paid"))
        store = payment.store
        value = payment.paid_value
        if payment.is_outpayment():
            operation_type = cls.TYPE_OUT
            source = account or payment.method.destination_account
            destination = sysparam.get_object(store, 'IMBALANCE_ACCOUNT')
        else:
            operation_type = cls.TYPE_IN
            source = sysparam.get_object(store, 'IMBALANCE_ACCOUNT')
            destination = account or payment.method.destination_account
        return cls(source_account=source,
                   account=destination,
                   value=value,
                   description=payment.description,
                   code=unicode(payment.identifier),
                   date=payment.paid_date,
                   store=store,
                   payment=payment,
                   operation_type=operation_type)
开发者ID:barkinet,项目名称:stoq,代码行数:32,代码来源:account.py


示例2: _update_accounts

    def _update_accounts(self):
        if len(self._payments) != 1:
            return

        payment = self._payments[0]
        create_transaction = payment.method.operation.create_transaction()
        for combo in [self.destination_account, self.source_account]:
            combo.set_sensitive(create_transaction)

        if not create_transaction:
            return

        destination_combo = self.get_account_destination_combo()
        for combo in [self.destination_account, self.source_account]:
            combo.prefill(api.for_combo(
                self.store.find(Account),
                attr='long_description'))

            if combo is destination_combo:
                combo.select(payment.method.destination_account)
            else:
                combo.select(
                    sysparam.get_object(self.store, 'IMBALANCE_ACCOUNT'))

        category_account = payment.category and payment.category.account
        if category_account:
            if payment.payment_type == payment.TYPE_IN:
                self.source_account.select(category_account)
            else:
                self.destination_account.select(category_account)
开发者ID:hackedbellini,项目名称:stoq,代码行数:30,代码来源:paymentconfirmslave.py


示例3: test_can_remove

    def test_can_remove(self):
        sellable = Sellable(store=self.store)
        self.assertTrue(sellable.can_remove())

        sellable = self.create_sellable()
        storable = Storable(product=sellable.product, store=self.store)
        self.assertTrue(sellable.can_remove())

        branch = get_current_branch(self.store)
        storable.increase_stock(1, branch,
                                StockTransactionHistory.TYPE_INITIAL, None)
        sale = self.create_sale()
        sale.status = Sale.STATUS_QUOTE
        sale.branch = branch
        sale.add_sellable(sellable)
        self.assertFalse(sellable.can_remove())

        # Can't remove the sellable if it's in a purchase.
        from stoqlib.domain.purchase import PurchaseItem
        sellable = self.create_sellable()
        Storable(product=sellable.product, store=self.store)
        self.assertTrue(sellable.can_remove())
        PurchaseItem(store=self.store,
                     quantity=8, quantity_received=0,
                     cost=125, base_cost=125,
                     sellable=sellable,
                     order=self.create_purchase_order())
        self.assertFalse(sellable.can_remove())

        # The delivery service cannot be removed.
        sellable = sysparam.get_object(self.store, 'DELIVERY_SERVICE').sellable
        self.assertFalse(sellable.can_remove())
开发者ID:hackedbellini,项目名称:stoq,代码行数:32,代码来源:test_sellable.py


示例4: test_account_remove

    def test_account_remove(self):
        a1 = self.create_account()
        a2 = self.create_account()

        imbalance_account = sysparam.get_object(self.store, 'IMBALANCE_ACCOUNT')

        t1 = self.create_account_transaction(a1)
        t1.source_account = a2
        self.store.flush()

        t2 = self.create_account_transaction(a2)
        t2.source_account = a1
        self.store.flush()

        a2.parent = a1
        with self.assertRaises(TypeError):
            a1.remove(self.store)
        a2.parent = None

        a1.station = self.create_station()
        self.assertRaises(TypeError, a1.remove)
        a1.station = None

        a1.remove(self.store)

        self.assertEqual(t1.account, imbalance_account)
        self.assertEqual(t2.source_account, imbalance_account)
开发者ID:hackedbellini,项目名称:stoq,代码行数:27,代码来源:test_account.py


示例5: _create_or_update_delivery

    def _create_or_update_delivery(self):
        delivery_service = sysparam.get_object(self.store, 'DELIVERY_SERVICE')
        delivery_sellable = delivery_service.sellable

        items = [item for item in self.slave.klist
                 if item.sellable.product is not None]

        if self._delivery is not None:
            model = self._delivery

        else:
            model = CreateDeliveryModel(
                price=delivery_sellable.price, recipient=self.model.person)

        rv = run_dialog(
            CreateDeliveryEditor, self.get_toplevel().get_toplevel(),
            self.store, model=model, items=items, person_type=Person)

        if not rv:
            return

        self._delivery = rv
        if self._delivery_item:
            self.slave.klist.update(self._delivery_item)
        else:
            self._delivery_item = self.get_order_item(
                delivery_sellable, self._delivery.price, 1)
            self.slave.klist.append(None, self._delivery_item)
开发者ID:hackedbellini,项目名称:stoq,代码行数:28,代码来源:stockdecreasewizard.py


示例6: _register_branch_station

def _register_branch_station(caller_store, station_name):
    import gtk
    from stoqlib.lib.parameters import sysparam

    if not sysparam.get_bool('DEMO_MODE'):
        fmt = _(u"The computer '%s' is not registered to the Stoq "
                u"server at %s.\n\n"
                u"Do you want to register it "
                u"(requires administrator access) ?")
        if not yesno(fmt % (station_name,
                            db_settings.address),
                     gtk.RESPONSE_YES, _(u"Register computer"), _(u"Quit")):
            raise SystemExit

        from stoqlib.gui.utils.login import LoginHelper
        h = LoginHelper(username="admin")
        try:
            user = h.validate_user()
        except LoginError as e:
            error(str(e))

        if not user:
            error(_("Must login as 'admin'"))

    from stoqlib.domain.station import BranchStation
    with new_store() as store:
        branch = sysparam.get_object(store, 'MAIN_COMPANY')
        station = BranchStation.create(store, branch=branch, name=station_name)
    return caller_store.fetch(station)
开发者ID:relsi,项目名称:stoq,代码行数:29,代码来源:runtime.py


示例7: __init__

    def __init__(self, store, hide_footer=False, hide_toolbar=True,
                 selection_mode=None, search_str=None, search_spec=None,
                 search_query=None, double_click_confirm=True, info_message=None):
        """
        :param store: a store
        :param hide_footer: do I have to hide the dialog footer?
        :param hide_toolbar: do I have to hide the dialog toolbar?
        :param selection_mode: the kiwi list selection mode
        :param search_str: If this search should already filter for some string
        :param double_click_confirm: If double click a item in the list should
            automatically confirm
        """
        if selection_mode is None:
            selection_mode = gtk.SELECTION_BROWSE

        self._image_viewer = None
        self._first_search = True
        self._first_search_string = search_str
        self._search_query = search_query
        self._delivery_sellable = sysparam.get_object(
            store, 'DELIVERY_SERVICE').sellable

        SearchEditor.__init__(self, store, search_spec=search_spec,
                              editor_class=self.editor_class,
                              hide_footer=hide_footer,
                              hide_toolbar=hide_toolbar,
                              selection_mode=selection_mode,
                              double_click_confirm=double_click_confirm)

        if info_message:
            self.set_message(info_message)

        if search_str:
            self.set_searchbar_search_string(search_str)
            self.search.refresh()
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:35,代码来源:sellablesearch.py


示例8: test_get_available_sellables_query

    def test_get_available_sellables_query(self):
        # Sellable and query without supplier
        sellable = self.create_sellable()
        self.create_storable(product=sellable.product,
                             branch=self.create_branch())

        self.assertIn(
            sellable,
            self.store.find(Sellable,
                            Sellable.get_available_sellables_query(self.store)))

        sellable.close()
        self.assertNotIn(
            sellable,
            self.store.find(Sellable,
                            Sellable.get_available_sellables_query(self.store)))

        delivery_sellable = sysparam.get_object(self.store, 'DELIVERY_SERVICE').sellable
        delivery_sellable.status = Sellable.STATUS_AVAILABLE
        # Deliveries are treated differently, that's why they should
        # not be present here
        self.assertNotIn(
            sellable,
            self.store.find(Sellable,
                            Sellable.get_available_sellables_query(self.store)))
开发者ID:hackedbellini,项目名称:stoq,代码行数:25,代码来源:test_sellable.py


示例9: get_sellable_view_query

    def get_sellable_view_query(self):
        delivery_sellable = sysparam.get_object(
            self.store, 'DELIVERY_SERVICE').sellable

        query = And(ServiceView.status == Sellable.STATUS_AVAILABLE,
                    ServiceView.id != delivery_sellable.id)
        return self.sellable_view, query
开发者ID:Guillon88,项目名称:stoq,代码行数:7,代码来源:productionwizard.py


示例10: __init__

    def __init__(self, store, product, visual_mode=False):
        self._product = product
        BaseRelationshipEditorSlave.__init__(self, store, visual_mode=visual_mode)

        suggested = sysparam.get_object(store, 'SUGGESTED_SUPPLIER')
        if suggested is not None:
            self.target_combo.select(suggested)
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:7,代码来源:productslave.py


示例11: get_tax_template

    def get_tax_template(cls, invoice_item):
        default_cofins = sysparam.get_object(invoice_item.store, 'DEFAULT_PRODUCT_COFINS_TEMPLATE')
        # FIXME: Allow use COFINS templates in services
        if invoice_item.sellable.service:
            return default_cofins

        return invoice_item.sellable.product.cofins_template or default_cofins
开发者ID:hackedbellini,项目名称:stoq,代码行数:7,代码来源:taxes.py


示例12: test_wizard_remove_delivery

    def test_wizard_remove_delivery(self, yesno):
        yesno.return_value = True
        branch = api.get_current_branch(self.store)
        storable = self.create_storable(branch=branch, stock=1)
        sellable = storable.product.sellable
        # Run the wizard
        wizard = StockDecreaseWizard(self.store)
        step = wizard.get_current_step()
        step.reason.update('test')
        self.click(wizard.next_button)
        step = wizard.get_current_step()
        self.assertNotSensitive(step, ['delivery_button'])
        step.sellable_selected(sellable)
        step.quantity.update(1)
        self.click(step.add_sellable_button)
        self.assertSensitive(step, ['delivery_button'])

        delivery_sellable = sysparam.get_object(self.store, 'DELIVERY_SERVICE').sellable
        delivery = CreateDeliveryModel(price=delivery_sellable.price,
                                       recipient=wizard.model.person)

        module = 'stoqlib.gui.wizards.stockdecreasewizard.run_dialog'
        with mock.patch(module) as run_dialog:
            # Delivery set
            run_dialog.return_value = delivery
            self.click(step.delivery_button)
            self.assertEqual(step._delivery, delivery)
            self.assertTrue(isinstance(step._delivery_item, StockDecreaseItem))

            # Remove the delivery item
            run_dialog.return_value = delivery
            step.slave.klist.select(step.slave.klist[1])
            self.click(step.slave.delete_button)
            self.assertIsNone(step._delivery)
            self.assertIsNone(step._delivery_item)
开发者ID:hackedbellini,项目名称:stoq,代码行数:35,代码来源:test_stockdecreasewizard.py


示例13: _get_parameter_value

    def _get_parameter_value(self, obj):
        """Given a ParameterData object, returns a string representation of
        its current value.
        """
        detail = sysparam.get_detail_by_name(obj.field_name)
        if detail.type == unicode:
            data = sysparam.get_string(obj.field_name)
        elif detail.type == bool:
            data = sysparam.get_bool(obj.field_name)
        elif detail.type == int:
            data = sysparam.get_int(obj.field_name)
        elif detail.type == decimal.Decimal:
            data = sysparam.get_decimal(obj.field_name)
        elif isinstance(detail.type, basestring):
            data = sysparam.get_object(self.store, obj.field_name)
        else:
            raise NotImplementedError(detail.type)

        if isinstance(data, Domain):
            if not (IDescribable in providedBy(data)):
                raise TypeError(u"Parameter `%s' must implement IDescribable "
                                "interface." % obj.field_name)
            return data.get_description()
        elif detail.options:
            return detail.options[int(obj.field_value)]
        elif isinstance(data, bool):
            return [_(u"No"), _(u"Yes")][data]
        elif obj.field_name == u'COUNTRY_SUGGESTED':
            return dgettext("iso_3166", data)
        elif isinstance(data, unicode):
            # FIXME: workaround to handle locale specific data
            return _(data)
        return unicode(data)
开发者ID:pkaislan,项目名称:stoq,代码行数:33,代码来源:parametersearch.py


示例14: 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


示例15: _load_tax_values

    def _load_tax_values(self, item):
        assert item
        sellable = item.sellable
        product = sellable.product
        service = sellable.service
        delivery = sysparam.get_object(item.store, 'DELIVERY_SERVICE').sellable
        if product:
            code = product.ncm or ''
            ex_tipi = self._format_ex(product.ex_tipi)
        else:
            if not self.include_services or sellable == delivery:
                return

            code = '%04d' % int(service.service_list_item_code.replace('.', ''))
            ex_tipi = ''

        options = taxes_data.get(code, {})
        n_options = len(options)
        if n_options == 0:
            tax_values = TaxInfo('0', '0', '0', '', '0')
        elif n_options == 1:
            tax_values = options['']
        else:
            tax_values = options.get(ex_tipi) or options['']
        return tax_values
开发者ID:hackedbellini,项目名称:stoq,代码行数:25,代码来源:ibpt.py


示例16: __init__

 def __init__(self, store=None, **kw):
     super(ReceivingOrder, self).__init__(store=store, **kw)
     # These miss default parameters and needs to be set before
     # cfop, which triggers an implicit flush.
     self.branch = kw.pop('branch', None)
     if not 'cfop' in kw:
         self.cfop = sysparam.get_object(store, 'DEFAULT_RECEIVING_CFOP')
开发者ID:hackedbellini,项目名称:stoq,代码行数:7,代码来源:receiving.py


示例17: __init__

 def __init__(self, store=None, **kw):
     Domain.__init__(self, store=store, **kw)
     # These miss default parameters and needs to be set before
     # cfop, which triggers an implicit flush.
     self.branch = kw.pop("branch", None)
     self.supplier = kw.pop("supplier", None)
     if not "cfop" in kw:
         self.cfop = sysparam.get_object(store, "DEFAULT_RECEIVING_CFOP")
开发者ID:amaurihamasu,项目名称:stoq,代码行数:8,代码来源:receiving.py


示例18: _set_person_utilities

def _set_person_utilities():
    store = new_store()
    branch = sysparam.get_object(store, 'MAIN_COMPANY')
    provide_utility(ICurrentBranch, branch)

    station = BranchStation(name=u"Stoqlib station", branch=branch,
                            store=store, is_active=True)
    provide_utility(ICurrentBranchStation, station)
    store.commit(close=True)
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:9,代码来源:stoqlibexamples.py


示例19: validate_confirm

    def validate_confirm(self):
        if not sysparam.get_bool('BLOCK_PAYMENT_FOR_IMBALANCE_ACCOUNT'):
            return True

        accounts = [self.source_account.get_selected(), self.destination_account.get_selected()]
        if sysparam.get_object(self.store, 'IMBALANCE_ACCOUNT') in accounts:
            warning(_('You must inform the source and destination accounts'))
            return False
        return True
开发者ID:hackedbellini,项目名称:stoq,代码行数:9,代码来源:paymentconfirmslave.py


示例20: _create_delivery

    def _create_delivery(self):
        delivery_param = sysparam.get_object(self.store, 'DELIVERY_SERVICE')
        if delivery_param.sellable in self.sale_items:
            self._delivery = delivery_param.sellable

        delivery = self._edit_delivery()
        if delivery:
            self._add_delivery_item(delivery, delivery_param.sellable)
            self._delivery = delivery
开发者ID:pkaislan,项目名称:stoq,代码行数:9,代码来源:pos.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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