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

Python runtime.get_current_user函数代码示例

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

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



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

示例1: test_run_dialog

    def test_run_dialog(self):
        observations = (
            u"Mussum ipsum cacilds, vidis litro abertis. "
            "Consetis adipiscings elitis. Pra la , depois "
            "divoltis porris, paradis. Paisis, filhis, "
            "espiritis santis. Me faiz elementum girarzis, "
            "nisi eros vermeio, in elementis me pra quem e "
            "amistosis quis leo. Manduma pindureta quium dia "
            "nois paga. Sapien in monti palavris qui num "
            "significa nadis i pareci latim. Interessantiss "
            "quisso pudia ce receita de bolis, mais bolis eu num gostis.")
        till = self.create_till()
        till.open_till()
        till.close_till(observations)

        model = self.store.find(TillClosedView, id=till.id).one()
        self.assertEquals(observations, model.observations)
        self.assertEquals(get_current_user(self.store).get_description(),
                          model.responsible_open_name)
        self.assertEquals(get_current_user(self.store).get_description(),
                          model.responsible_close_name)
        self.assertEquals(observations, model.observations)

        dialog = TillClosedSearch(self.store)
        dialog.search.refresh()
        self.assertNotSensitive(dialog._details_slave, ['details_button'])
        with mock.patch("stoqlib.gui.search.tillsearch.run_dialog") as r_dialog:
            dialog.results.select(model)
            self.assertSensitive(dialog._details_slave, ['details_button'])
            self.click(dialog._details_slave.details_button)
            r_dialog.assert_called_once_with(TillDetailsDialog, dialog,
                                             dialog.store, model)
开发者ID:Guillon88,项目名称:stoq,代码行数:32,代码来源:test_tillsearch.py


示例2: test_on_confirm_with_discount

    def test_on_confirm_with_discount(self):
        events_before = self.store.find(Event).count()

        sale_item = self.create_sale_item()
        sale_item.sale.identifier = 333123

        current_user = get_current_user(self.store)
        current_user.profile.max_discount = Decimal('5')

        # A manager to authorize the discount
        manager = self.create_user()
        manager.profile.max_discount = Decimal('10')

        editor = SaleQuoteItemEditor(self.store, sale_item)

        # Try applying 9% of discount
        editor.price.update(currency('9.10'))

        # The user is not allowed to give 10% discount
        self.assertNotSensitive(editor.main_dialog, ['ok_button'])

        # Lets call the manager and ask for permission
        with mock.patch('stoqlib.gui.editors.saleeditor.run_dialog') as rd:
            rd.return_value = manager
            editor.price.emit('icon-press', gtk.ENTRY_ICON_PRIMARY, None)

        # Now it should be possible to confirm
        self.click(editor.main_dialog.ok_button)
        events_after = self.store.find(Event).count()
        self.assertEquals(events_after, events_before + 1)

        last_event = self.store.find(Event).order_by(Event.id).last()
        expected = (u'Sale 333123: User username authorized 9.00 % '
                    u'of discount changing\n Description value from $10.00 to $9.10.')
        self.assertEquals(last_event.description, expected)
开发者ID:Joaldino,项目名称:stoq,代码行数:35,代码来源:test_salequoteitemeditor.py


示例3: _update_te

    def _update_te(self):
        user = get_current_user(self.store)
        station = get_current_station(self.store)

        self.te_modified.te_time = TransactionTimestamp()
        self.te_modified.user_id = user and user.id
        self.te_modified.station_id = station and station.id
开发者ID:amaurihamasu,项目名称:stoq,代码行数:7,代码来源:domainv1.py


示例4: create_for_receiving_order

    def create_for_receiving_order(cls, receiving_order):
        store = receiving_order.store
        current_user = get_current_user(store)
        employee = current_user.person.employee
        cfop_id = sysparam.get_object_id('DEFAULT_STOCK_DECREASE_CFOP')
        return_stock_decrease = cls(
            store=store,
            receiving_order=receiving_order,
            branch=get_current_branch(store),
            responsible=current_user,
            removed_by=employee,
            cfop_id=cfop_id)

        for receiving_item in receiving_order.get_items(with_children=False):
            if receiving_item.is_totally_returned():
                # Exclude items already totally returned
                continue

            if receiving_item.children_items.count():
                for child in receiving_item.children_items:
                    StockDecreaseItem.create_for_receiving_item(
                        return_stock_decrease, child)
            else:
                StockDecreaseItem.create_for_receiving_item(return_stock_decrease,
                                                            receiving_item)
        return return_stock_decrease
开发者ID:hackedbellini,项目名称:stoq,代码行数:26,代码来源:stockdecrease.py


示例5: confirm

    def confirm(self, confirm_date=None):
        """Confirms the purchase order

        :param confirm_data: optional, datetime
        """
        if confirm_date is None:
            confirm_date = TransactionTimestamp()

        if self.status not in [PurchaseOrder.ORDER_PENDING,
                               PurchaseOrder.ORDER_CONSIGNED]:
            raise ValueError(
                _(u'Invalid order status, it should be '
                  u'ORDER_PENDING or ORDER_CONSIGNED, got %s') % (
                      self.get_status_str(), ))

        transaction = IPaymentTransaction(self)
        transaction.confirm()

        if self.supplier:
            self.group.recipient = self.supplier.person

        self.responsible = get_current_user(self.store)
        self.status = PurchaseOrder.ORDER_CONFIRMED
        self.confirm_date = confirm_date

        Event.log(self.store, Event.TYPE_ORDER,
                  _(u"Order %s, total value %2.2f, supplier '%s' "
                    u"is now confirmed") % (self.identifier,
                                            self.get_purchase_total(),
                                            self.supplier.person.name))
开发者ID:leandrorchaves,项目名称:stoq,代码行数:30,代码来源:purchase.py


示例6: orm_get_unittest_value

def orm_get_unittest_value(klass, test, tables_dict, name, column):
    value = None
    if isinstance(column, PropertyColumn):
        if column.variable_factory.keywords['value'] is not Undef:
            value = column.variable_factory.keywords['value']
        else:
            try:
                value = orm_get_random(column)
            except ValueError:
                raise ORMTestError(u"No default for %r" % (column, ))

    elif isinstance(column, Reference):
        if name == 'te':
            return None
        if isinstance(column._remote_key, basestring):
            cls = tables_dict[column._remote_key.split('.')[0]]
        else:
            cls = column._remote_key[0].cls
        if cls.__name__ == 'LoginUser':
            # Avoid unique problems on domains that defines 2 references
            # to LoginUser (e.g. WorkOrder)
            from stoqlib.database.runtime import get_current_user
            value = get_current_user(test.store)
        elif cls.__name__ == 'StorableBatch':
            # StorableBatch needs some very specific information, that is
            # related to other objects. Thus, it cannot be created with random
            # value.
            value = None
        else:
            value = test.create_by_type(cls)
        if value is None:
            raise ORMTestError(u"No example for %s" % cls)
    return value
开发者ID:rosalin,项目名称:stoq,代码行数:33,代码来源:test_domain.py


示例7: open_till

    def open_till(self):
        """Open the till.

        It can only be done once per day.
        The final cash amount of the previous till will be used
        as the initial value in this one after opening it.
        """
        if self.status == Till.STATUS_OPEN:
            raise TillError(_('Till is already open'))

        # Make sure that the till has not been opened today
        today = localtoday().date()
        if not self.store.find(Till,
                               And(Date(Till.opening_date) >= today,
                                   Till.station_id == self.station.id)).is_empty():
            raise TillError(_("A till has already been opened today"))

        last_till = self._get_last_closed_till()
        if last_till:
            if not last_till.closing_date:
                raise TillError(_("Previous till was not closed"))

            initial_cash_amount = last_till.final_cash_amount
        else:
            initial_cash_amount = 0

        self.initial_cash_amount = initial_cash_amount

        self.opening_date = TransactionTimestamp()
        self.status = Till.STATUS_OPEN
        self.responsible_open = get_current_user(self.store)
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:31,代码来源:till.py


示例8: _update_wizard_model

    def _update_wizard_model(self):
        wizard_model = self.wizard.model
        if wizard_model:
            # We are replacing the model. Remove old one
            for item in wizard_model.returned_items:
                item.delete(item.id, store=item.store)
            wizard_model.delete(wizard_model.id,
                                store=wizard_model.store)

        sale_view = self.slave.results.get_selected()
        # FIXME: Selecting a sale and then clicking on unknown_sale_check
        # will not really deselect it, not until the results are sensitive
        # again. This should be as simple as 'if sale_view'.
        if sale_view and not self.unknown_sale_check.get_active():
            sale = self.store.fetch(sale_view.sale)
            model = sale.create_sale_return_adapter()
            for item in model.returned_items:
                _adjust_returned_sale_item(item)
        else:
            assert self._allow_unknown_sales()
            model = ReturnedSale(
                store=self.store,
                responsible=get_current_user(self.store),
                branch=get_current_branch(self.store),
            )

        self.wizard.model = model
开发者ID:LeonamSilva,项目名称:stoq,代码行数:27,代码来源:salereturnwizard.py


示例9: confirm

    def confirm(self, confirm_date=None):
        """Confirms the purchase order

        :param confirm_data: optional, datetime
        """
        if confirm_date is None:
            confirm_date = TransactionTimestamp()

        if self.status not in [PurchaseOrder.ORDER_PENDING,
                               PurchaseOrder.ORDER_CONSIGNED]:
            fmt = _(u'Invalid order status, it should be '
                    u'ORDER_PENDING or ORDER_CONSIGNED, got %s')
            raise ValueError(fmt % (self.status_str, ))

        # In consigned purchases there is no payments at this point.
        if self.status != PurchaseOrder.ORDER_CONSIGNED:
            for payment in self.payments:
                payment.set_pending()

        if self.supplier:
            self.group.recipient = self.supplier.person

        self.responsible = get_current_user(self.store)
        self.status = PurchaseOrder.ORDER_CONFIRMED
        self.confirm_date = confirm_date

        Event.log(self.store, Event.TYPE_ORDER,
                  _(u"Order %s, total value %2.2f, supplier '%s' "
                    u"is now confirmed") % (self.identifier,
                                            self.purchase_total,
                                            self.supplier.person.name))
开发者ID:Guillon88,项目名称:stoq,代码行数:31,代码来源:purchase.py


示例10: test_on_confirm_without_discount

    def test_on_confirm_without_discount(self):
        events_before = self.store.find(Event).count()

        sale_item = self.create_sale_item()

        current_user = get_current_user(self.store)
        current_user.profile.max_discount = Decimal('5')

        # A manager to authorize the discount
        manager = self.create_user()
        manager.profile.max_discount = Decimal('10')

        editor = SaleQuoteItemEditor(self.store, sale_item)
        # Try applying 10% of discount
        editor.price.update(currency('9.00'))

        # The user is not allowed to give 10% discount
        self.assertNotSensitive(editor.main_dialog, ['ok_button'])

        # Lets call the manager and ask for permission
        with mock.patch('stoqlib.gui.editors.saleeditor.run_dialog') as rd:
            rd.return_value = manager
            editor.price.emit('icon-press', gtk.ENTRY_ICON_PRIMARY, None)

        # Forget about the discount
        editor.price.update(currency('10'))

        # This will not trigger an event
        self.click(editor.main_dialog.ok_button)
        events_after = self.store.find(Event).count()
        # The number of events doesn't changed
        self.assertEquals(events_after, events_before)
开发者ID:Joaldino,项目名称:stoq,代码行数:32,代码来源:test_salequoteitemeditor.py


示例11: _update_te

    def _update_te(self):
        user = get_current_user(self.store)
        station = get_current_station(self.store)

        self.te.dirty = True
        self.te.te_time = StatementTimestamp()
        self.te.user_id = user and user.id
        self.te.station_id = station and station.id
开发者ID:Guillon88,项目名称:stoq,代码行数:8,代码来源:domainv2.py


示例12: set_consigned

    def set_consigned(self):
        if self.status != PurchaseOrder.ORDER_PENDING:
            raise ValueError(
                _(u'Invalid order status, it should be '
                  u'ORDER_PENDING, got %s') % (self.status_str, ))

        self.responsible = get_current_user(self.store)
        self.status = PurchaseOrder.ORDER_CONSIGNED
开发者ID:Guillon88,项目名称:stoq,代码行数:8,代码来源:purchase.py


示例13: _logout

 def _logout(self):
     from stoqlib.database.runtime import (get_current_user,
                                           get_default_store)
     log.debug('Logging out the current user')
     try:
         user = get_current_user(get_default_store())
         if user:
             user.logout()
     except StoqlibError:
         pass
开发者ID:hackedbellini,项目名称:stoq,代码行数:10,代码来源:shell.py


示例14: apply

    def apply(self):
        if self.test_type == ProductQualityTest.TYPE_BOOLEAN:
            value = self.model.boolean_value
        else:
            value = self.model.decimal_value

        for item in self._items:
            result = item.set_test_result_value(self.model.quality_test, value,
                                                get_current_user(self.store))
            self.emit('test-updated', item, self.model.quality_test, result)
开发者ID:marianaanselmo,项目名称:stoq,代码行数:10,代码来源:productionslave.py


示例15: test_set_consigned

 def test_set_consigned(self):
     order = self.create_purchase_order()
     order.status = PurchaseOrder.ORDER_PENDING
     order.set_consigned()
     current = get_current_user(store=self.store)
     self.assertEquals(current, order.responsible)
     self.assertEquals(order.status, order.ORDER_CONSIGNED)
     order.status = PurchaseOrder.ORDER_CONFIRMED
     with self.assertRaises(ValueError):
         order.set_consigned()
开发者ID:pkaislan,项目名称:stoq,代码行数:10,代码来源:test_purchase.py


示例16: decrease_stock

    def decrease_stock(self, quantity, branch, type, object_id,
                       cost_center=None):
        """When receiving a product, update the stock reference for the sold item
        this on a specific |branch|. Returns the stock item that was
        decreased.

        :param quantity: amount to decrease
        :param branch: a |branch|
        :param type: the type of the stock increase. One of the
            StockTransactionHistory.types
        :param object_id: the id of the object responsible for the transaction
        :param cost_center: the |costcenter| to which this stock decrease is
            related, if any
        """
        # FIXME: Put this back once 1.6 is released
        #assert isinstance(type, int)

        if quantity <= 0:
            raise ValueError(_(u"quantity must be a positive number"))
        if branch is None:
            raise ValueError(u"branch cannot be None")

        stock_item = self.get_stock_item(branch)
        if stock_item is None or quantity > stock_item.quantity:
            raise StockError(
                _('Quantity to sell is greater than the available stock.'))

        old_quantity = stock_item.quantity
        stock_item.quantity -= quantity

        # We emptied the entire stock in all branches, we need to change
        # the status of the sellable to unavailable as we cannot sell
        # it anymore
        if not self.store.find(ProductStockItem,
                    storable=self).sum(ProductStockItem.quantity):
            sellable = self.product.sellable
            if sellable:
                sellable.set_unavailable()

        stock_transaction = StockTransactionHistory(
                                product_stock_item=stock_item,
                                quantity=-quantity,
                                stock_cost=stock_item.stock_cost,
                                responsible=get_current_user(self.store),
                                type=type,
                                object_id=object_id,
                                store=self.store)

        if cost_center is not None:
            cost_center.add_stock_transaction(stock_transaction)

        ProductStockUpdateEvent.emit(self.product, branch, old_quantity,
                                     stock_item.quantity)

        return stock_item
开发者ID:romaia,项目名称:stoq,代码行数:55,代码来源:product.py


示例17: _on_object_added

    def _on_object_added(self, obj_info):
        store = obj_info.get("store")
        store.block_implicit_flushes()
        user = get_current_user(store)
        station = get_current_station(store)
        store.unblock_implicit_flushes()

        self.te = TransactionEntry(store=store,
                                   te_time=StatementTimestamp(),
                                   user_id=user and user.id,
                                   station_id=station and station.id)
开发者ID:Guillon88,项目名称:stoq,代码行数:11,代码来源:domainv3.py


示例18: increase_stock

    def increase_stock(self, quantity, branch, type, object_id, unit_cost=None):
        """When receiving a product, update the stock reference for this new
        item on a specific |branch|.

        :param quantity: amount to increase
        :param branch: |branch| that stores the stock
        :param type: the type of the stock increase. One of the
            StockTransactionHistory.types
        :param object_id: the id of the object responsible for the transaction
        :param unit_cost: unit cost of the new stock or `None`
        """
        assert isinstance(type, int)

        if quantity <= 0:
            raise ValueError(_(u"quantity must be a positive number"))
        if branch is None:
            raise ValueError(u"branch cannot be None")
        stock_item = self.get_stock_item(branch)
        # If the stock_item is missing create a new one
        if stock_item is None:
            store = self.store
            stock_item = ProductStockItem(
                storable=self,
                branch=store.fetch(branch),
                store=store)

        # Unit cost must be updated here as
        # 1) we need the stock item which might not exist
        # 2) it needs to be updated before we change the quantity of the
        #    stock item
        if unit_cost is not None:
            stock_item.update_cost(quantity, unit_cost)

        old_quantity = stock_item.quantity
        stock_item.quantity += quantity

        # If previously lacked quantity change the status of the sellable
        if not old_quantity:
            sellable = self.product.sellable
            if sellable:
                sellable.can_sell()

        StockTransactionHistory(product_stock_item=stock_item,
                                quantity=quantity,
                                stock_cost=stock_item.stock_cost,
                                responsible=get_current_user(self.store),
                                type=type,
                                object_id=object_id,
                                store=self.store)

        ProductStockUpdateEvent.emit(self.product, branch, old_quantity,
                                     stock_item.quantity)
开发者ID:romaia,项目名称:stoq,代码行数:52,代码来源:product.py


示例19: create_stock_transaction_history

 def create_stock_transaction_history(self, product_stock_item=None,
                                    stock_cost=0,
                                    quantity=0,
                                    type=StockTransactionHistory.TYPE_SELL):
     from stoqlib.domain.product import StockTransactionHistory
     if product_stock_item is None:
         product_stock_item = self.create_product_stock_item()
     return StockTransactionHistory(product_stock_item=product_stock_item,
                             responsible=get_current_user(store=self.store),
                             stock_cost=stock_cost,
                             quantity=quantity,
                             type=type,
                             store=self.store)
开发者ID:romaia,项目名称:stoq,代码行数:13,代码来源:exampledata.py


示例20: test_branch_combo_items

 def test_branch_combo_items(self):
     branch = get_current_branch(self.store)
     user = get_current_user(self.store)
     product = self.create_product(with_supplier=True)
     supplier_info = product.get_main_supplier_info()
     with mock.patch.object(user.profile, 'check_app_permission') as is_admin:
         # Admin user can set the supplier for any branch
         is_admin.side_effect = [True, False]
         editor = ProductSupplierEditor(self.store, supplier_info)
         self.assertEqual(len(editor.branch_combo.get_model_items()), 2)
         # Regular user can only set to the current branch
         editor = ProductSupplierEditor(self.store, supplier_info)
         items = list(editor.branch_combo.get_model_items().values())
         self.assertEqual(len(items), 1)
         self.assertEqual(items[0], branch)
开发者ID:hackedbellini,项目名称:stoq,代码行数:15,代码来源:test_productsuppliereditor.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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