本文整理汇总了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
示例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
示例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