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

Python test_tryton.CONTEXT类代码示例

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

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



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

示例1: setup_defaults

    def setup_defaults(self):
        """Creates default data for testing
        """
        self.currency, = self.Currency.create([{
            'name': 'US Dollar',
            'code': 'USD',
            'symbol': '$',
        }])

        with Transaction().set_context(company=None):
            company_party, = self.Party.create([{
                'name': 'openlabs'
            }])
            employee_party, = self.Party.create([{
                'name': 'Jim'
            }])

        self.company, = self.Company.create([{
            'party': company_party,
            'currency': self.currency,
        }])

        self.employee, = self.Employee.create([{
            'party': employee_party.id,
            'company': self.company.id,
        }])

        self.User.write([self.User(USER)], {
            'company': self.company,
            'main_company': self.company,
            'employees': [('add', [self.employee.id])],
        })
        # Write employee separately as employees needs to be saved first
        self.User.write([self.User(USER)], {
            'employee': self.employee.id,
        })

        CONTEXT.update(self.User.get_preferences(context_only=True))

        # Create Fiscal Year
        self._create_fiscal_year(company=self.company.id)
        # Create Chart of Accounts
        self._create_coa_minimal(company=self.company.id)
        # Create a payment term
        self.payment_term, = self._create_payment_term()
        self.cash_journal, = self.Journal.search(
            [('type', '=', 'cash')], limit=1
        )

        self.country, = self.Country.create([{
            'name': 'United States of America',
            'code': 'US',
        }])

        self.subdivision, = self.Subdivision.create([{
            'country': self.country.id,
            'name': 'California',
            'code': 'CA',
            'type': 'state',
        }])
开发者ID:fulfilio,项目名称:trytond-party-merge,代码行数:60,代码来源:test_party.py


示例2: setup_defaults

    def setup_defaults(self):
        """
        Setup the defaults
        """
        with Transaction().set_context(company=None):
            self.usd, = self.Currency.create([{
                'name': 'US Dollar',
                'code': 'USD',
                'symbol': '$',
            }])
            self.party, = self.Party.create([{
                'name': 'Openlabs',
            }])
            self.company, = self.Company.create([{
                'party': self.party.id,
                'currency': self.usd
            }])
        self.User.write(
            [self.User(USER)], {
                'main_company': self.company.id,
                'company': self.company.id,
            }
        )

        CONTEXT.update(self.User.get_preferences(context_only=True))
开发者ID:openlabs,项目名称:trytond-report-html,代码行数:25,代码来源:test_report.py


示例3: test0010_create_shop

 def test0010_create_shop(self):
     with Transaction().start(DB_NAME, USER,
             context=CONTEXT) as transaction:
         #This is needed in order to get default values for other test
         #executing in the same database
         company, = self.company.search([
                 ('rec_name', '=', 'Dunder Mifflin'),
                 ])
         self.user.write([self.user(USER)], {
                 'main_company': company.id,
                 'company': company.id,
                 })
         CONTEXT.update(self.user.get_preferences(context_only=True))
         with transaction.set_context(company=company.id):
             sequence, = self.sequence.search([
                     ('code', '=', 'sale.sale'),
                     ], limit=1)
             warehouse, = self.location.search([
                     ('code', '=', 'WH'),
                     ])
             price_list, = self.price_list.create([{
                         'name': 'Test',
                         }])
             term, = self.payment_term.create([{
                         'name': 'Payment term',
                         'lines': [
                             ('create', [{
                                         'sequence': 0,
                                         'type': 'remainder',
                                         'days': 0,
                                         'months': 0,
                                         'weeks': 0,
                                         }])]
                         }])
             shop, = self.shop.create([{
                         'name': 'Shop',
                         'warehouse': warehouse.id,
                         'price_list': price_list.id,
                         'payment_term': term.id,
                         'sale_sequence': sequence.id,
                         'sale_invoice_method': 'order',
                         'sale_invoice_method': 'order',
                         }])
             user = self.user(USER)
             self.user.write([user], {
                     'shops': [('add', [shop])],
                     'shop': shop.id,
                      })
         # Clear user values before commiting
         self.user.write([self.user(USER)], {
                 'main_company': None,
                 'company': None,
                 })
         transaction.cursor.commit()
开发者ID:aleibrecht,项目名称:tryton-modules-ar,代码行数:54,代码来源:test_sale_shop.py


示例4: setup_defaults

    def setup_defaults(self):
        """
        Creates default data for testing
        """
        currency, = self.Currency.create([{
            'name': 'US Dollar',
            'code': 'USD',
            'symbol': '$',
        }])

        with Transaction().set_context(company=None):
            company_party, = self.Party.create([{
                'name': 'Openlabs'
            }])

        self.company, = self.Company.create([{
            'party': company_party,
            'currency': currency,
        }])

        self.User.write([self.User(USER)], {
            'company': self.company,
            'main_company': self.company,
        })

        CONTEXT.update(self.User.get_preferences(context_only=True))

        # Create Fiscal Year
        self._create_fiscal_year(company=self.company.id)
        # Create Chart of Accounts
        self._create_coa_minimal(company=self.company.id)
        # Create Cash journal
        self.cash_journal, = self.Journal.search(
            [('type', '=', 'cash')], limit=1
        )
        self.Journal.write([self.cash_journal], {
            'debit_account': self._get_account_by_kind('expense').id
        })

        # Create a party
        self.party, = self.Party.create([{
            'name': 'Test party',
            'addresses': [('create', [{
                'name': 'Test Party',
                'street': 'Test Street',
                'city': 'Test City',
            }])],
            'account_receivable': self._get_account_by_kind(
                'receivable').id,
        }])
开发者ID:sharoonthomas,项目名称:trytond-payment-gateway,代码行数:50,代码来源:test_transaction.py


示例5: test_0010_test_failure_counter

    def test_0010_test_failure_counter(self):
        context = CONTEXT.copy()
        with Transaction().start(DB_NAME, USER, context=context) as txn:
            self.setup_defaults()
            app = self.get_app()

            txn.cursor.commit()

        DatabaseOperationalError = backend.get('DatabaseOperationalError')

        @transaction_start.connect
        def incr_error_count(app):
            """
            Subscribe to the transaction_start to increment the counter
            """
            self.error_counter += 1

        CONFIG['retry'] = 4

        with app.test_client() as c:
            try:
                c.get('fail-with-transaction-error')
            except DatabaseOperationalError:
                self.assertEqual(self.error_counter, 5)
开发者ID:2cadz,项目名称:nereid,代码行数:24,代码来源:test_dispatch.py


示例6: setup_defaults

    def setup_defaults(self):
        """Method to setup defaults
        """
        # Create currency
        self.currency, = self.Currency.create([{"name": "United Stated Dollar", "code": "USD", "symbol": "USD"}])
        self.Currency.create([{"name": "Indian Rupee", "code": "INR", "symbol": "INR"}])

        country_us, = self.Country.create([{"name": "United States", "code": "US"}])

        subdivision_florida, = self.CountrySubdivision.create(
            [{"name": "Florida", "code": "US-FL", "country": country_us.id, "type": "state"}]
        )

        subdivision_california, = self.CountrySubdivision.create(
            [{"name": "California", "code": "US-CA", "country": country_us.id, "type": "state"}]
        )

        with Transaction().set_context(company=None):
            company_party, = self.Party.create(
                [
                    {
                        "name": "Test Party",
                        "vat_number": "123456",
                        "addresses": [
                            (
                                "create",
                                [
                                    {
                                        "name": "Amine Khechfe",
                                        "street": "247 High Street",
                                        "zip": "94301-1041",
                                        "city": "Palo Alto",
                                        "country": country_us.id,
                                        "subdivision": subdivision_california.id,
                                    }
                                ],
                            )
                        ],
                    }
                ]
            )

        self.ups_service, = self.UPSService.create([{"name": "Next Day Air", "code": "01"}])

        self.ups_service2, = self.UPSService.create([{"name": "Second Next Day Air", "code": "02"}])

        self.SaleConfig.create([{"ups_service_type": self.ups_service.id}])
        self.company, = self.Company.create([{"party": company_party.id, "currency": self.currency.id}])
        self.PartyContact.create([{"type": "phone", "value": "8005551212", "party": self.company.party.id}])

        self.User.write([self.User(USER)], {"main_company": self.company.id, "company": self.company.id})

        CONTEXT.update(self.User.get_preferences(context_only=True))

        self._create_fiscal_year(company=self.company)
        self._create_coa_minimal(company=self.company)
        self.payment_term, = self._create_payment_term()

        account_revenue, = self.Account.search([("kind", "=", "revenue")])

        # Create product category
        category, = self.Category.create([{"name": "Test Category"}])

        uom_kg, = self.Uom.search([("symbol", "=", "kg")])
        uom_cm, = self.Uom.search([("symbol", "=", "cm")])
        uom_pound, = self.Uom.search([("symbol", "=", "lb")])

        # Carrier Carrier Product
        carrier_product_template, = self.Template.create(
            [
                {
                    "name": "Test Carrier Product",
                    "category": category.id,
                    "type": "service",
                    "salable": True,
                    "sale_uom": uom_kg,
                    "list_price": Decimal("10"),
                    "cost_price": Decimal("5"),
                    "default_uom": uom_kg,
                    "cost_price_method": "fixed",
                    "account_revenue": account_revenue.id,
                    "products": [("create", self.Template.default_products())],
                }
            ]
        )

        carrier_product = carrier_product_template.products[0]

        # Create product
        template, = self.Template.create(
            [
                {
                    "name": "Test Product",
                    "category": category.id,
                    "type": "goods",
                    "salable": True,
                    "sale_uom": uom_kg,
                    "list_price": Decimal("10"),
                    "cost_price": Decimal("5"),
                    "default_uom": uom_kg,
#.........这里部分代码省略.........
开发者ID:riteshshrv,项目名称:trytond-shipping-ups,代码行数:101,代码来源:test_ups.py


示例7: setup_defaults

    def setup_defaults(self):
        """
        Creates default data for testing
        """
        self.country, = self.Country.create([{
            'name': 'United States',
            'code': 'US',
        }])

        self.subdivision, = self.CountrySubdivision.create([{
            'name': 'Florida',
            'code': 'US-FL',
            'country': self.country.id,
            'type': 'state'
        }])
        currency, = self.Currency.create([{
            'name': 'Unites Stated',
            'code': 'USD',
            'symbol': '$',
        }])

        with Transaction().set_context(company=None):
            company_party, = self.Party.create([{
                'name': 'Openlabs'
            }])

        self.company, = self.Company.create([{
            'party': company_party,
            'currency': currency,
        }])

        self.User.write([self.User(USER)], {
            'company': self.company,
            'main_company': self.company,
        })

        CONTEXT.update(self.User.get_preferences(context_only=True))

        # Create Fiscal Year
        self._create_fiscal_year(company=self.company.id)
        # Create Chart of Accounts
        self._create_coa_minimal(company=self.company.id)
        # Create Cash journal
        self.cash_journal, = self.Journal.search(
            [('type', '=', 'cash')], limit=1
        )
        self.Journal.write([self.cash_journal], {
            'debit_account': self._get_account_by_kind('expense').id,
            'credit_account': self._get_account_by_kind('expense').id,
        })

        self.beanstream_passcode_gateway = self.PaymentGateway(
            name='beanstream',
            journal=self.cash_journal,
            provider='beanstream',
            method='credit_card',
            beanstream_auth_mechanism='passcode',
            beanstream_merchant_id='300200425',
            beanstream_pass_code='B042485853bb4ee9b8269ADEAF6A60dd',
            beanstream_currency=currency,
            test=True
        )
        self.beanstream_passcode_gateway.save()

        self.beanstream_hash_gateway = self.PaymentGateway(
            name='beanstream',
            journal=self.cash_journal,
            provider='beanstream',
            method='credit_card',
            beanstream_auth_mechanism='hash',
            beanstream_merchant_id='300200425',
            beanstream_hash_key='de59b16d310ace6983af0b0a791c1d318f79ec9d',
            beanstream_currency=currency,
            test=True,
        )
        self.beanstream_hash_gateway.save()

        # Create parties
        self.party1, = self.Party.create([{
            'name': 'Test party - 1',
            'addresses': [
                ('create', [{
                    'name': 'Amine Khechfe',
                    'street': '247 High Street',
                    'zip': '94301-1041',
                    'city': 'Palo Alto',
                    'country': self.country.id,
                    'subdivision': self.subdivision.id,
                }])
            ],
            'account_receivable': self._get_account_by_kind(
                'receivable'
            ).id,
        }])
        self.party2, = self.Party.create([{
            'name': 'Test party - 2',
            'addresses': [
                ('create', [{
                    'name': 'Amine Khechfe',
                    'street': '247 High Street',
#.........这里部分代码省略.........
开发者ID:openlabs,项目名称:payment-gateway-beanstream,代码行数:101,代码来源:test_transaction.py


示例8: setup_defaults

    def setup_defaults(self):
        """
        Setup defaults
        """
        usd, = self.Currency.create([{
            'name': 'US Dollar',
            'code': 'USD',
            'symbol': '$',
        }])

        with Transaction().set_context(company=None):
            company_party, = self.Party.create([{
                'name': 'Openlabs',
                'addresses': [('create', [{
                    'name': 'Openlabs',
                }])],
            }])

        self.company, = self.Company.create([{
            'party': company_party.id,
            'currency': usd,
        }])

        self.User.write([self.User(USER)], {
            'company': self.company,
            'main_company': self.company,
        })

        CONTEXT.update(self.User.get_preferences(context_only=True))

        # Create Fiscal Year
        self._create_fiscal_year(company=self.company.id)
        # Create Chart of Accounts
        self._create_coa_minimal(company=self.company.id)
        # Create a payment term
        payment_term, = self._create_payment_term()

        channel_price_list, user_price_list = self._create_pricelists()
        party1, = self.Party.create([{
            'name': 'Guest User',
        }])

        party2, = self.Party.create([{
            'name': 'Registered User',
            'sale_price_list': user_price_list,
        }])

        self.party2 = party2

        party3, = self.Party.create([{
            'name': 'Registered User 2',
        }])

        # Create users and assign the pricelists to them
        self.guest_user, = self.NereidUser.create([{
            'party': party1.id,
            'display_name': 'Guest User',
            'email': '[email protected]',
            'password': 'password',
            'company': self.company.id,
        }])
        self.registered_user, = self.NereidUser.create([{
            'party': party2.id,
            'display_name': 'Registered User',
            'email': '[email protected]',
            'password': 'password',
            'company': self.company.id,
        }])
        self.registered_user2, = self.NereidUser.create([{
            'party': party3.id,
            'display_name': 'Registered User 2',
            'email': '[email protected]',
            'password': 'password2',
            'company': self.company.id,
        }])

        warehouse, = self.Location.search([
            ('type', '=', 'warehouse')
        ], limit=1)
        location, = self.Location.search([
            ('type', '=', 'storage')
        ], limit=1)
        en_us, = self.Language.search([('code', '=', 'en_US')])

        self.locale_en_us, = self.Locale.create([{
            'code': 'en_US',
            'language': en_us.id,
            'currency': usd.id,
        }])

        self.channel, = self.SaleChannel.create([{
            'name': 'Default Channel',
            'price_list': channel_price_list,
            'warehouse': warehouse,
            'payment_term': payment_term,
            'company': self.company.id,
            'create_users': [('add', [USER])],
            'invoice_method': 'order',
            'shipment_method': 'order',
            'source': 'manual'
#.........这里部分代码省略.........
开发者ID:mbehrle,项目名称:nereid-webshop-elastic-search,代码行数:101,代码来源:test_pagination.py


示例9: setup_defaults

    def setup_defaults(self):
        """Creates default data for testing
        """
        self.currency, = self.Currency.create([{
            'name': 'US Dollar',
            'code': 'USD',
            'symbol': '$',
        }])

        with Transaction().set_context(company=None):
            company_party, = self.Party.create([{
                'name': 'openlabs'
            }])
            employee_party, = self.Party.create([{
                'name': 'Jim'
            }])

        self.company, = self.Company.create([{
            'party': company_party,
            'currency': self.currency,
        }])

        self.employee, = self.Employee.create([{
            'party': employee_party.id,
            'company': self.company.id,
        }])

        self.User.write([self.User(USER)], {
            'company': self.company,
            'main_company': self.company,
            'employees': [('add', [self.employee.id])],
        })
        # Write employee separately as employees needs to be saved first
        self.User.write([self.User(USER)], {
            'employee': self.employee.id,
        })

        CONTEXT.update(self.User.get_preferences(context_only=True))

        # Create Fiscal Year
        self._create_fiscal_year(company=self.company.id)
        # Create Chart of Accounts
        self._create_coa_minimal(company=self.company.id)
        # Create a payment term
        self.payment_term, = self._create_payment_term()

        # Create carrier
        carrier_price_list, = self.PriceList.create([{
            'name': 'PL 1',
            'company': self.company.id,
            'lines': [
                ('create', [{
                    'formula': '(unit_price * 0.0) + 5',
                }])
            ],
        }])
        carrier_party, = self.Party.create([{
            'name': 'Pricelist Carrier',
        }])

        day, = self.Uom.search([('name', '=', 'Day')])
        carrier_product_template, = self.ProductTemplate.create([{
            'name': 'Carrier Pricelist',
            'type': 'service',
            'salable': True,
            'default_uom': day.id,
            'sale_uom': day.id,
            'account_revenue': self._get_account_by_kind('revenue').id,
            'list_price': Decimal('50'),
            'cost_price': Decimal('40'),
        }])
        carrier_product, = self.Product.create([{
            'template': carrier_product_template.id,
        }])
        self.carrier, = self.Carrier.create([{
            'party': carrier_party.id,
            'carrier_cost_method': 'pricelist',
            'carrier_product': carrier_product.id,
            'price_list': carrier_price_list.id,
        }])

        unit, = self.Uom.search([('name', '=', 'Unit')])

        self.template1, = self.ProductTemplate.create([{
            'name': 'Product 1',
            'type': 'goods',
            'salable': True,
            'default_uom': unit.id,
            'sale_uom': unit.id,
            'list_price': Decimal('100'),
            'cost_price': Decimal('90'),
            'account_revenue': self._get_account_by_kind('revenue').id,
            'products': [('create', [{
                'code': 'product-1'
            }])]
        }])

        self.template2, = self.ProductTemplate.create([{
            'name': 'Product 2',
            'type': 'goods',
#.........这里部分代码省略.........
开发者ID:openlabs,项目名称:trytond-carrier-pricelist,代码行数:101,代码来源:test_carrier.py


示例10: setup_defaults

    def setup_defaults(self):
        """Method to setup defaults
        """
        # Create currency
        self.currency, = self.Currency.create([{
            'name': 'United Stated Dollar',
            'code': 'USD',
            'symbol': 'USD',
        }])
        self.Currency.create([{
            'name': 'Indian Rupee',
            'code': 'INR',
            'symbol': 'INR',
        }])

        country_us, country_at = self.Country.create([{
            'name': 'United States',
            'code': 'US',
        }, {
            'name': 'Austria',
            'code': 'AT',
        }])

        subdivision_idaho, = self.Country_Subdivision.create([{
            'name': 'Idaho',
            'code': 'US-ID',
            'country': country_us.id,
            'type': 'state'
        }])

        subdivision_california, = self.Country_Subdivision.create([{
            'name': 'California',
            'code': 'US-CA',
            'country': country_us.id,
            'type': 'state'
        }])

        subdivision_steiermark, = self.Country_Subdivision.create([{
            'name': 'Steiermark',
            'code': 'AT-6',
            'country': country_at.id,
            'type': 'state'
        }])

        with Transaction().set_context(company=None):
            company_party, = self.Party.create([{
                'name': 'Test Party',
                'addresses': [('create', [{
                    'name': 'Amine Khechfe',
                    'street': '247 High Street',
                    'zip': '84301',
                    'city': 'Palo Alto',
                    'country': country_us.id,
                    'subdivision': subdivision_california.id,
                }])]
            }])

        # Endicia Configuration
        self.EndiciaConfiguration.create([{
            'account_id': '123456',
            'requester_id': '123456',
            'passphrase': 'PassPhrase',
            'is_test': True,
        }])
        self.company, = self.Company.create([{
            'party': company_party.id,
            'currency': self.currency.id,
        }])
        self.PartyContact.create([{
            'type': 'phone',
            'value': '8005551212',
            'party': self.company.party.id
        }])

        # Sale configuration
        endicia_mailclass, = self.EndiciaMailclass.search([
            ('value', '=', 'First')
        ])

        self.SaleConfig.write(self.SaleConfig(1), {
            'endicia_label_subtype': 'Integrated',
            'endicia_integrated_form_type': 'Form2976',
            'endicia_mailclass': endicia_mailclass.id,
            'endicia_include_postage': True,
        })

        self.User.write(
            [self.User(USER)], {
                'main_company': self.company.id,
                'company': self.company.id,
            }
        )

        CONTEXT.update(self.User.get_preferences(context_only=True))

        self._create_fiscal_year(company=self.company)
        self._create_coa_minimal(company=self.company)
        self.payment_term, = self._create_payment_term()

        account_revenue, = self.Account.search([
#.........这里部分代码省略.........
开发者ID:openlabs,项目名称:trytond-endicia-integration,代码行数:101,代码来源:test_endicia.py


示例11: dataset

def dataset(request):
    """Create minimal data needed for testing
    """
    from trytond.transaction import Transaction
    from trytond.tests.test_tryton import USER, CONTEXT, DB_NAME, POOL

    Party = POOL.get('party.party')
    Company = POOL.get('company.company')
    Country = POOL.get('country.country')
    Subdivision = POOL.get('country.subdivision')
    Employee = POOL.get('company.employee')
    Currency = POOL.get('currency.currency')
    User = POOL.get('res.user')
    FiscalYear = POOL.get('account.fiscalyear')
    Sequence = POOL.get('ir.sequence')
    AccountTemplate = POOL.get('account.account.template')
    Account = POOL.get('account.account')
    Journal = POOL.get('account.journal')
    PaymentGateway = POOL.get('payment_gateway.gateway')
    AccountCreateChart = POOL.get('account.create_chart', type="wizard")

    with Transaction().start(DB_NAME, USER, context=CONTEXT) as transaction:
        # Create company, employee and set it user's current company
        usd, = Currency.create([{
            'name': 'US Dollar',
            'code': 'USD',
            'symbol': '$',
        }])

        country_us, = Country.create([{
            'name': 'United States',
            'code': 'US',
        }])
        subdivision_florida, = Subdivision.create([{
            'name': 'Florida',
            'code': 'US-FL',
            'country': country_us.id,
            'type': 'state'
        }])
        subdivision_california, = Subdivision.create([{
            'name': 'California',
            'code': 'US-CA',
            'country': country_us.id,
            'type': 'state'
        }])

        company_party, = Party.create([{
            'name': 'ABC Corp.',
            'addresses': [('create', [{
                'name': 'ABC Corp.',
                'street': '247 High Street',
                'zip': '94301-1041',
                'city': 'Palo Alto',
                'country': country_us.id,
                'subdivision': subdivision_california.id,
            }])],
            'contact_mechanisms': [('create', [{
                'type': 'phone',
                'value': '123456789'
            }])]
        }])

        employee_party, = Party.create([{
            'name': 'Prakash Pandey',
        }])
        company, = Company.create([{
            'party': company_party.id,
            'currency': usd.id,
        }])
        employee, = Employee.create([{
            'party': employee_party.id,
            'company': company.id,
        }])
        User.write(
            [User(USER)], {
                'main_company': company.id,
                'company': company.id,
            }
        )
        CONTEXT.update(User.get_preferences(context_only=True))

        # Create fiscal year
        date = datetime.date.today()

        post_move_sequence, = Sequence.create([{
            'name': '%s' % date.year,
            'code': 'account.move',
            'company': company.id,
        }])

        fiscal_year, = FiscalYear.create([{
            'name': '%s' % date.year,
            'start_date': date + relativedelta(month=1, day=1),
            'end_date': date + relativedelta(month=12, day=31),
            'company': company.id,
            'post_move_sequence': post_move_sequence.id,
        }])
        FiscalYear.create_period([fiscal_year])

        # Create minimal chart of account
#.........这里部分代码省略.........
开发者ID:usudaysingh,项目名称:trytond-payment-gateway-stripe,代码行数:101,代码来源:conftest.py


示例12: setup_defaults

    def setup_defaults(self):
        """Method to setup defaults
        """
        # Create currency
        self.currency, = self.Currency.create([{
            'name': 'United Stated Dollar',
            'code': 'USD',
            'symbol': 'USD',
        }])
        self.Currency.create([{
            'name': 'Indian Rupee',
            'code': 'INR',
            'symbol': 'INR',
        }])

        country_us, = self.Country.create([{
            'name': 'United States',
            'code': 'US',
        }])

        country_in, = self.Country.create([{
            'name': 'India',
            'code': 'IN',
        }])

        subdivision_delhi, = self.CountrySubdivision.create([{
            'name': 'Delhi',
            'code': 'IN-DL',
            'country': country_in.id,
            'type': 'state'
        }])

        subdivision_florida, = self.CountrySubdivision.create([{
            'name': 'Florida',
            'code': 'US-FL',
            'country': country_us.id,
            'type': 'state'
        }])

        subdivision_california, = self.CountrySubdivision.create([{
            'name': 'California',
            'code': 'US-CA',
            'country': country_us.id,
            'type': 'state'
        }])

        with Transaction().set_context(company=None):
            company_party, = self.Party.create([{
                'name': 'Test Party',
                'vat_number': '123456',
                'addresses': [('create', [{
                    'name': 'Amine Khechfe',
                    'street': '247 High Street',
                    'zip': '94301',
                    'city': 'Palo Alto',
                    'country': country_us.id,
                    'subdivision': subdivision_california.id,
                }])]
            }])

        self.company, = self.Company.create([{
            'party': company_party.id,
            'currency': self.currency.id,
        }])
        self.PartyContact.create([{
            'type': 'phone',
            'value': '8005551212',
            'party': self.company.party.id
        }])

        self.User.write(
            [self.User(USER)], {
                'main_company': self.company.id,
                'company': self.company.id,
            }
        )

        CONTEXT.update(self.User.get_preferences(context_only=True))

        self._create_fiscal_year(company=self.company)
        self._create_coa_minimal(company=self.company)
        self.payment_term, = self._create_payment_term()

        account_revenue, = self.Account.search([
            ('kind', '=', 'revenue')
        ])

        # Create product category
        category, = self.Category.create([{
            'name': 'Test Category',
        }])

        uom_kg, = self.Uom.search([('symbol', '=', 'kg')])
        uom_cm, = self.Uom.search([('symbol', '=', 'cm')])
        uom_pound, = self.Uom.search([('symbol', '=', 'lb')])

        # Carrier Carrier Product
        carrier_product_template, = self.Template.create([{
            'name': 'Test Carrier Product',
            'category': category.id,
#.........这里部分代码省略.........
开发者ID:kstenger,项目名称:trytond-shipping-dpd,代码行数:101,代码来源:test_shipment.py


示例13: setup_defaults

    def setup_defaults(self):
        """Creates default data for testing
        """

        self.currency, = self.Currency.create([{
            'name': 'US Dollar',
            'code': 'USD',
            'symbol': '$',
        }])

        with Transaction().set_context(company=None):
            self.company_party, = self.Party.create([{
                'name': 'openlabs',
            }])

        self.company, = self.Company.create([{
            'party': self.company_party,
            'currency': self.currency,
        }])
        self.User.write([self.User(USER)], {
            'company': self.company,
            'main_company': self.company,
        })

        CONTEXT.update(self.User.get_preferences(context_only=True))

        self.country, = self.Country.create([{
            'name': 'United States of America',
            'code': 'US',
        }])
        self.subdivision, = self.Subdivision.create([{
            'country': self.country.id,
            'name': 'California',
            'code': 'CA',
            'type': 'state',
        }])

        self._create_coa_minimal(self.company)
        self._create_payment_term()

        self.party, = self.Party.create([{
            'name': 'Bruce Wayne',
            'addresses': [('create', [{
                'name': 'Bruce Wayne',
                'party': Eval('id'),
                'city': 'Gotham',
                'country': self.country.id,
                'subdivision': self.subdivision.id,
            }])],
            'contact_mechanisms': [('create', [
                {'type': 'mobile', 'value': '8888888888'},
            ])],
        }])
        self.Party.write([self.company.party], {
            'addresses': [('create', [{
                'name': 'Lie Nielsen',
                'city': 'Los Angeles',
                'country': self.country.id,
                'subdivision': self.subdivision.id,
            }])],
        })
        self.product_category, = self.ProductCategory.create([{
            'name': 'Automobile',
        }])
        self.uom, = self.Uom.search([('name', '=', 'Unit')])

        self.product_template, = self.ProductTemplate.create([{
            'name': 'Bat Mobile',
            'type': 'goods',
            'category': self.product_category.id,
            'list_price': Decimal('20000'),
            'cost_price': Decimal('15000'),
            'default_uom': self.uom.id,
        }])
        self.product, = self.Product.create([{
            'template': self.product_template.id,
            'code': '123',
        }])
开发者ID:riteshshrv,项目名称:trytond-report-html-stock,代码行数:78,代码来源:test_base.py


示例14: setup_defaults

    def setup_defaults(self):
        """
        Setup the defaults
        """

        self.User.write(
            [self.User(USER)], {
                'main_company': self.company.id,
                'company': self.company.id,
            }
        )
        CONTEXT.update(self.User.get_preferences(context_only=True))

        # Create Fiscal Year
        self._create_fiscal_year(company=self.company.id)
        # Create Chart of Accounts
        self._create_coa_minimal(company=self.company.id)
        # Create a payment term
        self._create_payment_term()

        guest_price_list, user_price_list = self._create_pricelists()

        party1, = self.Party.create([{
            'name': 'Guest User',
            'sale_price_list': guest_price_list
        }])

        party2, = self.Party.create([{
            'name': 'Registered User',
            'sale_price_list': user_price_list,
        }])

        party3, = self.Party.create([{
            'name': 'Registered User 2',
        }])

        # Create users and assign the pricelists to them
        guest_user, = self.NereidUser.create([{
            'party': party1.id,
            'display_name': 'Guest User',
            'email': '[email protected]',
            'password': 'password',
            'company': self.company.id,
        }])
        self.registered_user, = self.NereidUser.create([{
            'party': party2.id,
            'display_name': 'Registered User',
            'email': '[email protected]',
            'password': 'password',
            'company': self.company.id,
        }])
        self.registered_user2, = self.NereidUser.create([{
            'party': party3.id,
            'display_name': 'Registered User 2',
            'email': '[email protected]',
            'password': 'password2',
            'company': self.company.id,
        }])

        self._create_countries()
        self.available_countries = self.Country.search([], limit=5)

        self.category, = self._create_product_category(
            'Category', [{'uri': 'category'}]
        )

        warehouse, = self.Location.search([
            ('type', '=', 'warehouse')
        ], limit=1)
        location, = self.Location.search([
            ('type', '=', 'storage')
        ], limit=1)
        url_map, = self.UrlMap.search([], limit=1)
        en_us, = self.Language.search([('code', '=', 'en_US')])

        self.locale_en_us, = self.Locale.create([{
            'code': 'en_US',
            'language': en_us.id,
            'currency': self.usd.id,
        }])
        self.NereidWebsite.create([{
            'name': 'localhost',
            'url_map': url_map,
            'company': self.company.id,
            'application_user': USER,
            'default_locale': self.locale_en_us.id,
            'guest_user': guest_user,
            'countries': [('set', self.available_countries)],
            'warehouse': warehouse,
            'stock_location': location,
            'categories': [('set', [self.category.id])],
            'currencies': [('set', [self.usd.id])],
        }])

         # Create product templates with products
        self.template1, = self._create_product_template(
            'product-1',
            [{
                'category': self.category.id,
                'type': 'goods',
#.........这里部分代码省略.........
开发者ID:aroraumang,项目名称:nereid-cart-b2c,代码行数:101,代码来源:test_product.py


示例15: setup_defaults

    def setup_defaults(self):
        """Creates default data for testing
        """
        currency, = self.Currency.create([{
            'name': 'US Dollar',
            'code': 'USD',
            'symbol': '$',
        }])

        with Transaction().set_context(company=None):
            company_party, = self.Party.create([{
                'name': 'Openlabs'
            }])

        self.company, = self.Company.create([{
            'party': company_party,
            'currency': currency,
        }])

        self.User.write([self.User(USER)], {
            'company': self.company,
            'main_company': self.company,
        })

        CONTEXT.update(self.User.get_preferences(context_only=True))

        # Create Fiscal Year
        self._create_fiscal_year(company=self.company.id)
        # Create Chart of Accounts
        self._create_coa_minimal(company=self.company.id)
        # Create a payment term
        self.payment_term, = self._create_payment_term()

        self.cash_journal, = self.Journal.search(
            [('type', '=', 'cash')], limit=1
        )

        # This is required to successfully pay the invoices
        main_cash_account = self._get_account_by_kind('other')

        self.Journal.write([self.cash_journal], {
            'debit_account': main_cash_account.id
        })

        self.uom, = self.Uom.search([('symbol', '=', 'd')])

        self.country, = self.Country.create([{
            'name': 'United States of America',
            'code': 'US',
        }])

        self.subdivision, = self.Subdivision.create([{
            'country': self.country.id,
            'name': 'California',
            'code': 'CA',
            'type': 'state',
        }])

        # Add address to company's party record
        self.Party.write([self.company.party], {
            'addresses': [('create', [{
                'name': 'Openlabs',
                'party': Eval('id'),
                'city': 'Los Angeles',
                'invoice': True,
                'country': self.country.id,
                'subdivision': self.subdivision.id,
            }])],
        })

        # Create party
        self.party, = self.Party.create([{
            'name': 'Bruce Wayne',
            'addresses': [('create', [{
                'name': 'Bruce Wayne',
                'party': Eval('id'),
                'city': 'Gotham',
                'invoice': True,
                'country': self.country.id,
                'subdivision': self.subdivision.id,
            }])],
            'customer_payment_term': self.payment_term.id,
            'account_receivable': self._get_account_by_kind(
                'receivable').id,
            'contact_mechanisms': [('create', [
                {'type': 'mobile', 'value': '8888888888'},
            ])],
        }])

        self.journal, = self.Journal.search([('type', '=', 'revenue')], limit=1)

        self.product_category, = self.ProductCategory.create([{
            'name': 'Test Category',
            'account_revenue': self._get_account_by_kind(
                'revenue', company=self.company.id).id,
            'account_expense': self._get_account_by_kind(
                'expense', company=self.company.id).id,
        }])

        self.product_template, = self.ProductTemplate.create([{
#.........这里部分代码省略.........
开发者ID:openlabs,项目名称:invoice-payment-gateway,代码行数:101,代码来源:test_invoice.py


示例16: setup_defaults

该文章已有0人参与评论

请发表评论

全部评论

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