有没有一种方法可以显示我们在qweb报告中的字段上粘贴的标签?
例如
在我的.py
中findings = fields.Text(string="Findings")
在我的.xml中
<t t-esc="findings" /> <!-- only shows the value -->
我们还能在qweb中获得标签吗?
答案 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>