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


Python runtime.get_current_branch函数代码示例

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


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

示例1: send

    def send(self):
        """Send the package to the :attr:`.destination_branch`

        This will mark the package as sent. Note that it's only possible
        to call this on the same branch as :attr:`.source_branch`.

        When calling this, the work orders' :attr:`WorkOrder.current_branch`
        will be ``None``, since they are on a package and not on any branch.
        """
        assert self.can_send()

        if self.source_branch != get_current_branch(self.store):
            raise ValueError(
                _("This package's source branch is %s and you are in %s. "
                  "It's not possible to send a package outside the "
                  "source branch") % (
                      self.source_branch, get_current_branch(self.store)))

        workorders = [item.order for item in self.package_items]
        if not len(workorders):
            raise ValueError(_("There're no orders to send"))

        for order in workorders:
            assert order.current_branch == self.source_branch
            # The order is going to leave the current_branch
            order.current_branch = None

        self.send_date = localnow()
        self.status = self.STATUS_SENT
开发者ID:marianaanselmo,项目名称:stoq,代码行数:29,代码来源:workorder.py

示例2: receive

    def receive(self):
        """Receive the package on the :attr:`.destination_branch`

        This will mark the package as received in the branch
        to receive it there. Note that it's only possible to call this
        on the same branch as :attr:`.destination_branch`.

        When calling this, the work orders' :attr:`WorkOrder.current_branch`
        will be set to :attr:`.destination_branch`, since receiving means
        they got to their destination.
        """
        assert self.can_receive()

        if self.destination_branch != get_current_branch(self.store):
            raise ValueError(
                _("This package's destination branch is %s and you are in %s. "
                  "It's not possible to receive a package outside the "
                  "destination branch") % (
                      self.destination_branch, get_current_branch(self.store)))

        for order in [item.order for item in self.package_items]:
            assert order.current_branch is None
            # The order is in destination branch now
            order.current_branch = self.destination_branch

        self.receive_date = localnow()
        self.status = self.STATUS_RECEIVED
开发者ID:marianaanselmo,项目名称:stoq,代码行数:27,代码来源:workorder.py

示例3: _create_sale

    def _create_sale(self, invoice_number, due_date=None):
        sale = self.create_sale()
        sale.invoice_number = invoice_number
        sale.branch = get_current_branch(self.store)
        tax_types = cycle(['aliq', 'nt', 'outr'])
        # [0] - Description
        # [1] - Code
        # [2] - Price
        # [3] - Quantity
        # [4] - Base price
        for tax_type, data in zip(tax_types, [
                (u"Laranja", u"1", Decimal(1), Decimal(10), Decimal('1.5')),
                (u"Limão", u"2", Decimal('0.5'), Decimal(15), Decimal('0.3')),
                (u"Abacaxi", u"3", Decimal(3), Decimal(1), Decimal('3.3')),
                (u"Cenoura", u"4", Decimal('1.5'), Decimal(6), Decimal('1.9')),
                (u"Pêssego", u"5", Decimal('3.5'), Decimal(3), Decimal('3.0'))]):
            sellable = self._create_sellable(data[0], data[1], data[2])
            storable = Storable(product=sellable.product,
                                store=self.store)
            storable.increase_stock(data[3], get_current_branch(self.store),
                                    StockTransactionHistory.TYPE_INITIAL,
                                    sale.id)

            sale_item = sale.add_sellable(sellable, data[3])
            if tax_type == 'aliq':
                self._add_aliq(sale_item)
            elif tax_type == 'nt':
                self._add_nt(sale_item)
            elif tax_type == 'outr':
                self._add_outr(sale_item)

            # Set the base price to test the discount in NF-e.
            sale_item.base_price = data[4]
            icms_info = sale_item.icms_info
            icms_info.csosn = 201
            icms_info.p_icms_st = 1

            self._update_taxes(sale_item)

        sale.client = self.create_client()
        self._create_address(sale.client.person,
                             street=u"Rua dos Tomates",
                             streetnumber=2666,
                             postal_code=u'87654-321')
        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(),
                              due_date=due_date)
        sale.confirm()

        return sale
开发者ID:adrianoaguiar,项目名称:stoq,代码行数:53,代码来源:test_nfe.py

示例4: create_workorder

 def create_workorder(self, equipment=u''):
     from stoqlib.domain.workorder import WorkOrder
     return WorkOrder(
         store=self.store,
         equipment=equipment,
         branch=get_current_branch(self.store),
         )
开发者ID:romaia,项目名称:stoq,代码行数:7,代码来源:exampledata.py

示例5: test_return_with_credit

    def test_return_with_credit(self):
        branch = get_current_branch(self.store)
        sale_item = self.create_sale_item()
        sale = sale_item.sale
        sellable = sale_item.sellable
        self.create_storable(product=sellable.product, branch=branch, stock=10)
        payments = self.add_payments(sale, method_type=u'bill',
                                     installments=2)
        payments[0].status = Payment.STATUS_PENDING
        self.add_payments(sale, method_type=u'money')
        sale.order()
        sale.confirm()

        rsale = ReturnedSale(branch=branch,
                             sale=sale,
                             store=self.store)
        ReturnedSaleItem(store=self.store,
                         returned_sale=rsale,
                         sale_item=sale_item,
                         quantity=1)
        # Create an unused to test the removal of unused items,
        # should probably be removed.
        ReturnedSaleItem(store=self.store,
                         returned_sale=rsale,
                         sale_item=sale_item,
                         quantity=0)
        rsale.return_(u'credit')
开发者ID:fuinha,项目名称:stoq,代码行数:27,代码来源:test_returnedsale.py

示例6: test_order_receive_sell

    def test_order_receive_sell(self):
        product = self.create_product()
        storable = Storable(product=product, store=self.store)
        self.failIf(self.store.find(ProductStockItem, storable=storable).one())
        purchase_order = self.create_purchase_order()
        purchase_item = purchase_order.add_item(product.sellable, 1)
        purchase_order.status = purchase_order.ORDER_PENDING
        method = PaymentMethod.get_by_name(self.store, u'money')
        method.create_payment(Payment.TYPE_OUT,
                              purchase_order.group, purchase_order.branch,
                              purchase_order.get_purchase_total())
        purchase_order.confirm()

        receiving_order = self.create_receiving_order(purchase_order)
        receiving_order.branch = get_current_branch(self.store)
        self.create_receiving_order_item(
            receiving_order=receiving_order,
            sellable=product.sellable,
            purchase_item=purchase_item,
            quantity=1)
        self.failIf(self.store.find(ProductStockItem, storable=storable).one())
        receiving_order.confirm()
        product_stock_item = self.store.find(ProductStockItem,
                                             storable=storable).one()
        self.failUnless(product_stock_item)
        self.assertEquals(product_stock_item.quantity, 1)

        sale = self.create_sale()
        sale.add_sellable(product.sellable)
        sale.order()
        method = PaymentMethod.get_by_name(self.store, u'check')
        method.create_payment(Payment.TYPE_IN, sale.group, sale.branch, Decimal(100))
        sale.confirm()
        self.assertEquals(product_stock_item.quantity, 0)
开发者ID:rosalin,项目名称:stoq,代码行数:34,代码来源:test_receiving.py

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

示例8: create_sale

    def create_sale(self, id_=None, branch=None, client=None):
        from stoqlib.domain.sale import Sale
        from stoqlib.domain.till import Till

        till = Till.get_current(self.store)
        if till is None:
            till = self.create_till()
            till.open_till()
        salesperson = self.create_sales_person()
        group = self.create_payment_group()
        if client:
            group.payer = client.person

        sale = Sale(
            coupon_id=0,
            open_date=TransactionTimestamp(),
            salesperson=salesperson,
            branch=branch or get_current_branch(self.store),
            cfop=sysparam(self.store).DEFAULT_SALES_CFOP,
            group=group,
            client=client,
            store=self.store,
        )
        if id_:
            sale.id = id_
            sale.identifier = id_
        return sale
开发者ID:rosalin,项目名称:stoq,代码行数:27,代码来源:exampledata.py

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

示例10: print_cheques_for_payment_group

def print_cheques_for_payment_group(store, group):
    """ Given a instance that implements the PaymentGroup interface, iterate
    over all its items printing a cheque for them.
    """
    payments = group.get_valid_payments()
    printer = get_current_cheque_printer_settings(store)
    if not printer:
        return
    printer_banks = printer.get_banks()
    current_branch = get_current_branch(store)
    main_address = current_branch.person.get_main_address()
    if not main_address:
        raise ValueError("The cheque can not be printed since there is no "
                         "main address defined for the current branch.")

    max_len = printer.get_capability("cheque_city").max_len
    city = main_address.city_location.city[:max_len]
    for idx, payment in enumerate(payments):
        if payment.method.method_name == 'check':
            continue
        check_data = payment.method.operation.get_check_data_by_payment(
            payment)
        bank_id = check_data.bank_data.bank_id
        try:
            bank = printer_banks[bank_id]
        except KeyError:
            continue
        thirdparty = group.recipient
        info(_(u"Insert Cheque %d") % (idx + 1))
        max_len = printer.get_capability("cheque_thirdparty").max_len
        thirdparty = thirdparty and thirdparty.name[:max_len] or ""
        printer.print_cheque(bank, payment.value, thirdparty, city)
开发者ID:Guillon88,项目名称:stoq,代码行数:32,代码来源:cheque.py

示例11: _add_header

    def _add_header(self):
        branch = get_current_branch(self.store)
        manager = branch.manager.person
        company = branch.person.company
        address = branch.person.get_main_address()

        state_registry = company.get_state_registry_number()
        state = address.get_state()

        self.sintegra.add_header(company.get_cnpj_number(),
                                 str(state_registry) or 'ISENTO',
                                 company.fancy_name,
                                 address.get_city(),
                                 state,
                                 branch.person.get_fax_number_number(),
                                 self.start,
                                 self.end)
        self.sintegra.add_complement_header(
            # If we don't have a street number, use zero for sintegra
            address.street, address.streetnumber or 0,
            address.complement,
            address.district,
            address.get_postal_code_number(),
            manager.name,
            branch.person.get_phone_number_number())

        self._add_registers(state)
开发者ID:tmaxter,项目名称:stoq,代码行数:27,代码来源:sintegragenerator.py

示例12: test_select_by_branch_data

    def test_select_by_branch_data(self):
        branch = get_current_branch(self.store)
        sale = self.create_sale()
        sale.branch = branch
        sellable = self.add_product(sale)
        sale.order()
        self.add_payments(sale, method_type=u"money")
        sale.confirm()

        results = SoldItemView.find_by_branch_date(self.store, None, None)
        self.assertFalse(results.is_empty())

        results = SoldItemView.find_by_branch_date(self.store, branch, None)
        self.assertFalse(results.is_empty())

        results = SoldItemView.find_by_branch_date(self.store, branch, None).find(SoldItemView.id == sellable.id)
        # FIXME: Storm does not support count() with group_by
        # self.assertEquals(results.count(), 1)
        self.assertEquals(len(list(results)), 1)

        today = localtoday()
        results = SoldItemView.find_by_branch_date(self.store, None, today).find(SoldItemView.id == sellable.id)
        self.assertEquals(len(list(results)), 1)

        yesterday = today - datetime.timedelta(days=1)
        results = SoldItemView.find_by_branch_date(self.store, None, (yesterday, today))
        results = results.find(SoldItemView.id == sellable.id)
        self.assertEquals(len(list(results)), 1)

        yesterday = today - datetime.timedelta(days=1)
        results = SoldItemView.find_by_branch_date(self.store, None, (yesterday, today))

        self.assertFalse(results.is_empty())
开发者ID:rg3915,项目名称:stoq,代码行数:33,代码来源:test_views.py

示例13: testTotalReturn

    def testTotalReturn(self):
        sale = self.create_sale(branch=get_current_branch(self.store))
        sellable = self.add_product(sale)
        storable = sellable.product_storable
        balance_before_confirm = storable.get_balance_for_branch(sale.branch)

        sale.order()
        self.add_payments(sale)
        sale.confirm()
        self.assertEqual(storable.get_balance_for_branch(sale.branch),
                         balance_before_confirm - 1)
        balance_before_return = storable.get_balance_for_branch(sale.branch)

        self.failUnless(sale.can_return())
        returned_sale = sale.create_sale_return_adapter()
        returned_sale.return_()

        self.failIf(sale.can_return())
        self.assertEqual(sale.status, Sale.STATUS_RETURNED)
        self.assertEqual(sale.return_date.date(), datetime.date.today())
        self.assertEqual(storable.get_balance_for_branch(sale.branch),
                         balance_before_return + 1)
        # Since this is a total return, balance should be
        # as it wasn't ever confirmed
        self.assertEqual(storable.get_balance_for_branch(sale.branch),
                         balance_before_confirm)
开发者ID:romaia,项目名称:stoq,代码行数:26,代码来源:test_sale.py

示例14: test_branch_combo_sensitivity

    def test_branch_combo_sensitivity(self):
        branch = get_current_branch(self.store)
        # Create product with supplier info for all branches
        supplier = self.create_supplier()
        product = self.create_product()
        supplier_info = self.create_product_supplier_info(
            product=product, supplier=supplier, branch=branch)

        # We are editing another product supplier info, and since there is NOT
        # another one for all branches, it's optional to set a branch
        new_supplier_info = self.create_product_supplier_info(
            product=product, supplier=supplier)
        editor = ProductSupplierEditor(self.store, new_supplier_info)
        self.assertNotSensitive(editor, ['branch_combo'])
        self.assertSensitive(editor, ['branch_checkbutton'])
        self.assertFalse(editor.branch_checkbutton.get_active())

        # Remove branch from original supplier info. Now it's generic/default
        supplier_info.branch = None
        # We are editing another product supplier info, and since there is
        # already another one for all branches, it's mandatory to set a specific
        # branch now
        editor = ProductSupplierEditor(self.store, new_supplier_info)
        self.assertSensitive(editor, ['branch_combo'])
        self.assertNotSensitive(editor, ['branch_checkbutton'])
        self.assertTrue(editor.branch_checkbutton.get_active())
开发者ID:hackedbellini,项目名称:stoq,代码行数:26,代码来源:test_productsuppliereditor.py

示例15: test_calculate_item_without_icms

    def test_calculate_item_without_icms(self):
        # SP (São Paulo) as default state.
        branch = get_current_branch(self.store)
        address = branch.person.get_main_address()
        state = address.city_location.state
        assert state == "SP"
        # Product with NCM, but without ICMS
        sale = self.create_sale()
        item = self.create_sale_item(sale)
        product = item.sellable.product
        product.ncm = u'01012100'
        items = sale.get_items()
        generator = IBPTGenerator(items)
        # When there is no icms information, the value defaults to the nacional
        # tax.
        tax_values = generator._load_tax_values(item)
        federal = generator._calculate_federal_tax(item, tax_values)
        self.assertEquals(federal, Decimal("4.20"))
        state = generator._calculate_state_tax(item, tax_values)
        self.assertEquals(state, Decimal("18"))

        msg = generate_ibpt_message(items)
        expected_msg = ("Trib aprox R$: 4.20 Federal e 18.00 Estadual\n"
                        "Fonte: IBPT 5oi7eW ")
        self.assertEquals(msg, expected_msg)
开发者ID:amaurihamasu,项目名称:stoq,代码行数:25,代码来源:test_ibpt.py


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