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

Python api.get_current_user函数代码示例

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

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



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

示例1: get_columns

    def get_columns(self):
        columns = [SearchColumn('code', title=_(u'Code'), data_type=str),
                   SearchColumn('barcode', title=_('Barcode'), data_type=str,
                                sort_func=sort_sellable_code, width=80),
                   SearchColumn('category_description', title=_('Category'),
                                data_type=str, width=120),
                   SearchColumn('description', title=_('Description'),
                                data_type=str, expand=True, sorted=True),
                   SearchColumn('location', title=_('Location'),
                                data_type=str, visible=False),
                   SearchColumn('manufacturer', title=_('Manufacturer'),
                                data_type=str, visible=False),
                   SearchColumn('model', title=_('Model'),
                                data_type=str, visible=False)]

        user = api.get_current_user(self.store)
        if user.profile.check_app_permission('purchase'):
            columns.append(SearchColumn('cost',
                                        title=_(u'Cost'),
                                        data_type=currency, visible=True))

        if hasattr(self.search_spec, 'price'):
            columns.append(SearchColumn('price',
                                        title=_(u'Price'),
                                        data_type=currency, visible=True))

        if hasattr(self.search_spec, 'minimum_quantity'):
            columns.append(SearchColumn('minimum_quantity',
                                        title=_(u'Minimum Qty'),
                                        data_type=Decimal, visible=False))

        if hasattr(self.search_spec, 'stock'):
            columns.append(QuantityColumn('stock', title=_(u'In Stock')))

        return columns
开发者ID:hackedbellini,项目名称:stoq,代码行数:35,代码来源:sellablesearch.py


示例2: on_confirm

    def on_confirm(self):
        till = self.model.till
        removed = abs(self.model.value)
        if removed:
            # We need to do this inside a new transaction, because if the
            # till closing fails further on, this still needs to be recorded
            # in the database
            store = api.new_store()
            t_till = store.fetch(till)
            TillRemoveCashEvent.emit(till=t_till, value=removed)

            reason = _('Amount removed from Till by %s') % (
                api.get_current_user(self.store).get_description(), )
            till_entry = t_till.add_debit_entry(removed, reason)

            # Financial transaction
            _create_transaction(store, till_entry)
            # DB transaction
            store.confirm(True)
            store.close()

        if self._close_ecf:
            try:
                retval = TillCloseEvent.emit(till=till,
                                             previous_day=self._previous_day)
            except (TillError, DeviceError), e:
                warning(str(e))
                return None

            # If the event was captured and its return value is False, then we
            # should not close the till.
            if retval is False:
                return False
开发者ID:romaia,项目名称:stoq,代码行数:33,代码来源:tilleditor.py


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


示例4: _create_receiving_order

    def _create_receiving_order(self):
        supplier_id = self.purchases[0].supplier_id
        branch_id = self.purchases[0].branch_id

        # If the receiving is for another branch, we need a temporary identifier
        temporary_identifier = None
        if (api.sysparam.get_bool('SYNCHRONIZED_MODE') and
                api.get_current_branch(self.store).id != branch_id):
            temporary_identifier = ReceivingOrder.get_temporary_identifier(self.store)

        # We cannot create the model in the wizard since we haven't
        # selected a PurchaseOrder yet which ReceivingOrder depends on
        # Create the order here since this is the first place where we
        # actually have a purchase selected
        receiving_invoice = ReceivingInvoice(
            supplier=supplier_id, store=self.store, branch=branch_id,
            responsible=api.get_current_user(self.store))
        self.wizard.model = self.model = ReceivingOrder(
            identifier=temporary_identifier,
            receiving_invoice=receiving_invoice,
            responsible=receiving_invoice.responsible,
            invoice_number=None, branch=branch_id, store=self.store)

        for row in self.purchases:
            self.model.add_purchase(row.purchase)
开发者ID:hackedbellini,项目名称:stoq,代码行数:25,代码来源:receivingwizard.py


示例5: on_cost__validate

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

        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:pkaislan,项目名称:stoq,代码行数:27,代码来源:abstractwizard.py


示例6: create_model

 def create_model(self, store):
     return Calls(date=datetime.date.today(),
                  description=u'',
                  message=u'',
                  person=self.person,
                  attendant=api.get_current_user(self.store),
                  store=store)
开发者ID:romaia,项目名称:stoq,代码行数:7,代码来源:callseditor.py


示例7: test_create

    def test_create(self, set_message):
        sellable = self.create_sellable()
        self.create_storable(product=sellable.product)
        sale_item = TemporarySaleItem(sellable=sellable, quantity=1)

        user = api.get_current_user(self.store)
        with mock.patch.object(user.profile, 'check_app_permission') as has_acess:
            has_acess.side_effect = [False]
            search = SaleSellableSearch(self.store,
                                        sale_items=[sale_item], quantity=1)

            self.assertRaises(TypeError, SaleSellableSearch, self.store,
                              sale_items=[sale_item],
                              selection_mode=Gtk.SelectionMode.MULTIPLE)
            self.assertRaises(TypeError, SaleSellableSearch, self.store,
                              sale_items=[sale_item], quantity=None)

            search = SaleSellableSearch(self.store)
            search.search.refresh()
            self.check_search(search, 'sale-sellable-no-filter')

            search = SaleSellableSearch(self.store, info_message='test')
            set_message.assert_called_once_with('test')

            search = SaleSellableSearch(self.store, search_str='cal')
            self.check_search(search, 'sale-sellable-string-filter')
开发者ID:hackedbellini,项目名称:stoq,代码行数:26,代码来源:test_sellablesearch.py


示例8: test_show

    def test_show(self):
        workorder = self.create_workorder(description=u'Test equipment')
        workorder.client = self.create_client()
        workorder.client.category = self.create_client_category()

        product = self.create_product(stock=10)
        sellable = product.sellable
        storable = product.storable

        item = workorder.add_sellable(sellable)
        editor = _WorkOrderItemEditor(self.store, model=item)
        self.check_editor(editor, 'editor-workorderitem-show')

        self.assertValid(editor, ['price'])
        editor.price.update(0)
        self.assertInvalid(editor, ['price'])
        editor.price.update(-1)
        self.assertInvalid(editor, ['price'])
        with mock.patch.object(sellable, 'is_valid_price') as ivp:
            ivp.return_value = {
                'is_valid': False,
                'min_price': decimal.Decimal('10.00'),
                'max_discount': decimal.Decimal('0.00'),
            }
            editor.price.update(1)
            ivp.assert_called_once_with(1, workorder.client.category,
                                        api.get_current_user(self.store))
            self.assertInvalid(editor, ['price'])

        self.assertValid(editor, ['quantity'])
        with mock.patch.object(storable, 'get_balance_for_branch') as gbfb:
            gbfb.return_value = 0
            editor.quantity.update(20)
            gbfb.assert_called_once_with(workorder.branch)
            self.assertInvalid(editor, ['quantity'])
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:35,代码来源:test_workorderslave.py


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


示例10: fields

    def fields(self):
        # Only users with admin or purchase permission can modify transporters
        user = api.get_current_user(self.store)
        can_modify_transporter = any((
            user.profile.check_app_permission(u'admin'),
            user.profile.check_app_permission(u'purchase'),
        ))
        freight_types = [(v, k) for k, v in Delivery.freights.items()]
        states = [(v, v) for v in api.get_l10n_field('state').state_list]

        return collections.OrderedDict(
            recipient=PersonQueryField(_("Recipient"), proxy=True, mandatory=True,
                                       person_type=self.person_type),
            transporter_id=PersonField(_("Transporter"), proxy=True,
                                       person_type=Transporter,
                                       can_add=can_modify_transporter,
                                       can_edit=can_modify_transporter),
            address=AddressField(_("Address"), proxy=True, mandatory=True),
            freight_type=ChoiceField(_("Freight type"), proxy=True,
                                     values=freight_types),
            price=PriceField(_("Delivery cost"), proxy=True),
            estimated_fix_date=DateField(_("Estimated delivery date"), proxy=True),
            volumes_kind=TextField(_("Volumes kind"), proxy=True),
            volumes_quantity=IntegerField(_("Volumes quantity"), proxy=True),
            volumes_net_weight=NumericField(_("Volumes net weight"), proxy=True,
                                            digits=3),
            volumes_gross_weight=NumericField(_("Volumes gross weight"),
                                              proxy=True, digits=3),
            vehicle_license_plate=TextField(_("Vehicle license plate"), proxy=True),
            vehicle_state=ChoiceField(_("Vehicle state"), proxy=True, use_entry=True,
                                      values=states),
            vehicle_registration=TextField(_("Vehicle registration"), proxy=True),
        )
开发者ID:hackedbellini,项目名称:stoq,代码行数:33,代码来源:deliveryeditor.py


示例11: test_price_validation

    def test_price_validation(self):
        user = api.get_current_user(self.store)
        user.profile.max_discount = 2
        editor = self._create_editor()

        with self.sysparam(ALLOW_HIGHER_SALE_PRICE=True):
            editor.price.update(101)
            self.assertValid(editor, ['price'])
            editor.price.update(98)
            self.assertValid(editor, ['price'])
            editor.price.update(97)
            self.assertInvalid(editor, ['price'])
            editor.price.update(-1)
            self.assertInvalid(editor, ['price'])

        with self.sysparam(ALLOW_HIGHER_SALE_PRICE=False):
            editor.price.update(101)
            self.assertInvalid(editor, ['price'])
            editor.price.update(98)
            self.assertValid(editor, ['price'])
            editor.price.update(97)
            self.assertInvalid(editor, ['price'])
            editor.price.update(-1)
            self.assertInvalid(editor, ['price'])

        with self.sysparam(REUTILIZE_DISCOUNT=True):
            editor.price.update(10)
            self.assertInvalid(editor, ['price'])

        with self.sysparam(REUTILIZE_DISCOUNT=False):
            editor.price.update(10)
            self.assertInvalid(editor, ['price'])
开发者ID:reashninja,项目名称:stoq,代码行数:32,代码来源:test_optical_wizard.py


示例12: _create_receiving_order

    def _create_receiving_order(self):
        # since we will create a new receiving order, we should confirm the
        # purchase first. Note that the purchase may already be confirmed
        if self.model.status in [PurchaseOrder.ORDER_PENDING,
                                 PurchaseOrder.ORDER_CONSIGNED]:
            self.model.confirm()

        temporary_identifier = None
        if self.wizard.is_for_another_branch():
            temporary_identifier = ReceivingOrder.get_temporary_identifier(self.store)

        receiving_invoice = ReceivingInvoice(
            store=self.store,
            supplier=self.model.supplier,
            branch=self.model.branch,
            responsible=api.get_current_user(self.store))
        receiving_model = ReceivingOrder(
            identifier=temporary_identifier,
            receiving_invoice=receiving_invoice,
            responsible=receiving_invoice.responsible,
            branch=self.model.branch,
            invoice_number=None,
            store=self.store)
        receiving_model.add_purchase(self.model)

        # Creates ReceivingOrderItem's
        for item in self.model.get_pending_items():
            receiving_model.add_purchase_item(item)

        self.wizard.receiving_model = receiving_model
开发者ID:hackedbellini,项目名称:stoq,代码行数:30,代码来源:purchasewizard.py


示例13: search_products

 def search_products(self):
     with api.new_store() as store:
         profile = api.get_current_user(store).profile
         can_create = (profile.check_app_permission('admin') or
                       profile.check_app_permission('purchase'))
         run_dialog(ProductSearch, None, store, hide_footer=True, hide_toolbar=not can_create,
                    hide_cost_column=not can_create)
开发者ID:hackedbellini,项目名称:stoq,代码行数:7,代码来源:widgets.py


示例14: on_SalesCancel__activate

    def on_SalesCancel__activate(self, action):
        sale_view = self.results.get_selected()
        can_cancel = api.sysparam.get_bool('ALLOW_CANCEL_LAST_COUPON')
        if can_cancel and ECFIsLastSaleEvent.emit(sale_view.sale):
            info(_("That is last sale in ECF. Return using the menu "
                   "ECF - Cancel Last Document"))
            return

        store = api.new_store()
        sale = store.fetch(sale_view.sale)
        msg_text = _(u"This will cancel the sale, Are you sure?")
        model = SaleComment(store=store, sale=sale,
                            author=api.get_current_user(store))

        retval = self.run_dialog(
            NoteEditor, store, model=model, attr_name='comment',
            message_text=msg_text, label_text=_(u"Reason"),
            mandatory=True, ok_button_label=_(u"Cancel sale"),
            cancel_button_label=_(u"Don't cancel"))

        if not retval:
            store.rollback()
            return

        sale.cancel()
        store.commit(close=True)
        self.refresh()
开发者ID:dionimf,项目名称:stoq,代码行数:27,代码来源:sales.py


示例15: create_actions

    def create_actions(self):
        group = get_accels('app.financial')
        actions = [
            ('Import', Gtk.STOCK_ADD, _('Import...'),
             group.get('import'), _('Import a GnuCash or OFX file')),
            ('ConfigurePaymentMethods', None,
             _('Payment methods'),
             group.get('configure_payment_methods'),
             _('Select accounts for the payment methods on the system')),
            ('Delete', None, _('Delete...')),
            ("NewAccount", Gtk.STOCK_NEW, _("Account..."),
             group.get('new_account'),
             _("Add a new account")),
            ("NewTransaction", Gtk.STOCK_NEW, _("Transaction..."),
             group.get('new_store'),
             _("Add a new transaction")),
            ("Edit", Gtk.STOCK_EDIT, _("Edit..."),
             group.get('edit')),
        ]
        self.financial_ui = self.add_ui_actions(actions)
        self.set_help_section(_("Financial help"), 'app-financial')

        user = api.get_current_user(self.store)
        if not user.profile.check_app_permission(u'admin'):
            self.set_sensitive([self.ConfigurePaymentMethods], False)
开发者ID:hackedbellini,项目名称:stoq,代码行数:25,代码来源:financial.py


示例16: on_SalesCancel__activate

    def on_SalesCancel__activate(self, action):
        sale_view = self.results.get_selected()
        can_cancel = api.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 can_cancel and SaleAvoidCancelEvent.emit(sale_view.sale):
            return

        store = api.new_store()
        sale = store.fetch(sale_view.sale)
        msg_text = _(u"This will cancel the sale, Are you sure?")
        model = SaleComment(store=store, sale=sale,
                            author=api.get_current_user(store))

        retval = self.run_dialog(
            NoteEditor, store, model=model, attr_name='comment',
            message_text=msg_text, label_text=_(u"Reason"),
            mandatory=True, ok_button_label=_(u"Cancel sale"),
            cancel_button_label=_(u"Don't cancel"))

        if not retval:
            store.rollback()
            return

        sale.cancel()
        store.commit(close=True)
        self.refresh()
开发者ID:Guillon88,项目名称:stoq,代码行数:27,代码来源:sales.py


示例17: _check_client_birthdays

    def _check_client_birthdays(self):
        if not api.sysparam.get_bool('BIRTHDAY_NOTIFICATION'):
            return

        # Display the info bar once per day
        date = api.user_settings.get('last-birthday-check')
        last_check = date and datetime.datetime.strptime(date, '%Y-%m-%d').date()
        if last_check and last_check >= datetime.date.today():
            return

        # Only display the infobar if the user has access to calendar (because
        # clicking on the button will open it) and to sales (because it
        # requires that permission to be able to check client details)
        user = api.get_current_user(self.store)
        if not all([user.profile.check_app_permission(u'calendar'),
                    user.profile.check_app_permission(u'sales')]):
            return

        branch = api.get_current_branch(self.store)
        clients_count = ClientWithSalesView.find_by_birth_date(
            self.store, datetime.datetime.today(), branch=branch).count()

        if clients_count:
            msg = stoqlib_ngettext(
                _("There is %s client doing birthday today!"),
                _("There are %s clients doing birthday today!"),
                clients_count) % (clients_count, )
            button = gtk.Button(_("Check the calendar"))
            button.connect('clicked', self._on_check_calendar__clicked)

            self._birthdays_bar = self.add_info_bar(
                gtk.MESSAGE_INFO,
                "<b>%s</b>" % (glib.markup_escape_text(msg), ),
                action_widget=button)
开发者ID:adrianoaguiar,项目名称:stoq,代码行数:34,代码来源:shellwindow.py


示例18: finish

    def finish(self):
        for payment in self.model.group.payments:
            if payment.is_preview():
                # Set payments created on SaleReturnPaymentStep as pending
                payment.set_pending()

        total_amount = self.model.total_amount
        # If the user chose to create credit for the client instead of returning
        # money, there is no need to display this messages.
        if not self.credit:
            if total_amount == 0:
                info(_("The client does not have a debt to this sale anymore. "
                       "Any existing unpaid installment will be cancelled."))
            elif total_amount < 0:
                info(_("A reversal payment to the client will be created. "
                       "You can see it on the Payable Application."))

        login_user = api.get_current_user(self.store)
        self.model.return_(method_name=u'credit' if self.credit else u'money',
                           login_user=login_user)
        SaleReturnWizardFinishEvent.emit(self.model)
        self.retval = self.model
        self.close()

        # Commit before printing to avoid losing data if something breaks
        self.store.confirm(self.retval)
        if self.credit:
            if yesno(_(u'Would you like to print the credit letter?'),
                     gtk.RESPONSE_YES, _(u"Print Letter"), _(u"Don't print")):
                print_report(ClientCreditReport, self.model.client)
开发者ID:adrianoaguiar,项目名称:stoq,代码行数:30,代码来源:salereturnwizard.py


示例19: __init__

    def __init__(self, resource, manager, compact=False):
        self._resource = resource
        self._compact = compact
        self._manager = manager
        user = api.get_current_user(api.get_default_store())
        self._is_admin = user.profile.check_app_permission(u'admin')

        super(ResourceStatusBox, self).__init__(spacing=6)
        if compact:
            self.props.margin = 6
        else:
            self.props.margin = 12

        self.img = Gtk.Image()
        self.pack_start(self.img, False, True, 0)
        self.lbl = Gtk.Label()
        self.lbl.set_xalign(0)
        self.lbl.set_line_wrap(True)
        self.pack_start(self.lbl, False, True, 0)

        self.buttonbox = Gtk.Box()
        self.buttonbox.set_valign(Gtk.Align.CENTER)
        self.buttonbox.get_style_context().add_class('linked')
        if not compact:
            self.pack_end(self.buttonbox, False, True, 0)
开发者ID:hackedbellini,项目名称:stoq,代码行数:25,代码来源:statusbar.py


示例20: create_model

 def create_model(self, store):
     # TODO: Add a parameter for getting a default destination branch
     return WorkOrderPackage(
         store=store,
         identifier=u"",
         send_responsible=api.get_current_user(store),
         source_branch=api.get_current_branch(store),
     )
开发者ID:pkaislan,项目名称:stoq,代码行数:8,代码来源:workordereditor.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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