This question has been flagged
1 Reply
11751 Views

Hi,

Could someone help me to understand the following sentence for QWeb reports? I see what it does, I just do not understand how it works. What is widget, what is contact, what is fields, what is name, what is no_marger. And why that &quot?


<address t-field="o.partner_id" t-field-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: true}">

Thanks for sharing

Avatar
Discard
Best Answer

Hi @E.M

When you define the attribute t-field on a html node, not available for ("table", "tbody", "thead", "tfoot", "tr", "td", "li", "ul", "ol", "dl", "dt", "dd", "t"), you are saying that your t-field expression result could be modified by the values of t-field-options attribute that let you specify a number a dict items depending of every case but most important ones is the widget item that let you change the default field widget in qweb to render the field result, in your case the widget contact is assigned to the class openerp.addons.base.ir.ir_qweb.Contact that is the model 'ir.qweb.field.contact'. When you define the widget in the t-field-options dict string you are saying: Search for a model with the name prefixed with 'ir.qweb.field.' plus the t-field-options key widget value and use it to render the result of the t-field expression. In the case of the widget contact the implementation of the method record_to_html use the fields key to render the template 'contact' and in that template the 'no_marker' key is used.

That's the use of those t-field-options keys. The attribute t-field-options is a bag, a dict string that gets evaluated and passed to the default widget for the field type or for the widget option value and used to change the default render way of the field. In the case of the contact widget it operate over many2one values like o.partner_id you define it

Avatar
Discard
Author

Thanks Axel, and where is actually defined the "contact" widget? I understood that it is ir.qweb.field.contact, but how can you check what it actually does?

The contact template is located at:
/openerp/addons/base/ir/ir_qweb.xml