如何在qweb报告中显示字段标签?

时间:2018-11-09 15:13:37

标签: odoo odoo-8 qweb

有没有一种方法可以显示我们在qweb报告中的字段上粘贴的标签?

例如

在我的.py

findings = fields.Text(string="Findings")

在我的.xml中

<t t-esc="findings" /> <!-- only shows the value -->

我们还能在qweb中获得标签吗?

2 个答案:

答案 0 :(得分:1)

您可以使用函数来获取字段描述(标签),但我建议您像在odoo invoice reports中那样显示标签。

要获取date_invoice标签:

def get_field_label(self, model_name, field_name):
    ir_model_obj = self.env['ir.model']
    ir_model_fields_obj = self.env['ir.model.fields']
    model_id = ir_model_obj.search([('model', '=', model_name)], limit=1)
    field_id = ir_model_fields_obj.search([('name', '=', field_name), ('model_id', '=', model_id.id)], limit=1)

    return field_id.field_description

答案 1 :(得分:0)

您无法获取该字段的标签。 相反,您可以添加 html 标签以显示标签

例如:

<p>Your Label <t t-esc="findings" /> </p>

 or
<span> Some Text <t t-esc="findings" /> </span>