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


Python CONTEXT.update方法代码示例

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


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

示例1: setup_defaults

# 需要导入模块: from trytond.tests.test_tryton import CONTEXT [as 别名]
# 或者: from trytond.tests.test_tryton.CONTEXT import update [as 别名]
    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,代码行数:62,代码来源:test_party.py

示例2: setup_defaults

# 需要导入模块: from trytond.tests.test_tryton import CONTEXT [as 别名]
# 或者: from trytond.tests.test_tryton.CONTEXT import update [as 别名]
    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,代码行数:27,代码来源:test_report.py

示例3: test0010_create_shop

# 需要导入模块: from trytond.tests.test_tryton import CONTEXT [as 别名]
# 或者: from trytond.tests.test_tryton.CONTEXT import update [as 别名]
 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,代码行数:56,代码来源:test_sale_shop.py

示例4: setup_defaults

# 需要导入模块: from trytond.tests.test_tryton import CONTEXT [as 别名]
# 或者: from trytond.tests.test_tryton.CONTEXT import update [as 别名]
    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,代码行数:52,代码来源:test_transaction.py

示例5: setup_defaults

# 需要导入模块: from trytond.tests.test_tryton import CONTEXT [as 别名]
# 或者: from trytond.tests.test_tryton.CONTEXT import update [as 别名]
    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,代码行数:103,代码来源:test_ups.py

示例6: setup_defaults

# 需要导入模块: from trytond.tests.test_tryton import CONTEXT [as 别名]
# 或者: from trytond.tests.test_tryton.CONTEXT import update [as 别名]
    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,代码行数:103,代码来源:test_transaction.py

示例7: setup_defaults

# 需要导入模块: from trytond.tests.test_tryton import CONTEXT [as 别名]
# 或者: from trytond.tests.test_tryton.CONTEXT import update [as 别名]
    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,代码行数:103,代码来源:test_pagination.py

示例8: setup_defaults

# 需要导入模块: from trytond.tests.test_tryton import CONTEXT [as 别名]
# 或者: from trytond.tests.test_tryton.CONTEXT import update [as 别名]
    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,代码行数:103,代码来源:test_carrier.py

示例9: setup_defaults

# 需要导入模块: from trytond.tests.test_tryton import CONTEXT [as 别名]
# 或者: from trytond.tests.test_tryton.CONTEXT import update [as 别名]
    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,代码行数:103,代码来源:test_endicia.py

示例10: dataset

# 需要导入模块: from trytond.tests.test_tryton import CONTEXT [as 别名]
# 或者: from trytond.tests.test_tryton.CONTEXT import update [as 别名]
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,代码行数:103,代码来源:conftest.py

示例11: setup_defaults

# 需要导入模块: from trytond.tests.test_tryton import CONTEXT [as 别名]
# 或者: from trytond.tests.test_tryton.CONTEXT import update [as 别名]
    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,代码行数:103,代码来源:test_shipment.py

示例12: setup_defaults

# 需要导入模块: from trytond.tests.test_tryton import CONTEXT [as 别名]
# 或者: from trytond.tests.test_tryton.CONTEXT import update [as 别名]
    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,代码行数:80,代码来源:test_base.py

示例13: setup_defaults

# 需要导入模块: from trytond.tests.test_tryton import CONTEXT [as 别名]
# 或者: from trytond.tests.test_tryton.CONTEXT import update [as 别名]
    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,代码行数:103,代码来源:test_product.py

示例14: setup_defaults

# 需要导入模块: from trytond.tests.test_tryton import CONTEXT [as 别名]
# 或者: from trytond.tests.test_tryton.CONTEXT import update [as 别名]
    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,代码行数:103,代码来源:test_invoice.py

示例15: setup_defaults

# 需要导入模块: from trytond.tests.test_tryton import CONTEXT [as 别名]
# 或者: from trytond.tests.test_tryton.CONTEXT import update [as 别名]
    def setup_defaults(self):
        """Method to setup defaults
        """
        # Create currency
        self.currency, = self.Currency.create([{"name": "Euro", "code": "EUR", "symbol": "EUR"}])

        country_de, country_tw = self.Country.create(
            [{"name": "Germany", "code": "DE"}, {"name": "Taiwan", "code": "TW"}]
        )

        subdivision_bw, = self.Subdivision.create(
            [{"name": "Baden-Württemberg", "code": "DE-BW", "type": "state", "country": country_de.id}]
        )

        with Transaction().set_context(company=None):
            company_party, = self.Party.create(
                [
                    {
                        "name": "Deutsche Post IT Brief GmbH",
                        "vat_number": "123456",
                        "addresses": [
                            (
                                "create",
                                [
                                    {
                                        "name": "Max Muster",
                                        "street": "Heinrich-Bruening-Str.",
                                        "streetbis": "7",
                                        "zip": "53113",
                                        "city": "Bonn",
                                        "country": country_de.id,
                                    }
                                ],
                            )
                        ],
                        "contact_mechanisms": [
                            (
                                "create",
                                [
                                    {"type": "phone", "value": "030244547777778"},
                                    {"type": "email", "value": "[email protected]"},
                                    {"type": "fax", "value": "030244547777778"},
                                    {"type": "mobile", "value": "9876543212"},
                                    {"type": "website", "value": "example.com"},
                                ],
                            )
                        ],
                    }
                ]
            )

        self.company, = self.Company.create([{"party": company_party.id, "currency": self.currency.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,
#.........这里部分代码省略.........
开发者ID:kstenger,项目名称:trytond-shipping-dhl-de,代码行数:103,代码来源:test_shipment.py


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