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


Python inventory.Inventory类代码示例

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


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

示例1: _update_view

    def _update_view(self):
        self.proxy.update("status_str")

        has_open_inventory = bool(Inventory.has_open(self.store, api.get_current_branch(self.store)))

        tab = self._get_tab("execution_holder")
        # If it's not opened, it's at least approved.
        # So, we can enable the execution slave
        tab.set_sensitive(
            self.model.status == WorkOrder.STATUS_WORK_IN_PROGRESS and not has_open_inventory and not self.visual_mode
        )

        has_items = bool(self.model.order_items.count())
        if self.model.can_approve():
            label = _("Approve")
        elif self.model.can_work() and not has_items:
            label = _("Start")
        elif self.model.can_work():
            label = _("Continue")
        elif self.model.can_pause():
            label = _("Pause")
        else:
            label = ""
        self.toggle_status_btn.set_label(label)
        self.toggle_status_btn.set_sensitive(not self.visual_mode and self.model.client is not None)
        self.toggle_status_btn.set_visible(bool(label))

        stock_id, tooltip = get_workorder_state_icon(self.model)
        if stock_id is not None:
            self.state_icon.set_from_stock(stock_id, gtk.ICON_SIZE_MENU)
            self.state_icon.set_visible(True)
            self.state_icon.set_tooltip_text(tooltip)
        else:
            self.state_icon.hide()
开发者ID:pkaislan,项目名称:stoq,代码行数:34,代码来源:workordereditor.py

示例2: _can_open

    def _can_open(self):
        branch = api.get_current_branch(self.store)
        if Inventory.has_open(self.store, branch):
            return False

        # It doesn't make sense to open an inventory if we don't have any stock
        return self.store.find(ProductStockItem, branch=branch).count() > 0
开发者ID:rosalin,项目名称:stoq,代码行数:7,代码来源:inventory.py

示例3: new_sale

    def new_sale(self):
        store = self.window.store
        if Inventory.has_open(store, api.get_current_branch(store)):
            warning(_("You cannot create a quote with an open inventory."))
            return

        with api.new_store() as store:
            run_dialog(SaleQuoteWizard, None, store)
开发者ID:hackedbellini,项目名称:stoq,代码行数:8,代码来源:widgets.py

示例4: validate_confirm

    def validate_confirm(self):
        query = self._get_sellables_query()
        sellables = Inventory.get_sellables_for_inventory(self.store, self.model.branch, query)
        if sellables.is_empty():
            info(_(u'No products have been found in the selected '
                   'categories.'))
            return False

        return True
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:9,代码来源:inventoryeditor.py

示例5: setup_proxies

    def setup_proxies(self):
        # Avoid changing widget states in __init__, so that plugins have a
        # chance to override the default settings
        has_open_inventory = Inventory.has_open(self.store,
                                                api.get_current_branch(self.store))
        self.receive_now.set_sensitive(not bool(has_open_inventory))

        self._setup_transporter_entry()
        self.proxy = self.add_proxy(self.model, self.proxy_widgets)
开发者ID:pkaislan,项目名称:stoq,代码行数:9,代码来源:purchasewizard.py

示例6: on_confirm

    def on_confirm(self):
        # We are using this hook as a callback for the finish button
        branch = self.store.fetch(self.model.branch)
        responsible = self.store.fetch(self.model.user)
        inventory = Inventory(open_date=self.model.open_date,
                              branch=branch, responsible=responsible,
                              store=self.store)
        for sellable in self._get_sellables():
            storable = sellable.product_storable
            if storable is None:
                continue

            if storable.is_batch:
                for batch in storable.get_available_batches(inventory.branch):
                    inventory.add_sellable(sellable,
                                           batch_number=batch.batch_number)
            else:
                inventory.add_sellable(sellable)
开发者ID:LeonamSilva,项目名称:stoq,代码行数:18,代码来源:inventoryeditor.py

示例7: _register_inventory

 def _register_inventory(self):
     query = Storable.id == self._product.id
     inventory = Inventory.create_inventory(
         self.store, branch=self._branch, responsible=api.get_current_user(self.store), query=query
     )
     # At this point, the inventory should have only one item.
     item = inventory.get_items().one()
     item.counted_quantity = item.actual_quantity = self.model.quantity
     # item.product_cost = self.model.cost
     item.reason = self.model.reason
     item.adjust(invoice_number=None)
     inventory.close()
开发者ID:stoq,项目名称:stoq,代码行数:12,代码来源:producteditor.py

示例8: _setup_widgets

    def _setup_widgets(self):
        self.edit_button.set_sensitive(False)
        if not self.visual_mode:
            self.start_production_check.hide()

        has_open_inventory = Inventory.has_open(self.store,
                                                get_current_branch(self.store))
        self.start_production_check.set_sensitive(not bool(has_open_inventory))

        self.materials.set_columns(self._get_columns())
        for production_item in self.model.get_items():
            self._add_materials(production_item)
开发者ID:marianaanselmo,项目名称:stoq,代码行数:12,代码来源:productionslave.py

示例9: new_sale_with_wo

    def new_sale_with_wo(self):
        store = self.window.store
        if Inventory.has_open(store, api.get_current_branch(store)):
            warning(_("You cannot create a quote with an open inventory."))
            return

        with api.new_store() as store:
            run_dialog(WorkOrderQuoteWizard, None, store)

        if store.committed:
            # We are unable to just refresh the ui, so 'deactivate' and
            # 'activate' the launcher to mimic the refresh
            self.window.switch_application('launcher')
开发者ID:hackedbellini,项目名称:stoq,代码行数:13,代码来源:widgets.py

示例10: _get_available_branches_to_inventory

    def _get_available_branches_to_inventory(self):
        """Returns a list of branches where we can open an inventory.
        Note that we can open a inventory if:
            - There's no inventory opened yet (in the same branch)
            - The branch must have some stock
        """
        available_branches = []
        for branch in self._get_branches():
            has_open_inventory = Inventory.has_open(self.store, branch)
            if not has_open_inventory:
                stock = self.store.find(ProductStockItem, branch=branch)
                if stock.count() > 0:
                    available_branches.append(branch)

        return available_branches
开发者ID:marianaanselmo,项目名称:stoq,代码行数:15,代码来源:inventory.py

示例11: test_create_inventory

    def test_create_inventory(self):
        branch = self.create_branch()
        # A category so that we can filter the products we want in the
        # inventory
        cat = self.create_sellable_category()

        #  First, lets create some sellables for our test
        # One storable with stock (it should be in the inventory)
        storable1 = self.create_storable(branch=branch, stock=10)
        storable1.product.sellable.category = cat

        # One storable without stock (it should NOT be in the inventory)
        storable2 = self.create_storable()
        storable2.product.sellable.category = cat

        # One storable with one batch, and stock (it should be in the inventory)
        storable3 = self.create_storable()
        storable3.is_batch = True
        storable3.product.sellable.category = cat
        batch1 = self.create_storable_batch(storable3, u'123')
        storable3.increase_stock(3, branch, batch=batch1,
                                 type=0, object_id=None, unit_cost=10)

        # One storable with one batch and a stock item (but without stock).
        # it should be on the inventory
        storable4 = self.create_storable()
        storable4.is_batch = True
        storable4.product.sellable.category = cat
        batch2 = self.create_storable_batch(storable4, u'124')
        storable4.increase_stock(1, branch, batch=batch2,
                                 type=0, object_id=None, unit_cost=10)
        storable4.decrease_stock(1, branch, batch=batch2,
                                 type=0, object_id=None)

        # Then, lets open the inventory
        responsible = self.create_user()
        query = Sellable.category == cat
        inventory = Inventory.create_inventory(self.store, branch, responsible, query)

        self.assertEquals(inventory.branch, branch)
        self.assertEquals(inventory.responsible, responsible)

        # There should be only 3 items in the inventory
        items = inventory.get_items()
        self.assertEqual(items.count(), 3)
        self.assertEqual(set(i.product for i in items),
                         set([storable1.product,
                              storable3.product,
                              storable4.product]))

        # Use this examples to also test get_inventory_data
        data = list(inventory.get_inventory_data())
        self.assertEquals(len(data), 3)

        # each row should have 5 items
        row = data[0]
        self.assertEquals(len(row), 5)

        self.assertEquals(set(i[0] for i in data), set(items))
        self.assertEquals(set(i[1] for i in data),
                          set([storable1, storable3, storable4]))
        self.assertEquals(set(i[4] for i in data),
                          set([None, batch1, batch2]))
开发者ID:dionimf,项目名称:stoq,代码行数:63,代码来源:test_inventory.py

示例12: has_open_inventory

 def has_open_inventory(self):
     has_open = Inventory.has_open(self.store,
                                   api.get_current_branch(self.store))
     return bool(has_open)
开发者ID:hackedbellini,项目名称:stoq,代码行数:4,代码来源:productiondetails.py

示例13: on_confirm

 def on_confirm(self):
     # We are using this hook as a callback for the finish button
     branch = self.store.fetch(self.model.branch)
     responsible = self.store.fetch(self.model.user)
     query = self._get_sellables_query()
     return Inventory.create_inventory(self.store, branch, responsible, query)
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:6,代码来源:inventoryeditor.py

示例14: testRegisters

    def testRegisters(self):
        order = self.create_receiving_order()
        order.receival_date = localdate(2007, 6, 1).date()
        order.discount_value = 10
        # order.purchase.discount_value = 5
        # order.purchase.surcharge_value = 8
        # order.surcharge_value = 15
        order.ipi_total = 10
        order.freight_total = 6
        order.secure_value = 6
        order.expense_value = 12
        supplier = self.create_supplier()
        company = supplier.person.has_individual_or_company_facets()
        company.state_registry = u'103238426117'
        order.supplier = supplier
        employee = self.create_employee()
        branch = get_current_branch(self.store)
        branch.manager = employee

        order.purchase.status = order.purchase.ORDER_PENDING

        sellable = self.create_sellable()
        sellable.tax_constant = SellableTaxConstant(
            description=u"18",
            tax_type=int(TaxType.CUSTOM),
            tax_value=18,
            store=self.store)
        self.create_receiving_order_item(order, sellable=sellable)

        sellable2 = self.create_sellable()
        sellable2.tax_constant = SellableTaxConstant(
            description=u"6",
            tax_type=int(TaxType.CUSTOM),
            tax_value=6,
            store=self.store)
        self.create_receiving_order_item(order, sellable=sellable2)

        order.purchase.confirm()
        order.confirm()

        sellable.code = u'9999'
        sellable2.code = u'10000'

        sale = self.create_sale()
        sale.open_date = localdate(2007, 6, 10).date()

        sellable3 = self.create_sellable()
        product = sellable3.product
        sellable.tax_constant = SellableTaxConstant(
            description=u"18",
            tax_type=int(TaxType.CUSTOM),
            tax_value=18,
            store=self.store)

        sale.add_sellable(sellable3, quantity=1)

        self.create_storable(product, get_current_branch(self.store), stock=100)

        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()
        sale.close_date = localdate(2007, 6, 10).date()
        sale.confirm_date = localdate(2007, 6, 10).date()
        sellable3.code = u'09999'

        inventory = Inventory(branch=branch, store=self.store)
        inventory.open_date = localdate(2007, 6, 15).date()

        # product came from sellable3
        inventory_item = InventoryItem(product=product,
                                       product_cost=product.sellable.cost,
                                       inventory=inventory,
                                       recorded_quantity=99,
                                       store=self.store)
        inventory_item.cfop_data = self.store.get(CfopData, 1)
        inventory_item.reason = u'Test'
        inventory_item.actual_quantity = 99
        inventory_item.adjust(invoice_number=999)
        inventory.close(close_date=localdate(2007, 6, 15).date())

        generator = StoqlibSintegraGenerator(self.store,
                                             localdate(2007, 6, 1).date(),
                                             localdate(2007, 6, 30).date())

        try:
            compare_sintegra_file(generator.sintegra, 'sintegra-receival')
        except AssertionError as e:
            self.fail(e)
开发者ID:marianaanselmo,项目名称:stoq,代码行数:93,代码来源:test_sintegragenerator.py

示例15: _has_open_inventory

 def _has_open_inventory(self):
     store = self._parent.store
     has_open = Inventory.has_open(store, api.get_current_branch(store))
     return bool(has_open)
开发者ID:hackedbellini,项目名称:stoq,代码行数:4,代码来源:clientdetails.py


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