【问题标题】:Odoo 9.0c: how to get the name of the current usser in sale order report qweb?Odoo 9.0c:如何在销售订单报告 qweb 中获取当前用户的姓名?
【发布时间】:2017-03-22 08:45:52
【问题描述】:

能否请你们帮我指出正确的方法来在重复的 qweb 报告上显示当前用户(直接打印报告的人,而不是创建报告的人)?此外,我的目的是在二维码表单下设置名称。这是我的代码:

                                                <div class="col-xs-3">
                                                    <img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('QR', o.name, 80, 80)" style="width:80px;height:80px;"/>
                                                    <img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('QR', o.user.name, 80, 80)" style="width:80px;height:80px;"/>
                                                </div>

然后我得到这个错误:

QWebException: "'sale.order' object has no attribute 'user'" while evaluating
"'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('QR', o.user.name, 80, 80)"

【问题讨论】:

    标签: report odoo-9 qweb


    【解决方案1】:

    您可以使用 user

    访问当前用户表单 qweb 报告
    <span t-esc="user.name"></span>
    

    目前的合作伙伴

    <span t-esc="user.partner_id.name"></span>
    

    看看 odoo 9 报告documentation

    【讨论】:

    • 感谢回复,其实我已经尝试在二维码表单下获取当前用户名,访问“user.name”时系统返回错误。更新问题,您可以看到我的代码并按照错误提示。
    • @tuấnanhphạm 对象是一个实例 od sale.order,您需要在我的用户中使用准确的代码。
    • 哦,感谢您分享您的知识,让我先尝试一下,然后我会返回反馈。祝你有美好的一天,朋友。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多