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


Python api.get_current_branch函数代码示例

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


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

示例1: test_create

    def test_create(self):
        storable = self.create_storable(is_batch=True)
        batch = self.create_storable_batch(storable=storable,
                                           batch_number=u'1')
        batch.create_date = datetime.date(2010, 10, 10)
        batch = self.create_storable_batch(storable=storable,
                                           batch_number=u'2')
        batch.create_date = datetime.date(2011, 11, 11)
        batch = self.create_storable_batch(storable=storable,
                                           batch_number=u'3')
        batch.create_date = datetime.date(2012, 12, 12)

        storable.register_initial_stock(10, api.get_current_branch(self.store),
                                        1, u'1')
        storable.register_initial_stock(15, api.get_current_branch(self.store),
                                        1, u'2')
        storable.register_initial_stock(8, api.get_current_branch(self.store),
                                        1, u'3')

        dialog = BatchSelectionDialog(self.store, storable, 33)
        for entry in dialog._spins.keys():
            entry.update(1)
            dialog._spins[entry].update(12)

        for entry in dialog._spins.keys()[1:]:
            entry.update(2)
            dialog._spins[entry].update(7)

        for entry in dialog._spins.keys()[2:]:
            entry.update(3)
            dialog._spins[entry].update(8)

        dialog.existing_batches_expander.set_expanded(True)

        self.check_dialog(dialog, 'dialog-batch-selection-dialog-create')
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:35,代码来源:test_batchselectiondialog.py

示例2: test_auto_reserve

    def test_auto_reserve(self, yesno):
        # Data setup
        client = self.create_client()
        medic = self.create_optical_medic(crm_number=u'999')

        auto = self.create_storable(
            branch=api.get_current_branch(self.store),
            stock=10)
        auto.product.sellable.barcode = u'auto_reserve'
        OpticalProduct(store=self.store, product=auto.product,
                       auto_reserve=True)

        not_auto = self.create_storable(
            branch=api.get_current_branch(self.store),
            stock=10)
        not_auto.product.sellable.barcode = u'not_auto_reserve'
        OpticalProduct(store=self.store, product=not_auto.product,
                       auto_reserve=False)

        wizard = OpticalSaleQuoteWizard(self.store)
        # First step: Client
        step = wizard.get_current_step()
        step.client_gadget.set_value(client)
        self.click(wizard.next_button)

        # Second Step: optical data
        step = wizard.get_current_step()
        slave = step.slaves['WO 1']
        slave.patient.update('Patient')
        slave.medic_gadget.set_value(medic)
        slave.estimated_finish.update(localdate(2020, 1, 5))

        # Third Step: Products
        self.click(wizard.next_button)
        step = wizard.get_current_step()

        # Add two items: One auto reserved and another not. Both with initially
        # 10 items on stock
        for barcode in ['auto_reserve', 'not_auto_reserve']:
            step.barcode.set_text(barcode)
            self.activate(step.barcode)
            step.quantity.update(5)
            self.click(step.add_sellable_button)

        # Finish the wizard
        yesno.return_value = False
        with mock.patch.object(self.store, 'commit'):
            self.click(wizard.next_button)

        # Now check the stock for the two items. The auto reverd should have the
        # stock decreased to 5. The one that not auto reserves should still be
        # at 10
        self.assertEqual(auto.get_total_balance(), 5)
        self.assertEqual(not_auto.get_total_balance(), 10)
开发者ID:hackedbellini,项目名称:stoq,代码行数:54,代码来源:test_optical_wizard.py

示例3: test_get

    def test_get(self):
        with self.sysparam(DEMO_MODE=True):
            with self.fake_store():
                api.get_current_branch(self.store)
                s = self.login()

                sellable = self.create_sellable()
                img = self.create_image()
                img.image = b'foobar'
                img.sellable_id = sellable.id

                rv = self.client.get('/image/' + sellable.id, headers={'stoq-session': s})
                self.assertEqual(rv.status_code, 200)
                self.assertEqual(rv.data, b'foobar')
开发者ID:hackedbellini,项目名称:stoq-server,代码行数:14,代码来源:test_restful.py

示例4: test_confirm

    def test_confirm(self, yesno, print_report):
        client = self.create_client()
        branch = api.get_current_branch(self.store)
        storable = self.create_storable(branch=branch, stock=1)
        sellable = storable.product.sellable
        wizard = NewLoanWizard(self.store)

        step = wizard.get_current_step()
        step.client.update(client)
        step.expire_date.update(localtoday().date())
        self.check_wizard(wizard, 'new-loan-wizard-start-step')
        self.click(wizard.next_button)

        step = wizard.get_current_step()
        step.barcode.set_text(sellable.barcode)
        step.sellable_selected(sellable)
        step.quantity.update(1)
        self.click(step.add_sellable_button)
        loan_item = self.store.find(LoanItem, sellable=sellable).one()
        module = 'stoqlib.gui.events.NewLoanWizardFinishEvent.emit'
        with mock.patch(module) as emit:
            self.click(wizard.next_button)
            self.assertEquals(emit.call_count, 1)
            args, kwargs = emit.call_args
            self.assertTrue(isinstance(args[0], Loan))
        self.check_wizard(wizard, 'new-loan-wizard-item-step',
                          [wizard.retval, loan_item])

        yesno.assert_called_once_with(_('Would you like to print the receipt now?'),
                                      gtk.RESPONSE_YES, 'Print receipt', "Don't print")
        self.assertEquals(print_report.call_count, 1)

        # verifies if stock was decreased correctly
        self.assertEquals(storable.get_balance_for_branch(branch), 0)
开发者ID:rosalin,项目名称:stoq,代码行数:34,代码来源:test_loanwizard.py

示例5: test_confirm

    def test_confirm(self, save, generator, localtoday):
        save.return_value = True

        value = datetime.datetime(2012, 1, 31)
        localtoday.return_value = value

        # we need to create a system table because it is used by the sintegra
        # dialog to populate the date filter
        SystemTable(updated=datetime.datetime(2012, 1, 1),
                    patchlevel=0,
                    generation=1,
                    store=self.store)
        branch = api.get_current_branch(self.store)
        branch.manager = self.create_employee()

        dialog = SintegraDialog(self.store)
        with mock.patch.object(generator, 'write'):
            self.click(dialog.ok_button)
            self.check_dialog(dialog, 'dialog-sintegra-confirm', [dialog.retval])

            self.assertEquals(save.call_count, 1)
            args, kwargs = save.call_args
            label, toplevel, filename = args
            self.assertEquals(label, _("Save Sintegra file"))
            self.assertTrue(isinstance(toplevel, gtk.Dialog))
            self.assertEquals(filename, 'sintegra-2012-01.txt')
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:26,代码来源:test_sintegra_dialog.py

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

示例7: _get_or_create_quote_group

 def _get_or_create_quote_group(self, order, store):
     if order is not None:
         quotation = store.find(Quotation, purchase=order).one()
         return quotation.group
     else:
         return QuoteGroup(branch=api.get_current_branch(store),
                           store=store)
开发者ID:pkaislan,项目名称:stoq,代码行数:7,代码来源:purchasequotewizard.py

示例8: test_batch_number_suggestion_synchronized_mode

    def test_batch_number_suggestion_synchronized_mode(self):
        branch = api.get_current_branch(self.store)
        branch.acronym = u'AB'

        storable = self.create_storable(is_batch=True)
        storable2 = self.create_storable(is_batch=True)

        dialog = BatchIncreaseSelectionDialog(self.store, storable, 10)
        self.assertEqual(dialog._last_entry.get_text(), '')

        with self.sysparam(SUGGEST_BATCH_NUMBER=True, SYNCHRONIZED_MODE=True):
            storable.register_initial_stock(1, self.create_branch(), 0,
                                            batch_number=u'130')
            dialog = BatchIncreaseSelectionDialog(self.store, storable, 10)
            # Make sure it suggested right
            self.assertEqual(dialog._last_entry.get_text(), '131-AB')

            spinbutton = dialog.get_spin_by_entry(dialog._last_entry)
            spinbutton.update(5)
            # Updating the spinbutton should append a new entry with the suggestion
            self.assertEqual(dialog._last_entry.get_text(), '132-AB')
            self.click(dialog.main_dialog.ok_button)

            dialog = BatchIncreaseSelectionDialog(self.store, storable2, 10)
            # Since the dialog above was confirmed on the same store this one is,
            # it should consider it's batch numbers for the next suggestion
            self.assertEqual(dialog._last_entry.get_text(), '133-AB')

            branch.acronym = None
            spinbutton = dialog.get_spin_by_entry(dialog._last_entry)
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:30,代码来源:test_batchselectiondialog.py

示例9: test_wizard

    def test_wizard(self, receipt_dialog):
        branch = api.get_current_branch(self.store)
        storable = self.create_storable(branch=branch, stock=1)
        sellable = storable.product.sellable
        wizard = StockDecreaseWizard(self.store)

        step = wizard.get_current_step()
        self.assertFalse(step.create_payments.get_visible())
        self.assertNotSensitive(wizard, ['next_button'])
        step.reason.update('text')
        self.assertSensitive(wizard, ['next_button'])
        self.check_wizard(wizard, 'start-stock-decrease-step')
        self.click(wizard.next_button)

        step = wizard.get_current_step()
        self.assertNotSensitive(wizard, ['next_button'])
        step.barcode.set_text(sellable.barcode)
        step.sellable_selected(sellable)
        step.quantity.update(1)
        self.click(step.add_sellable_button)
        self.check_wizard(wizard, 'decrease-item-step')

        self.assertSensitive(wizard, ['next_button'])
        module = 'stoqlib.gui.events.StockDecreaseWizardFinishEvent.emit'
        with mock.patch(module) as emit:
            with mock.patch.object(self.store, 'commit'):
                self.click(wizard.next_button)
            self.assertEqual(emit.call_count, 1)
            args, kwargs = emit.call_args
            self.assertTrue(isinstance(args[0], StockDecrease))

        self.assertEqual(receipt_dialog.call_count, 1)

        # Assert wizard decreased stock.
        self.assertEqual(storable.get_balance_for_branch(branch), 0)
开发者ID:hackedbellini,项目名称:stoq,代码行数:35,代码来源:test_stockdecreasewizard.py

示例10: _update_widgets

    def _update_widgets(self):
        branch = api.get_current_branch(self.store)

        is_main_branch = self.branch_filter.get_state().value is branch
        item = self.results.get_selected()

        sellable = item and item.product.sellable
        if sellable:
            if sellable.has_image:
                thumbnail = sellable.image.thumbnail
                pixbuf = self.pixbuf_converter.from_string(thumbnail)
            else:
                pixbuf = None

            self._update_edit_image(pixbuf)
            if self.image_viewer:
                self.image_viewer.set_sellable(sellable)
        else:
            self._update_edit_image()

        self.set_sensitive([self.EditProduct], bool(item))
        self.set_sensitive([self.ProductStockHistory],
                           bool(item) and is_main_branch)
        # We need more than one branch to be able to do transfers
        # Note that 'all branches' is not a real branch
        has_branches = len(self.branch_filter.combo) > 2

        transfer_active = self.NewTransfer.get_sensitive()
        self.set_sensitive([self.NewTransfer],
                           transfer_active and has_branches)
        self.set_sensitive([self.SearchTransfer], has_branches)
开发者ID:tmaxter,项目名称:stoq,代码行数:31,代码来源:stock.py

示例11: test_wizard_with_cost_center

    def test_wizard_with_cost_center(self, yesno):
        sysparam.set_bool(self.store, 'CREATE_PAYMENTS_ON_STOCK_DECREASE', True)
        yesno.return_value = False

        branch = api.get_current_branch(self.store)
        storable = self.create_storable(branch=branch, stock=1)
        sellable = storable.product.sellable
        cost_center = self.create_cost_center()

        wizard = StockDecreaseWizard(self.store)

        entry = self.store.find(CostCenterEntry,
                                cost_center=wizard.model.cost_center)
        self.assertEqual(len(list(entry)), 0)

        step = wizard.get_current_step()
        step.reason.update('test')
        step.cost_center.select(cost_center)
        self.check_wizard(wizard, 'stock-decrease-with-cost-center')

        self.click(wizard.next_button)

        step = wizard.get_current_step()
        step.barcode.set_text(sellable.barcode)
        step.sellable_selected(sellable)
        step.quantity.update(1)
        self.click(step.add_sellable_button)
        with mock.patch.object(self.store, 'commit'):
            self.click(wizard.next_button)

        self.assertEqual(wizard.model.cost_center, cost_center)
        entry = self.store.find(CostCenterEntry,
                                cost_center=wizard.model.cost_center)
        self.assertEqual(len(list(entry)), 1)
开发者ID:hackedbellini,项目名称:stoq,代码行数:34,代码来源:test_stockdecreasewizard.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: _show_search

 def _show_search(self):
     search = ProductionHistorySearch(self.store)
     search.branch_filter.set_state(api.get_current_branch(self.store).id)
     search.date_filter.select(Any)
     search.search.refresh()
     search.results.select(search.results[0])
     return search
开发者ID:LeonamSilva,项目名称:stoq,代码行数:7,代码来源:test_productionsearch.py

示例14: create_filters

 def create_filters(self):
     self.search.set_query(self._query)
     self.set_text_field_columns(["description", "code", "barcode", "category_description", "manufacturer"])
     branches = Branch.get_active_branches(self.store)
     self.branch_filter = ComboSearchFilter(_("Show by:"), api.for_combo(branches, empty=_("All branches")))
     self.branch_filter.select(api.get_current_branch(self.store))
     self.add_filter(self.branch_filter, position=SearchFilterPosition.TOP)
开发者ID:coletivoEITA,项目名称:stoq,代码行数:7,代码来源:stock.py

示例15: test_save_new_sale

    def test_save_new_sale(self, new_store):
        new_store.return_value = self.store

        with contextlib.nested(
                self.sysparam(USE_SALE_TOKEN=True),
                mock.patch.object(self.store, 'close'),
                mock.patch.object(self.store, 'commit')):
            pos = self.create_app(PosApp, u'pos')
            self._pos_open_till(pos)
            token = self.create_sale_token(
                u'foobar', branch=api.get_current_branch(self.store))
            self._open_token(pos, token)

            pos.barcode.set_text(u'1598756984265')
            self.activate(pos.barcode)

            _sale = []
            original_create_sale = pos._create_sale

            def _create_sale(*args, **kwargs):
                sale = original_create_sale(*args, **kwargs)
                _sale.append(sale)
                return sale

            with mock.patch.object(pos, '_create_sale') as create_sale:
                create_sale.side_effect = _create_sale
                self.click(pos.save_button)

            sale = _sale[0]
            self.assertEqual(sale.status, Sale.STATUS_ORDERED)
            self.assertEqual(sale.current_sale_token, token)
            items = list(sale.get_items())
            self.assertEqual(len(items), 1)
            self.assertEqual(items[0].sellable.barcode, u'1598756984265')
开发者ID:hackedbellini,项目名称:stoq,代码行数:34,代码来源:test_pos.py


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