当前位置: 首页>>代码示例>>Python>>正文


Python sysparam.get_bool函数代码示例

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


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

示例1: return_sale

def return_sale(parent, sale, store):
    from stoqlib.gui.wizards.salereturnwizard import SaleReturnWizard

    cancel_last_coupon = sysparam.get_bool('ALLOW_CANCEL_LAST_COUPON')
    if cancel_last_coupon and ECFIsLastSaleEvent.emit(sale):
        info(_("That is last sale in ECF. Return using the menu "
               "ECF - Cancel Last Document"))
        return

    if sale.can_return():
        need_document = not sysparam.get_bool('ACCEPT_SALE_RETURN_WITHOUT_DOCUMENT')
        if need_document and not sale.get_client_document():
            warning(_('It is not possible to accept a returned sale from clients '
                      'without document. Please edit the client document or change '
                      'the sale client'))
            return

        returned_sale = sale.create_sale_return_adapter()
        retval = run_dialog(SaleReturnWizard, parent, store, returned_sale)
    elif sale.can_cancel():
        retval = cancel_sale(sale)
    else:
        retval = False

    return retval
开发者ID:Joaldino,项目名称:stoq,代码行数:25,代码来源:saleslave.py

示例2: return_sale

def return_sale(parent, sale, store):
    from stoqlib.gui.wizards.salereturnwizard import SaleReturnWizard

    cancel_last_coupon = sysparam.get_bool('ALLOW_CANCEL_LAST_COUPON')
    # A plugin (e.g. ECF) can avoid the cancelation of a sale
    # because it wants it to be cancelled using another way
    if cancel_last_coupon and SaleAvoidCancelEvent.emit(sale):
        return

    if sale.can_return():
        need_document = not sysparam.get_bool('ACCEPT_SALE_RETURN_WITHOUT_DOCUMENT')
        if need_document and not sale.get_client_document():
            warning(_('It is not possible to accept a returned sale from clients '
                      'without document. Please edit the client document or change '
                      'the sale client'))
            return

        returned_sale = sale.create_sale_return_adapter()
        retval = run_dialog(SaleReturnWizard, parent, store, returned_sale)
    elif sale.can_cancel():
        retval = cancel_sale(sale)
    else:
        retval = False

    return retval
开发者ID:Guillon88,项目名称:stoq,代码行数:25,代码来源:saleslave.py

示例3: _validate_percentage

    def _validate_percentage(self, value, type_text):
        if value >= 100:
            self.model.discount_percentage = 0
            return ValidationError(_(u'%s can not be greater or equal '
                                     'to 100%%.') % type_text)
        if value < 0:
            self.model.discount_percentage = 0
            return ValidationError(_("%s can not be less than 0")
                                   % type_text)

        if (not sysparam.get_bool('USE_TRADE_AS_DISCOUNT') and
            value > self.max_discount):
            self.model.discount_percentage = 0
            return ValidationError(_("%s can not be greater than %d%%")
                                   % (type_text, self.max_discount))

        discount = self.max_discount / 100 * self.original_sale_amount
        perc = discount * 100 / self.model.get_sale_subtotal()
        new_discount = quantize(self.original_discount + perc)
        #XXX: If the discount is less than the trade value. What to do?
        if (sysparam.get_bool('USE_TRADE_AS_DISCOUNT') and value > new_discount):
            self.model.discount_percentage = 0
            return ValidationError(_(u'%s can not be greater than (%.2f%%).')
                                   % (type_text, new_discount))

        old_discount = self.model.discount_value
        # Avoid unecessary updates if the discount didnt change
        if self.model.discount_value != old_discount:
            self.update_sale_discount()
开发者ID:Joaldino,项目名称:stoq,代码行数:29,代码来源:saleslave.py

示例4: update_discount_and_surcharge

 def update_discount_and_surcharge(self):
     marker("update_discount_and_surcharge")
     # Here we need avoid to reset sale data defined when creating the
     # Sale in the POS application, i.e, we should not reset the
     # discount and surcharge if they are already set (this is the
     # case when one of the parameters, CONFIRM_SALES_ON_TILL or
     # USE_TRADE_AS_DISCOUNT is enabled).
     if (not sysparam.get_bool('CONFIRM_SALES_ON_TILL') and
             not sysparam.get_bool('USE_TRADE_AS_DISCOUNT')):
         self.model.discount_value = currency(0)
         self.model.surcharge_value = currency(0)
开发者ID:Farrapo,项目名称:stoq,代码行数:11,代码来源:salewizard.py

示例5: setup_widgets

    def setup_widgets(self):
        marker('Setting up widgets')
        # Only quotes have expire date.
        self.expire_date.hide()
        self.expire_label.hide()

        # Hide client category widgets
        self.client_category_lbl.hide()
        self.client_category.hide()

        # if the NF-e plugin is active, the client is mandantory in this
        # wizard (in this situation, we have only quote sales).
        if self.model.status == Sale.STATUS_QUOTE:
            manager = get_plugin_manager()
            mandatory_client = manager.is_active('nfe')
            self.client.set_property('mandatory', mandatory_client)

        marker('Filling sales persons')
        salespersons = self.store.find(SalesPerson)
        self.salesperson.prefill(api.for_person_combo(salespersons))
        marker('Finished filling sales persons')

        marker('Read parameter')
        if not sysparam.get_bool('ACCEPT_CHANGE_SALESPERSON'):
            self.salesperson.set_sensitive(False)
        else:
            self.salesperson.grab_focus()
        marker('Finished reading parameter')
        self._fill_clients_combo()
        self._fill_transporter_combo()
        self._fill_cost_center_combo()

        if sysparam.get_bool('ASK_SALES_CFOP'):
            self._fill_cfop_combo()
        else:
            self.cfop_lbl.hide()
            self.cfop.hide()
            self.create_cfop.hide()

        # the maximum number allowed for an invoice is 999999999.
        self.invoice_number.set_adjustment(
            gtk.Adjustment(lower=1, upper=999999999, step_incr=1))

        if not self.model.invoice_number:
            new_invoice_number = Sale.get_last_invoice_number(self.store) + 1
            self.invoice_model.invoice_number = new_invoice_number
        else:
            new_invoice_number = self.model.invoice_number
            self.invoice_model.invoice_number = new_invoice_number
            self.invoice_number.set_sensitive(False)

        self.invoice_model.original_invoice = new_invoice_number
        marker('Finished setting up widgets')
开发者ID:igorferreira,项目名称:stoq,代码行数:53,代码来源:salewizard.py

示例6: on_close_date__validate

    def on_close_date__validate(self, widget, date):
        if sysparam.get_bool('ALLOW_OUTDATED_OPERATIONS'):
            return

        if date > localtoday().date() or date < self.model.open_date:
            return ValidationError(_("Paid date must be between "
                                     "%s and today") % (self.model.open_date, ))
开发者ID:Guillon88,项目名称:stoq,代码行数:7,代码来源:paymentconfirmslave.py

示例7: trade

    def trade(self):
        """Do a trade for this return

        Almost the same as :meth:`.return_`, but unlike it, this won't
        generate reversed payments to the client. Instead, it'll
        generate an inpayment using :obj:`.returned_total` value,
        so it can be used as an "already paid quantity" on :obj:`.new_sale`.
        """
        assert self.new_sale
        if self.sale:
            assert self.sale.can_return()
        self._clean_not_used_items()

        store = self.store
        group = self.group
        method = PaymentMethod.get_by_name(store, u'trade')
        description = _(u'Traded items for sale %s') % (
            self.new_sale.identifier, )
        value = self.returned_total

        self._return_items()

        value_as_discount = sysparam.get_bool('USE_TRADE_AS_DISCOUNT')
        if value_as_discount:
            self.new_sale.discount_value = self.returned_total
        else:
            payment = method.create_payment(Payment.TYPE_IN, group, self.branch, value,
                                            description=description)
            payment.set_pending()
            payment.pay()
            self._revert_fiscal_entry()

        if self.sale:
            self.sale.return_(self)
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:34,代码来源:returnedsale.py

示例8: _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

示例9: version

    def version(self, store, app_version):
        """Fetches the latest version
        :param store: a store
        :param app_version: application version
        :returns: a deferred with the version_string as a parameter
        """
        try:
            bdist_type = library.bdist_type
        except Exception:
            bdist_type = None

        if os.path.exists(os.path.join('etc', 'init.d', 'stoq-bootstrap')):
            source = 'livecd'
        elif bdist_type in ['egg', 'wheel']:
            source = 'pypi'
        elif is_developer_mode():
            source = 'devel'
        else:
            source = 'ppa'

        params = {
            'hash': sysparam.get_string('USER_HASH'),
            'demo': sysparam.get_bool('DEMO_MODE'),
            'dist': platform.dist(),
            'cnpj': get_main_cnpj(store),
            'plugins': InstalledPlugin.get_plugin_names(store),
            'product_key': get_product_key(),
            'time': datetime.datetime.today().isoformat(),
            'uname': platform.uname(),
            'version': app_version,
            'source': source,
        }
        params.update(self._get_company_details(store))
        params.update(self._get_usage_stats(store))
        return self._do_request('GET', 'version.json', **params)
开发者ID:adrianoaguiar,项目名称:stoq,代码行数:35,代码来源:webservice.py

示例10: checkout

    def checkout(self, cancel_clear=False):
        """Initiates the sale wizard to confirm sale.

        :param cancel_clear: If cancel_clear is true, the sale will be cancelled
          if the checkout is cancelled.
        """
        assert len(self.sale_items) >= 1

        if self._current_store:
            store = self._current_store
            savepoint = 'before_run_fiscalprinter_confirm'
            store.savepoint(savepoint)
        else:
            store = api.new_store()
            savepoint = None

        if self._trade:
            if self._get_subtotal() < self._trade.returned_total:
                info(_("Traded value is greater than the new sale's value. "
                       "Please add more items or return it in Sales app, "
                       "then make a new sale"))
                return

            sale = self._create_sale(store)
            self._trade.new_sale = sale
            self._trade.trade()
        else:
            sale = self._create_sale(store)

        if sysparam.get_bool('CONFIRM_SALES_ON_TILL'):
            sale.order()
            store.commit()
        else:
            assert self._coupon

            ordered = self._coupon.confirm(sale, store, savepoint,
                                           subtotal=self._get_subtotal())
            # Dont call store.confirm() here, since coupon.confirm()
            # above already did it
            if not ordered:
                # FIXME: Move to TEF plugin
                manager = get_plugin_manager()
                if manager.is_active('tef') or cancel_clear:
                    self._cancel_order(show_confirmation=False)
                elif not self._current_store:
                    # Just do that if a store was created above and
                    # if _cancel_order wasn't called (it closes the connection)
                    store.rollback(close=True)
                return

            log.info("Checking out")

        self._coupon = None
        POSConfirmSaleEvent.emit(sale, self.sale_items[:])

        # We must close the connection only after the event is emmited, since it
        # may use value from the sale that will become invalid after it is
        # closed
        store.close()
        self._clear_order()
开发者ID:reashninja,项目名称:stoq,代码行数:60,代码来源:pos.py

示例11: on_cost__validate

    def on_cost__validate(self, widget, value):
        sellable = self.proxy.model.sellable
        if not sellable:
            return

        # Dont allow numbers bigger than MAX_INT (see stoqlib.lib.defaults)
        if value > MAX_INT:
            return ValidationError(_("Price cannot be bigger than %s") % MAX_INT)

        if value <= 0:
            return ValidationError(_(u"Cost must be greater than zero."))

        if self.validate_price:
            category = getattr(self.model, "client_category", None)
            default_price = sellable.get_price_for_category(category)
            if not sysparam.get_bool("ALLOW_HIGHER_SALE_PRICE") and value > default_price:
                return ValidationError(_(u"The sell price cannot be greater " "than %s.") % default_price)

            manager = self.manager or api.get_current_user(self.store)
            client = getattr(self.model, "client", None)
            category = client and client.category
            extra_discount = self.get_extra_discount(sellable)
            valid_data = sellable.is_valid_price(value, category, manager, extra_discount=extra_discount)

            if not valid_data["is_valid"]:
                return ValidationError((_(u"Max discount for this product is %.2f%%.") % valid_data["max_discount"]))
开发者ID:amaurihamasu,项目名称:stoq,代码行数:26,代码来源:abstractwizard.py

示例12: on_price__validate

    def on_price__validate(self, widget, value):
        if value <= 0:
            return ValidationError(_(u"The price must be greater than zero."))

        if (not sysparam.get_bool('ALLOW_HIGHER_SALE_PRICE') and
            value > self.model.base_price):
            return ValidationError(_(u'The sell price cannot be greater '
                                   'than %s.') % self.model.base_price)

        sellable = self.model.sellable
        manager = self.manager or api.get_current_user(self.store)

        if api.sysparam.get_bool('REUTILIZE_DISCOUNT'):
            extra_discount = self.model.sale.get_available_discount_for_items(
                user=manager, exclude_item=self.model)
        else:
            extra_discount = None

        valid_data = sellable.is_valid_price(
            value, category=self.model.sale.client_category,
            user=manager, extra_discount=extra_discount)

        if not valid_data['is_valid']:
            return ValidationError(
                (_(u'Max discount for this product is %.2f%%.') %
                 valid_data['max_discount']))
开发者ID:pkaislan,项目名称:stoq,代码行数:26,代码来源:saleeditor.py

示例13: _add_pos_menus

    def _add_pos_menus(self, uimanager):
        if sysparam.get_bool('POS_SEPARATE_CASHIER'):
            return

        ui_string = """<ui>
          <menubar name="menubar">
            <placeholder name="ExtraMenubarPH">
              <menu action="ECFMenu">
                <menuitem action="CancelLastDocument"/>
                <menuitem action="Summary"/>
                <menuitem action="ReadMemory"/>
              </menu>
            </placeholder>
          </menubar>
        </ui>"""

        group = get_accels('plugin.ecf')

        ag = gtk.ActionGroup('ECFMenuActions')
        ag.add_actions([
            ('ECFMenu', None, _('ECF')),
            ('ReadMemory', None, _('Read Memory'),
             group.get('read_memory'), None, self._on_ReadMemory__activate),
            ('CancelLastDocument', None, _('Cancel Last Document'),
             None, None, self._on_CancelLastDocument__activate),
        ])
        ag.add_action_with_accel(self._till_summarize_action,
                                 group.get('summarize'))

        uimanager.insert_action_group(ag, 0)
        self._ui = uimanager.add_ui_from_string(ui_string)
开发者ID:pkaislan,项目名称:stoq,代码行数:31,代码来源:ecfui.py

示例14: on_open_date__validate

 def on_open_date__validate(self, widget, date):
     if sysparam.get_bool('ALLOW_OUTDATED_OPERATIONS'):
         return
     if date < localtoday().date():
         return ValidationError(
             _("Open date must be set to today or "
               "a future date"))
开发者ID:Guillon88,项目名称:stoq,代码行数:7,代码来源:purchasewizard.py

示例15: setup_slaves

    def setup_slaves(self):
        marker('Setting up slaves')
        BaseMethodSelectionStep.setup_slaves(self)
        marker('Finished parent')

        self.pm_slave.set_client(self.model.client,
                                 total_amount=self.wizard.get_total_to_pay())

        marker('Setting discount')
        self.discount_slave = SaleDiscountSlave(self.store, self.model,
                                                self.model_type)

        if sysparam.get_bool('USE_TRADE_AS_DISCOUNT'):
            self.subtotal_expander.set_expanded(True)
            self.discount_slave.discount_value_ck.set_active(True)
            self.discount_slave.update_sale_discount()
        marker('Finshed setting up discount')

        self.discount_slave.connect('discount-changed',
                                    self.on_discount_slave_changed)
        slave_holder = 'discount_surcharge_slave'
        if self.get_slave(slave_holder):
            self.detach_slave(slave_holder)
        self.attach_slave(slave_holder, self.discount_slave)
        marker('Finished setting up slaves')
开发者ID:Farrapo,项目名称:stoq,代码行数:25,代码来源:salewizard.py


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