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

Python test_tryton.POOL类代码示例

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

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



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

示例1: test_0100_template_trans_tag_with_expr

    def test_0100_template_trans_tag_with_expr(self):
        """
        Test for
        {% trans user=user.username %}Hello {{ user }}!{% endtrans %} tag
        """
        TranslationSet = POOL.get('ir.translation.set', type='wizard')
        IRTranslation = POOL.get('ir.translation')

        with Transaction().start(DB_NAME, USER, CONTEXT):
            session_id, _, _ = TranslationSet.create()
            set_wizard = TranslationSet(session_id)

            # Set the nereid_template translations alone
            set_wizard.set_nereid_template()

            # XXX: See how {{ user }} changed to %(user)s
            translation, = IRTranslation.search([
                ('type', '=', 'nereid_template'),
                ('module', '=', 'nereid_test'),
                ('src', '=', 'Hello %(name)s!')
            ])
            self.assertEqual(
                translation.comments, 'Translation with an expression'
            )
            self.assertEqual(translation.res_id, 26)
开发者ID:2cadz,项目名称:nereid,代码行数:25,代码来源:test_translation.py


示例2: test_0100_product_images

    def test_0100_product_images(self):
        """
        Test for adding product images
        """
        Product = POOL.get('product.product')
        StaticFolder = POOL.get("nereid.static.folder")
        StaticFile = POOL.get("nereid.static.file")
        Media = POOL.get('product.media')

        with Transaction().start(DB_NAME, USER, CONTEXT):
            self.setup_defaults()
            self.create_test_products()

            folder, = StaticFolder.create([{
                'name': 'Test'
            }])
            file_buffer = buffer('test-content')
            file, = StaticFile.create([{
                'name': 'test.png',
                'folder': folder.id,
                'file_binary': file_buffer
            }])

            product, = Product.search([], limit=1)

            Media.create([{
                'product': product.id,
                'template': product.template.id,
                'static_file': file.id,
            }])

            app = self.get_app()
            with app.test_request_context('/'):
                home_template = render_template('home.jinja', product=product)
                self.assertTrue(file.name in home_template)
开发者ID:2cadz,项目名称:nereid-catalog,代码行数:35,代码来源:test_catalog.py


示例3: _create_fiscal_year

    def _create_fiscal_year(self, date=None, company=None):
        """
        Creates a fiscal year and requried sequences
        """
        FiscalYear = POOL.get('account.fiscalyear')
        Sequence = POOL.get('ir.sequence')
        Company = POOL.get('company.company')

        if date is None:
            date = datetime.date.today()

        if company is None:
            company, = Company.search([], limit=1)

        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,
            'post_move_sequence': Sequence.create([{
                'name': '%s' % date.year,
                'code': 'account.move',
                'company': company,
            }])[0],
        }])
        FiscalYear.create_period([fiscal_year])
        return fiscal_year
开发者ID:openlabs,项目名称:payment-gateway-beanstream,代码行数:27,代码来源:test_transaction.py


示例4: test_0080_import_sale_order_with_bundle_product

    def test_0080_import_sale_order_with_bundle_product(self):
        """
        Tests import of sale order with bundle product using magento data
        """
        Sale = POOL.get('sale.sale')
        Category = POOL.get('product.category')

        with Transaction().start(DB_NAME, USER, CONTEXT):
            self.setup_defaults()

            with Transaction().set_context({
                'current_channel': self.channel1.id,
            }):

                order_states_list = load_json('order-states', 'all')
                for code, name in order_states_list.iteritems():
                    self.channel1.create_order_state(code, name)

                category_tree = load_json('categories', 'category_tree')
                Category.create_tree_using_magento_data(category_tree)

                orders = Sale.search([])
                self.assertEqual(len(orders), 0)

                order_data = load_json('orders', '300000001')

                with patch(
                        'magento.Customer', mock_customer_api(), create=True):
                    self.Party.find_or_create_using_magento_id(
                        order_data['customer_id']
                    )

                with Transaction().set_context(company=self.company):
                    # Create sale order using magento data
                    with patch(
                        'magento.Product', mock_product_api(), create=True
                    ):
                        order = Sale.find_or_create_using_magento_data(
                            order_data
                        )

                self.assertEqual(order.state, 'confirmed')

                orders = Sale.search([])
                self.assertEqual(len(orders), 1)

                # Item lines + shipping line should be equal to lines on tryton
                self.assertEqual(len(order.lines), 2)

                self.assertEqual(
                    order.total_amount, Decimal(order_data['base_grand_total'])
                )

                # There should be a BoM for the bundle product
                product = self.channel1.import_product('VGN-TXN27N-BW')

                self.assertEqual(len(product.boms), 1)
                self.assertEqual(
                    len(product.boms[0].bom.inputs), 2
                )
开发者ID:prakashpp,项目名称:trytond-magento,代码行数:60,代码来源:test_sale.py


示例5: _create_fiscal_year

    def _create_fiscal_year(self, date=None, company=None):
        """
        Creates a fiscal year and requried sequences
        """
        Sequence = POOL.get('ir.sequence')
        SequenceStrict = POOL.get('ir.sequence.strict')

        if date is None:
            date = datetime.date.today()

        if company is None:
            company, = self.Company.search([], limit=1)

        invoice_sequence, = SequenceStrict.create([{
            'name': '%s' % date.year,
            'code': 'account.invoice',
            'company': company,
        }])
        fiscal_year, = self.FiscalYear.create([{
            'name': '%s' % date.year,
            'start_date': date + relativedelta(month=1, day=1),
            'end_date': date + relativedelta(month=12, day=31),
            'company': company,
            'post_move_sequence': Sequence.create([{
                'name': '%s' % date.year,
                'code': 'account.move',
                'company': company,
            }])[0],
            'out_invoice_sequence': invoice_sequence,
            'in_invoice_sequence': invoice_sequence,
            'out_credit_note_sequence': invoice_sequence,
            'in_credit_note_sequence': invoice_sequence,
        }])
        self.FiscalYear.create_period([fiscal_year])
        return fiscal_year
开发者ID:mbehrle,项目名称:nereid-webshop-elastic-search,代码行数:35,代码来源:test_pagination.py


示例6: setUp

    def setUp(self):
        trytond.tests.test_tryton.install_module('nereid_s3')
        self.static_file = POOL.get('nereid.static.file')
        self.static_folder = POOL.get('nereid.static.folder')

        # Mock S3Connection
        self.s3_api_patcher = patch(
            'boto.s3.connection.S3Connection', autospec=True
        )
        PatchedS3 = self.s3_api_patcher.start()

        # Mock S3Key
        self.s3_key_patcher = patch(
            'boto.s3.key.Key', autospec=True
        )
        PatchedS3Key = self.s3_key_patcher.start()

        PatchedS3.return_value = connection.S3Connection('ABCD', '123XYZ')
        PatchedS3.return_value.get_bucket = lambda bucket_name: Bucket(
            PatchedS3.return_value, 'tryton-test-s3'
        )

        PatchedS3Key.return_value = Key(
            Bucket(PatchedS3.return_value, 'tryton-test-s3'), 'some key'
        )
        PatchedS3Key.return_value.key = "some key"
        PatchedS3Key.return_value.get_contents_as_string = lambda *a: 'testfile'
        PatchedS3Key.return_value.set_contents_from_string = \
            lambda value: 'testfile'
开发者ID:openlabs,项目名称:trytond-nereid-s3,代码行数:29,代码来源:test_nereid_s3.py


示例7: _create_auth_net_gateway_for_site

    def _create_auth_net_gateway_for_site(self):
        """
        A helper function that creates the authorize.net gateway and assigns
        it to the websites.
        """
        PaymentGateway = POOL.get('payment_gateway.gateway')
        NereidWebsite = POOL.get('nereid.website')
        Journal = POOL.get('account.journal')

        cash_journal, = Journal.search([
            ('name', '=', 'Cash')
        ])

        gateway = PaymentGateway(
            name='Authorize.net',
            journal=cash_journal,
            provider='authorize_net',
            method='credit_card',
            authorize_net_login='327deWY74422',
            authorize_net_transaction_key='32jF65cTxja88ZA2',
            test=True
        )
        gateway.save()

        websites = NereidWebsite.search([])
        NereidWebsite.write(websites, {
            'accept_credit_card': True,
            'save_payment_profile': True,
            'credit_card_gateway': gateway.id,
        })
        return gateway
开发者ID:fulfilio,项目名称:nereid-checkout,代码行数:31,代码来源:test_payment.py


示例8: setUp

 def setUp(self):
     install_module('test')
     self.one2many = POOL.get('test.copy.one2many')
     self.one2many_target = POOL.get('test.copy.one2many.target')
     self.one2many_reference = POOL.get('test.copy.one2many_reference')
     self.one2many_reference_target = \
         POOL.get('test.copy.one2many_reference.target')
开发者ID:Sisouvan,项目名称:ogh,代码行数:7,代码来源:test_copy.py


示例9: setUp

 def setUp(self):
     trytond.tests.test_tryton.install_module('elastic_search')
     self.IndexBacklog = POOL.get('elasticsearch.index_backlog')
     self.DocumentType = POOL.get('elasticsearch.document.type')
     self.User = POOL.get('res.user')
     self.Model = POOL.get('ir.model')
     self.Trigger = POOL.get('ir.trigger')
开发者ID:sharoonthomas,项目名称:trytond-elastic-search,代码行数:7,代码来源:test_elastic_search.py


示例10: test_0020_render_unicode

    def test_0020_render_unicode(self):
        '''
        Render the report without PDF conversion but having unicode template
        '''
        UserReport = POOL.get('res.user', type='report')
        IRReport = POOL.get('ir.action.report')

        with Transaction().start(DB_NAME, USER, context=CONTEXT):
            self.setup_defaults()

            with Transaction().set_context(company=self.company.id):
                report_html, = IRReport.create([{
                    'name': 'HTML Report',
                    'model': 'res.user',
                    'report_name': 'res.user',
                    'report_content': buffer(
                        "<h1>Héllø, {{data['name']}}!</h1>"
                    ),
                    'extension': 'html',
                }])

                val = UserReport.execute([USER], {'name': u'Cédric'})
                self.assertEqual(val[0], u'html')
                self.assertEqual(
                    str(val[1]), '<h1>Héllø, Cédric!</h1>'
                )
开发者ID:openlabs,项目名称:trytond-report-html,代码行数:26,代码来源:test_report.py


示例11: test_0010_render_report_xhtml

    def test_0010_render_report_xhtml(self):
        '''
        Render the report without PDF conversion
        '''
        UserReport = POOL.get('res.user', type='report')
        IRReport = POOL.get('ir.action.report')

        with Transaction().start(DB_NAME, USER, context=CONTEXT):
            self.setup_defaults()

            with Transaction().set_context(company=self.company.id):
                report_html, = IRReport.create([{
                    'name': 'HTML Report',
                    'model': 'res.user',
                    'report_name': 'res.user',
                    'report_content': buffer(
                        '<h1>Hello, {{records[0].name}}!</h1>'
                    ),
                    'extension': 'html',
                }])
                val = UserReport.execute([USER], {})
                self.assertEqual(val[0], u'html')
                self.assertEqual(
                    str(val[1]), '<h1>Hello, Administrator!</h1>'
                )
开发者ID:openlabs,项目名称:trytond-report-html,代码行数:25,代码来源:test_report.py


示例12: test_0400_translation_export

    def test_0400_translation_export(self):
        """
        Export the translations and test
        """
        TranslationSet = POOL.get('ir.translation.set', type='wizard')
        TranslationUpdate = POOL.get('ir.translation.update', type='wizard')
        IRTranslation = POOL.get('ir.translation')
        IRLanguage = POOL.get('ir.lang')

        with Transaction().start(DB_NAME, USER, CONTEXT):
            # First create all the translations
            session_id, _, _ = TranslationSet.create()
            set_wizard = TranslationSet(session_id)
            set_wizard.transition_set_()

            # set an additional language as translatable
            new_lang, = IRLanguage.search([
                ('translatable', '=', False)
            ], limit=1)
            new_lang.translatable = True
            new_lang.save()

            # Now update the translations
            session_id, _, _ = TranslationUpdate.create()
            update_wizard = TranslationUpdate(session_id)

            update_wizard.start.language = new_lang
            update_wizard.do_update(update_wizard.update.get_action())

            # TODO: Check the contents of the po file
            IRTranslation.translation_export(new_lang.code, 'nereid_test')
            IRTranslation.translation_export(new_lang.code, 'nereid')
开发者ID:2cadz,项目名称:nereid,代码行数:32,代码来源:test_translation.py


示例13: test_0300_translation_update

    def test_0300_translation_update(self):
        """
        Check if the update does not break this functionality
        """
        TranslationSet = POOL.get('ir.translation.set', type='wizard')
        TranslationUpdate = POOL.get('ir.translation.update', type='wizard')
        IRTranslation = POOL.get('ir.translation')
        IRLanguage = POOL.get('ir.lang')

        with Transaction().start(DB_NAME, USER, CONTEXT):
            # First create all the translations
            session_id, _, _ = TranslationSet.create()
            set_wizard = TranslationSet(session_id)
            set_wizard.transition_set_()

            # set an additional language as translatable
            new_lang, = IRLanguage.search([
                ('translatable', '=', False)
            ], limit=1)
            new_lang.translatable = True
            new_lang.save()

            count_before = IRTranslation.search([], count=True)

            # Now update the translations
            session_id, _, _ = TranslationUpdate.create()
            update_wizard = TranslationUpdate(session_id)

            update_wizard.start.language = new_lang
            update_wizard.do_update(update_wizard.update.get_action())

            # check the count now
            count_after = IRTranslation.search([], count=True)
            self.assertEqual(count_after, count_before * 2)
开发者ID:2cadz,项目名称:nereid,代码行数:34,代码来源:test_translation.py


示例14: test_0200_translation_clean

    def test_0200_translation_clean(self):
        """
        Check if the cleaning of translations work
        """
        TranslationSet = POOL.get('ir.translation.set', type='wizard')
        TranslationClean = POOL.get('ir.translation.clean', type='wizard')
        IRTranslation = POOL.get('ir.translation')
        IRModule = POOL.get('ir.module.module')

        with Transaction().start(DB_NAME, USER, CONTEXT):
            # First create all the translations
            session_id, _, _ = TranslationSet.create()
            set_wizard = TranslationSet(session_id)
            set_wizard.transition_set_()

            # Uninstall nereid_test and there should be no translations
            # belonging to that module with type as nereid or
            # nereid_template
            nereid_test, = IRModule.search([('name', '=', 'nereid_test')])
            nereid_test.state = 'uninstalled'
            nereid_test.save()

            session_id, _, _ = TranslationClean.create()
            clean_wizard = TranslationClean(session_id)
            clean_wizard.transition_clean()

            count = IRTranslation.search([
                ('module', '=', 'nereid_test'),
                ('type', 'in', ('nereid', 'nereid_template'))
            ], count=True)
            self.assertEqual(count, 0)
开发者ID:2cadz,项目名称:nereid,代码行数:31,代码来源:test_translation.py


示例15: test_0090_import_sale_order_with_bundle_product_check_duplicate

    def test_0090_import_sale_order_with_bundle_product_check_duplicate(self):
        """
        Tests import of sale order with bundle product using magento data
        This tests that the duplication of BoMs doesnot happen
        """
        Sale = POOL.get('sale.sale')
        ProductTemplate = POOL.get('product.template')
        Category = POOL.get('product.category')
        MagentoOrderState = POOL.get('magento.order_state')

        with Transaction().start(DB_NAME, USER, CONTEXT):
            self.setup_defaults()
            with Transaction().set_context({
                'magento_instance': self.instance1.id,
                'magento_store_view': self.store_view.id,
                'magento_website': self.website1.id,
            }):

                MagentoOrderState.create_all_using_magento_data(
                    load_json('order-states', 'all'),
                )

                category_tree = load_json('categories', 'category_tree')
                Category.create_tree_using_magento_data(category_tree)

                order_data = load_json('orders', '300000001')

                with patch(
                        'magento.Customer', mock_customer_api(), create=True):
                    self.Party.find_or_create_using_magento_id(
                        order_data['customer_id']
                    )

                with Transaction().set_context({'company': self.company.id}):
                    # Create sale order using magento data
                    with patch(
                        'magento.Product', mock_product_api(), create=True
                    ):
                        Sale.find_or_create_using_magento_data(order_data)

                # There should be a BoM for the bundle product
                product_template = \
                    ProductTemplate.find_or_create_using_magento_id(158)
                product = product_template.products[0]
                self.assertTrue(len(product.boms), 1)
                self.assertTrue(len(product.boms[0].bom.inputs), 2)

                order_data = load_json('orders', '300000001-a')

                # Create sale order using magento data
                with patch('magento.Product', mock_product_api(), create=True):
                    Sale.find_or_create_using_magento_data(order_data)

                # There should be a BoM for the bundle product
                product_template = \
                    ProductTemplate.find_or_create_using_magento_id(
                        158
                    )
                self.assertEqual(len(product.boms), 1)
                self.assertEqual(len(product.boms[0].bom.inputs), 2)
开发者ID:GauravButola,项目名称:trytond-magento,代码行数:60,代码来源:test_sale.py


示例16: test_0050_import_grouped_product

    def test_0050_import_grouped_product(self):
        """
        Test the import of a grouped product using magento data
        """
        Category = POOL.get('product.category')
        ProductTemplate = POOL.get('product.template')

        with Transaction().start(DB_NAME, USER, CONTEXT) as txn:
            self.setup_defaults()
            category_data = load_json('categories', 22)
            product_data = load_json('products', 54)
            with txn.set_context({
                'magento_instance': self.instance1,
                'magento_website': self.website1,
                'company': self.company,
            }):
                Category.create_using_magento_data(category_data)
                template = ProductTemplate.find_or_create_using_magento_data(
                    product_data
                )
                self.assertEqual(
                    template.category.magento_ids[0].magento_id, 22
                )
                self.assertEqual(
                    template.magento_product_type, 'grouped'
                )
开发者ID:vishu1993,项目名称:trytond-magento,代码行数:26,代码来源:test_product.py


示例17: test0030_get_variant_images

    def test0030_get_variant_images(self):
        """
        Test to get variant images.

        If boolean field use_template_images is true return images
        of product template else return images of variant
        """
        Product = POOL.get('product.product')
        StaticFolder = POOL.get("nereid.static.folder")
        StaticFile = POOL.get("nereid.static.file")

        with Transaction().start(DB_NAME, USER, CONTEXT):
            self.setup_defaults()

            folder, = StaticFolder.create([{
                'name': 'Test'
            }])
            file_buffer = buffer('test-content')
            file = StaticFile.create([{
                'name': 'test.png',
                'folder': folder.id,
                'file_binary': file_buffer
            }])[0]

            file1 = StaticFile.create([{
                'name': 'test1.png',
                'folder': folder.id,
                'file_binary': file_buffer
            }])[0]

            uom, = self.Uom.search([], limit=1)

            # creating product template
            product_template, = self.Template.create([{
                'name': 'test template',
                'category': self.category.id,
                'type': 'goods',
                'list_price': Decimal('10'),
                'cost_price': Decimal('5'),
                'default_uom': uom.id,
                'description': 'Description of template',
                'media': [('create', [{
                    'static_file': file.id,
                }])],
                'products': [('create', self.Template.default_products())]
            }])

            product, = product_template.products

            Product.write([product], {
                'media': [('create', [{
                    'static_file': file1.id,
                }])]
            })

            self.assertEqual(product.get_images()[0].id, file.id)
            Product.write([product], {
                'use_template_images': False,
            })
            self.assertEqual(product.get_images()[0].id, file1.id)
开发者ID:openlabs,项目名称:nereid-catalog,代码行数:60,代码来源:test_product.py


示例18: test0030_menuitem

    def test0030_menuitem(self):
        '''
        Test create menuitem for products
        '''
        self.Product = POOL.get('product.product')
        self.Template = POOL.get('product.template')
        with Transaction().start(DB_NAME, USER, context=CONTEXT):
            app = self.get_app()
            self.setup_defaults()
            uom, = self.Uom.search([], limit=1)

            template, = self.Template.create([{
                'name': 'TestProduct',
                'type': 'goods',
                'list_price': Decimal('100'),
                'cost_price': Decimal('100'),
                'default_uom': uom.id,
            }])
            product, = self.Product.create([{
                'template': template.id,
                'displayed_on_eshop': True,
                'uri': 'test-product',
            }])

            with app.test_request_context('/'):
                rv = product.get_menu_item(max_depth=10)

            self.assertEqual(rv['title'], product.name)
开发者ID:dkodnik,项目名称:nereid-webshop,代码行数:28,代码来源:test_website.py


示例19: _create_cheque_payment_method

    def _create_cheque_payment_method(self):
        """
        A helper function that creates the cheque gateway and assigns
        it to the websites.
        """
        PaymentGateway = POOL.get('payment_gateway.gateway')
        NereidWebsite = POOL.get('nereid.website')
        PaymentMethod = POOL.get('nereid.website.payment_method')
        Journal = POOL.get('account.journal')

        cash_journal, = Journal.search([
            ('name', '=', 'Cash')
        ])

        gateway = PaymentGateway(
            name='Offline Payment Methods',
            journal=cash_journal,
            provider='self',
            method='manual',
        )
        gateway.save()

        website, = NereidWebsite.search([])

        payment_method = PaymentMethod(
            name='Cheque',
            gateway=gateway,
            website=website
        )
        payment_method.save()
        return payment_method
开发者ID:fulfilio,项目名称:nereid-checkout,代码行数:31,代码来源:test_payment.py


示例20: test_0050_import_grouped_product

    def test_0050_import_grouped_product(self):
        """
        Test the import of a grouped product using magento data
        """
        Category = POOL.get('product.category')
        Product = POOL.get('product.product')

        with Transaction().start(DB_NAME, USER, CONTEXT) as txn:
            self.setup_defaults()
            category_data = load_json('categories', 22)
            product_data = load_json('products', 54)
            with txn.set_context({
                'current_channel': self.channel1.id,
                'company': self.company.id,
            }):
                Category.create_using_magento_data(category_data)
                product = Product.find_or_create_using_magento_data(
                    product_data
                )
                self.assertEqual(
                    product.category.magento_ids[0].magento_id, 22
                )
                self.assertEqual(
                    product.channel_listings[0].magento_product_type,
                    'grouped'
                )
开发者ID:usudaysingh,项目名称:trytond-magento,代码行数:26,代码来源:test_product.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

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