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

Python pool.Pool类代码示例

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

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



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

示例1: origin_name

 def origin_name(self):
     pool = Pool()
     SaleLine = pool.get('sale.line')
     name = super(Move, self).origin_name
     if isinstance(self.origin, SaleLine):
         name = self.origin.sale.rec_name
     return name
开发者ID:kret0s,项目名称:gnuhealth-live,代码行数:7,代码来源:stock.py


示例2: do_open

    def do_open(self, action):
        pool = Pool()
        Product = pool.get('product.product')
        Lang = pool.get('ir.lang')

        context = {}
        product_id = Transaction().context['active_id']
        context['product'] = product_id
        if self.start.forecast_date:
            context['stock_date_end'] = self.start.forecast_date
        else:
            context['stock_date_end'] = datetime.date.max
        action['pyson_context'] = PYSONEncoder().encode(context)
        product = Product(product_id)

        for code in [Transaction().language, 'en_US']:
            langs = Lang.search([
                    ('code', '=', code),
                    ])
            if langs:
                break
        lang, = langs
        date = Lang.strftime(context['stock_date_end'],
            lang.code, lang.date)

        action['name'] += ' - %s (%s) @ %s' % (product.rec_name,
            product.default_uom.rec_name, date)
        return action, {}
开发者ID:silpol,项目名称:tryton-bef,代码行数:28,代码来源:product.py


示例3: default_warehouse

 def default_warehouse():
     Location = Pool().get('stock.location')
     warehouses = Location.search([
             ('type', '=', 'warehouse'),
             ])
     if len(warehouses) == 1:
         return warehouses[0].id
开发者ID:silpol,项目名称:tryton-bef,代码行数:7,代码来源:product.py


示例4: _get_invoice

    def _get_invoice(self):
        "Return invoice for the work"
        pool = Pool()
        Invoice = pool.get('account.invoice')
        Journal = pool.get('account.journal')

        journals = Journal.search([
                ('type', '=', 'revenue'),
                ], limit=1)
        if journals:
            journal, = journals
        else:
            journal = None

        if not self.party:
            self.raise_user_error('missing_party', (self.rec_name,))

        with Transaction().set_user(0, set_context=True):
            return Invoice(
                company=self.company,
                type='out_invoice',
                journal=journal,
                party=self.party,
                invoice_address=self.party.address_get(type='invoice'),
                currency=self.company.currency,
                account=self.party.account_receivable,
                payment_term=self.party.customer_payment_term,
                description=self.work.name,
                )
开发者ID:silpol,项目名称:tryton-bef,代码行数:29,代码来源:work.py


示例5: do_open

    def do_open(self, action):
        pool = Pool()
        Location = pool.get('stock.location')
        Lang = pool.get('ir.lang')

        context = {}
        context['locations'] = Transaction().context.get('active_ids')
        date = self.start.forecast_date or datetime.date.max
        context['stock_date_end'] = Date(date.year, date.month, date.day)
        action['pyson_context'] = PYSONEncoder().encode(context)

        locations = Location.browse(context['locations'])

        for code in [Transaction().language, 'en_US']:
            langs = Lang.search([
                    ('code', '=', code),
                    ])
            if langs:
                break
        lang = langs[0]
        date = Lang.strftime(date, lang.code, lang.date)

        action['name'] += ' - (%s) @ %s' % (
            ','.join(l.name for l in locations), date)
        return action, {}
开发者ID:aleibrecht,项目名称:tryton-modules-ar,代码行数:25,代码来源:location.py


示例6: create_period

 def create_period(cls, fiscalyears, interval=1):
     '''
     Create periods for the fiscal years with month interval
     '''
     Period = Pool().get('account.period')
     to_create = []
     for fiscalyear in fiscalyears:
         period_start_date = fiscalyear.start_date
         while period_start_date < fiscalyear.end_date:
             period_end_date = period_start_date + \
                 relativedelta(months=interval - 1) + \
                 relativedelta(day=31)
             if period_end_date > fiscalyear.end_date:
                 period_end_date = fiscalyear.end_date
             name = datetime_strftime(period_start_date, '%Y-%m')
             if name != datetime_strftime(period_end_date, '%Y-%m'):
                 name += ' - ' + datetime_strftime(period_end_date, '%Y-%m')
             to_create.append({
                 'name': name,
                 'start_date': period_start_date,
                 'end_date': period_end_date,
                 'fiscalyear': fiscalyear.id,
                 'type': 'standard',
                 })
             period_start_date = period_end_date + relativedelta(days=1)
     if to_create:
         Period.create(to_create)
开发者ID:Sisouvan,项目名称:ogh,代码行数:27,代码来源:fiscalyear.py


示例7: close

    def close(cls, fiscalyears):
        '''
        Close a fiscal year
        '''
        pool = Pool()
        Period = pool.get('account.period')
        Account = pool.get('account.account')

        for fiscalyear in fiscalyears:
            if cls.search([
                        ('end_date', '<=', fiscalyear.start_date),
                        ('state', '=', 'open'),
                        ('company', '=', fiscalyear.company.id),
                        ]):
                cls.raise_user_error('close_error', (fiscalyear.rec_name,))

            #First close the fiscalyear to be sure
            #it will not have new period created between.
            cls.write([fiscalyear], {
                'state': 'close',
                })
            periods = Period.search([
                    ('fiscalyear', '=', fiscalyear.id),
                    ])
            Period.close(periods)

            with Transaction().set_context(fiscalyear=fiscalyear.id,
                    date=None, cumulate=True):
                accounts = Account.search([
                        ('company', '=', fiscalyear.company.id),
                        ])
            for account in accounts:
                fiscalyear._process_account(account)
开发者ID:Sisouvan,项目名称:ogh,代码行数:33,代码来源:fiscalyear.py


示例8: get_origin

 def get_origin(cls):
     Model = Pool().get('ir.model')
     models = cls._get_origin()
     models = Model.search([
             ('model', 'in', models),
             ])
     return [(None, '')] + [(m.model, m.name) for m in models]
开发者ID:coopengo,项目名称:account_payment,代码行数:7,代码来源:payment.py


示例9: do_process

    def do_process(self, action):
        pool = Pool()
        Payment = pool.get('account.payment')
        payments = Payment.browse(Transaction().context['active_ids'])

        for payment in payments:
            if payment.line and payment.line.payment_amount < 0:
                self.raise_user_warning(str(payment),
                    'overpay', {
                        'payment': payment.rec_name,
                        'line': payment.line.rec_name,
                        })

        groups = []
        payments = sorted(payments, key=self._group_payment_key)
        for key, grouped_payments in groupby(payments,
                key=self._group_payment_key):
            def group():
                group = self._new_group(dict(key))
                group.save()
                groups.append(group)
                return group
            Payment.process(list(grouped_payments), group)

        return action, {
            'res_id': [g.id for g in groups],
            }
开发者ID:coopengo,项目名称:account_payment,代码行数:27,代码来源:payment.py


示例10: get_sale_price

    def get_sale_price(self):
        """Estimates the shipment rate for the current shipment

        The get_sale_price implementation by tryton's carrier module
        returns a tuple of (value, currency_id)

        :returns: A tuple of (value, currency_id which in this case is USD)
        """
        Sale = Pool().get('sale.sale')
        Shipment = Pool().get('stock.shipment.out')
        Currency = Pool().get('currency.currency')

        shipment_id = Transaction().context.get('shipment')
        sale_id = Transaction().context.get('sale')
        default_currency, = Currency.search([('code', '=', 'USD')])

        if Transaction().context.get('ignore_carrier_computation'):
            return Decimal('0'), default_currency.id
        if not (sale_id or shipment_id):
            return Decimal('0'), default_currency.id

        if self.carrier_cost_method != 'ups':
            return super(Carrier, self).get_sale_price()

        if sale_id:
            return Sale(sale_id).get_ups_shipping_cost()

        if shipment_id and shipment_id > 0:
            # get_ups_shipping_cost must not be called if shipment is not saved.
            # If shipment is saved/active record is created properly,
            # then the ID must be a positive integer.
            return Shipment(shipment_id).get_ups_shipping_cost()

        return Decimal('0'), default_currency.id
开发者ID:PritishC,项目名称:trytond-shipping-ups,代码行数:34,代码来源:carrier.py


示例11: get_context

    def get_context(cls, objects, data):
        Product = Pool().get('product.product')
        Locations = Pool().get('stock.location')

        report_context = super(ProductLedgerReport, cls).get_context(
            objects, data
        )
        records = []
        summary = {}
        for product_id in data['products']:
            product = Product(product_id)
            record = {
                'product': product,
                'purchases': cls.get_purchases(product.id, data),
                'productions': cls.get_productions(product.id, data),
                'customers': cls.get_customers(product.id, data),
                'lost_and_founds': cls.get_lost_and_founds(product.id, data),
                'consumed': cls.get_consumed(product.id, data)
            }
            records.append(record)
            summary[product] = cls.get_summary(record, data)

        report_context['summary'] = summary
        report_context['warehouses'] = Locations.browse(data['warehouses'])
        return report_context
开发者ID:fulfilio,项目名称:trytond-report-html-stock,代码行数:25,代码来源:report_html_stock.py


示例12: nereid_add_payment_profile

    def nereid_add_payment_profile(cls):
        """
        Add card to user profile.
        """
        AddPaymentProfileWizard = Pool().get(
            'party.party.payment_profile.add', type='wizard'
        )
        Address = Pool().get('party.address')

        gateway = request.nereid_website.credit_card_gateway
        form = PaymentProfileForm()

        if form.validate_on_submit():
            profile_wiz = AddPaymentProfileWizard(
                AddPaymentProfileWizard.create()[0]
            )
            profile_wiz.card_info.party = current_user.party
            profile_wiz.card_info.address = Address(form.address.data)
            profile_wiz.card_info.provider = gateway.provider
            profile_wiz.card_info.gateway = gateway
            profile_wiz.card_info.owner = form.owner.data
            profile_wiz.card_info.number = form.number.data
            profile_wiz.card_info.expiry_month = form.expiry_month.data
            profile_wiz.card_info.expiry_year = \
                unicode(form.expiry_year.data)
            profile_wiz.card_info.csc = form.cvv.data

            try:
                profile_wiz.transition_add()
                flash(_('Credit Card added successfully!'))
            except UserError, e:  # pragma: no cover
                flash(_(e.message))
            finally:
开发者ID:2cadz,项目名称:nereid-payment-gateway,代码行数:33,代码来源:party.py


示例13: read

    def read(cls, ids, fields_names=None):
        res = super(View, cls).read(ids, fields_names=fields_names)

        if Transaction().user == 0:
            return res

        pool = Pool()
        action = pool.get('ir.action')
        ids_action = action.search([('name', '=', 'Surface Terriere'),
                ('type', '=', 'ir.action.act_window')])

        assert(len(ids_action) == 1), len(ids_action)

        #act_window = pool.get('ir.action.act_window')
        #ids_act_window = act_window.search([('action', '=', ids_action[0])])

        dynamic_view_id = cls.dynamic_view_id()
        if not dynamic_view_id:
            # Restart the cache
            cls._dynamic_view_cache.reset()

        #print "dview"
        if fields_names is None \
                or 'arch' in fields_names:
            #print ids, dynamic_view_id
            if dynamic_view_id in ids:
                for res2 in res:
                    if res2['id'] == dynamic_view_id:
                        #print "dview2"
                        res2['arch'] ='<board string="Comparaison surfaces terrieres"><action name="6100"/></board>'
        #from pprint import pprint
        #print "pprint psdrf"
        #pprint(Transaction().context)
        #pprint(res)
        return res
开发者ID:silpol,项目名称:tryton-bef,代码行数:35,代码来源:reports.py


示例14: write

    def write(cls, *args):
        pool = Pool()
        Sale = pool.get('sale.sale')
        SaleLine = pool.get('sale.line')

        super(ShipmentOutReturn, cls).write(*args)

        actions = iter(args)
        for shipments, values in zip(actions, actions):
            if values.get('state') != 'received':
                continue
            sales = []
            move_ids = []
            for shipment in shipments:
                move_ids.extend([x.id for x in shipment.incoming_moves])

            with Transaction().set_context(_check_access=False):
                sale_lines = SaleLine.search([
                        ('moves', 'in', move_ids),
                        ])
                if sale_lines:
                    for sale_line in sale_lines:
                        if sale_line.sale not in sales:
                            sales.append(sale_line.sale)

                    sales = Sale.browse([s.id for s in sales])
                    Sale.process(sales)
开发者ID:kret0s,项目名称:gnuhealth-live,代码行数:27,代码来源:stock.py


示例15: test_integer

    def test_integer(self):
        'Test integer'
        pool = Pool()
        Integer = pool.get('test.import_data.integer')

        self.assertEqual(Integer.import_data(['integer'],
            [['1']]), 1)

        self.assertEqual(Integer.import_data(['integer'],
            [['-1']]), 1)

        self.assertEqual(Integer.import_data(['integer'],
            [['']]), 1)

        self.assertEqual(Integer.import_data(['integer'],
            [['1'], ['2']]), 2)

        self.assertRaises(ValueError, Integer.import_data,
            ['integer'], [['1.1']])

        self.assertRaises(ValueError, Integer.import_data,
            ['integer'], [['-1.1']])

        self.assertRaises(ValueError, Integer.import_data,
            ['integer'], [['foo']])

        self.assertEqual(Integer.import_data(['integer'],
            [['0']]), 1)
开发者ID:kret0s,项目名称:tryton3_8,代码行数:28,代码来源:test_importdata.py


示例16: transition_force

    def transition_force(self):
        pool = Pool()
        Production = pool.get('production')

        Production.assign_force(
            [Production(Transaction().context['active_id'])])
        return 'end'
开发者ID:silpol,项目名称:tryton-bef,代码行数:7,代码来源:production.py


示例17: test_integer_required

    def test_integer_required(self):
        'Test required integer'
        pool = Pool()
        IntegerRequired = pool.get('test.import_data.integer_required')
        transaction = Transaction()

        self.assertEqual(IntegerRequired.import_data(['integer'],
            [['1']]), 1)

        self.assertEqual(IntegerRequired.import_data(['integer'],
            [['-1']]), 1)

        self.assertRaises(UserError, IntegerRequired.import_data,
            ['integer'], [['']])
        transaction.cursor.rollback()

        self.assertEqual(IntegerRequired.import_data(['integer'],
            [['1'], ['2']]), 2)

        self.assertRaises(ValueError, IntegerRequired.import_data,
            ['integer'], [['1.1']])

        self.assertRaises(ValueError, IntegerRequired.import_data,
            ['integer'], [['-1.1']])

        self.assertRaises(ValueError, IntegerRequired.import_data,
            ['integer'], [['foo']])

        self.assertEqual(IntegerRequired.import_data(['integer'],
            [['0']]), 1)
开发者ID:kret0s,项目名称:tryton3_8,代码行数:30,代码来源:test_importdata.py


示例18: test_float

    def test_float(self):
        'Test float'
        pool = Pool()
        Float = pool.get('test.import_data.float')

        self.assertEqual(Float.import_data(['float'],
            [['1.1']]), 1)

        self.assertEqual(Float.import_data(['float'],
            [['-1.1']]), 1)

        self.assertEqual(Float.import_data(['float'],
            [['1']]), 1)

        self.assertEqual(Float.import_data(['float'],
            [['']]), 1)

        self.assertEqual(Float.import_data(['float'],
            [['1.1'], ['2.2']]), 2)

        self.assertRaises(ValueError, Float.import_data,
            ['float'], [['foo']])

        self.assertEqual(Float.import_data(['float'],
            [['0']]), 1)

        self.assertEqual(Float.import_data(['float'],
            [['0.0']]), 1)
开发者ID:kret0s,项目名称:tryton3_8,代码行数:28,代码来源:test_importdata.py


示例19: find

    def find(cls, company_id, date=None, exception=True):
        '''
        Return the fiscal year for the company_id
            at the date or the current date.
        If exception is set the function will raise an exception
            if any fiscal year is found.
        '''
        pool = Pool()
        Lang = pool.get('ir.lang')
        Date = pool.get('ir.date')

        if not date:
            date = Date.today()
        fiscalyears = cls.search([
            ('start_date', '<=', date),
            ('end_date', '>=', date),
            ('company', '=', company_id),
            ], order=[('start_date', 'DESC')], limit=1)
        if not fiscalyears:
            if exception:
                language = Transaction().language
                languages = Lang.search([('code', '=', language)])
                if not languages:
                    languages = Lang.search([('code', '=', 'en_US')])
                language, = languages
                formatted = Lang.strftime(date, language.code, language.date)
                cls.raise_user_error('no_fiscalyear_date', (formatted,))
            else:
                return None
        return fiscalyears[0].id
开发者ID:Sisouvan,项目名称:ogh,代码行数:30,代码来源:fiscalyear.py


示例20: test_float_required

    def test_float_required(self):
        'Test required float'
        pool = Pool()
        FloatRequired = pool.get('test.import_data.float_required')
        transaction = Transaction()

        self.assertEqual(FloatRequired.import_data(['float'],
            [['1.1']]), 1)

        self.assertEqual(FloatRequired.import_data(['float'],
            [['-1.1']]), 1)

        self.assertEqual(FloatRequired.import_data(['float'],
            [['1']]), 1)

        self.assertRaises(UserError, FloatRequired.import_data,
            ['float'], [['']])
        transaction.cursor.rollback()

        self.assertEqual(FloatRequired.import_data(['float'],
            [['1.1'], ['2.2']]), 2)

        self.assertRaises(ValueError, FloatRequired.import_data,
            ['float'], [['foo']])

        self.assertEqual(FloatRequired.import_data(['float'],
            [['0']]), 1)

        self.assertEqual(FloatRequired.import_data(['float'],
            [['0.0']]), 1)
开发者ID:kret0s,项目名称:tryton3_8,代码行数:30,代码来源:test_importdata.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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