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


Python Pool.get_source方法代码示例

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


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

示例1: get_visit_str

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import get_source [as 别名]
    def get_visit_str(self, ids):
        """Visit field string, eventually containg a tier phone number"""
        visit = dict(ItemsSheet.visit.selection)[self.visit]
        Translation = Pool().get('ir.translation')
        language = Transaction().language
        visit = Translation.get_source(self.__name__ + ',' + 'visit', 'selection',
                                       language, visit)

        if self.visit in ['RANGER', 'AGENT']:
            visit += '%s Tel: %s' % (self.visit_party.name, self.visit_party.phone)
        return visit
开发者ID:silpol,项目名称:tryton-bef,代码行数:13,代码来源:items_sheet.py

示例2: _get_aliases

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import get_source [as 别名]
 def _get_aliases(cls, model_name):
     """Returns the list of column aliases: for each field the wfs column get
     the field's label as an alias"""
     Model = Pool().get(model_name)
     Translation = Pool().get('ir.translation')
     aliases = ''
     for no, field in enumerate(Model._fields):
         if field in TRYTON_TO_QGIS:
             continue
         field = getattr(Model, field)
         title_src = field.string
         if Transaction().language != 'en_US':
             name = '%s,%s' % (model_name, field.name)
             title = Translation.get_source(name, 'field', Transaction().language, title_src)
             if title is None:
                 title = title_src
         else:
             title = title_src
         aliases += '<alias field="%s" index="%i" name="%s"/>' % (field.name, no, title)
     return aliases
开发者ID:silpol,项目名称:tryton-bef,代码行数:22,代码来源:qgis.py

示例3: raise_user_error

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import get_source [as 别名]
    def raise_user_error(cls, error, error_args=None,
            error_description='', error_description_args=None,
            raise_exception=True):
        '''
        Raise an exception that will be displayed as an error message
        in the client.

        :param error: the key of the dictionary _error_messages used
            for error message
        :param error_args: the arguments that will be used
            for "%"-based substitution
        :param error_description: the key of the dictionary
            _error_messages used for error description
        :param error_description_args: the arguments that will be used
            for "%"-based substitution
        :param raise_exception: if set to False return the error string
            (or tuple if error_description is not empty) instead of raising an
            exception.
        '''
        Translation = Pool().get('ir.translation')

        error = cls._error_messages.get(error, error)

        language = Transaction().language
        res = Translation.get_source(cls.__name__, 'error', language, error)
        if not res:
            res = Translation.get_source(error, 'error', language)
        if res:
            error = res

        if error_args is not None:
            try:
                error = error % error_args
            except TypeError:
                pass

        if error_description:
            error_description = cls._error_messages.get(error_description,
                    error_description)

            res = Translation.get_source(cls.__name__, 'error', language,
                error_description)
            if not res:
                res = Translation.get_source(error_description, 'error',
                    language)
            if res:
                error_description = res

            if error_description_args:
                try:
                    error_description = (error_description
                        % error_description_args)
                except TypeError:
                    pass
            if raise_exception:
                raise UserError(error, error_description)
            else:
                return (error, error_description)
        if raise_exception:
            raise UserError(error)
        else:
            return error
开发者ID:coopengo,项目名称:trytond,代码行数:64,代码来源:error.py


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