ir_qweb.py 文件源码

python
阅读 54 收藏 0 点赞 0 评论 0

项目:gooderp_org 作者: osbzr 项目源码 文件源码
def record_to_html(self, cr, uid, field_name, record, options=None, context=None):
        if options is None: options = {}
        aclasses = ['img', 'img-responsive'] + options.get('class', '').split()
        classes = ' '.join(itertools.imap(escape, aclasses))

        max_size = None
        max_width, max_height = options.get('max_width', 0), options.get('max_height', 0)
        if max_width or max_height:
            max_size = '%sx%s' % (max_width, max_height)

        src = self.pool['website'].image_url(cr, uid, record, field_name, max_size)
        alt = None
        if options.get('alt-field') and getattr(record, options['alt-field'], None):
            alt = record[options['alt-field']]
        elif options.get('alt'):
            alt = options['alt']
        img = '<img class="%s" src="%s" style="%s"%s/>' % (classes, src, options.get('style', ''), ' alt="%s"' % alt if alt else '')
        return ir_qweb.HTMLSafe(img)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号