Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
2424 Vistas

Hi,


I have a treeview with a button column. 

How can I add a header title to that column? String doesn't seem to work...



My code:

Python:
ck = fields.Boolean(string='Checked', default=False, compute='_compute_ck')

XML:
≤tree string="Ordem de Compra"≥
​≤field name="name" readonly="1"/≥
≤field name="partner_id" readonly="1"/≥
≤field name="z_data_oc" readonly="1"/≥
≤field name="ck" invisible="1"/≥
≤button string="Checked" icon="fa-check" attrs="{'invisible': [('ck', '=', False)]}"/≥
≤field name="amount_total" readonly="1"/≥
≤/tree≥


-------------------------------------------------------------------
Edit: Tried S.M Firoz Ahmed's solution
------------------------------------------------------------------- Colspan did not work. Maybe I'm doing something wrong. My code:



Result:





Avatar
Descartar
Mejor respuesta

To add a header title to a column in a tree view in Odoo, you can use the string attribute for the field element in the XML. In your case, you need to specify the string attribute for the field element corresponding to the "ck" field:



This will add the "Checked" title to the corresponding column in the tree view.

You can also use the colspan attribute to merge multiple columns under one title, for example:



This will merge the columns of "ck" and the next column, and display the "Checked" title above the merged columns.

Note that the invisible attribute is used to make the column invisible but it still present in the tree view. If you want to completely remove the column from the tree view, you should remove the corresponding field element from the XML.

Avatar
Descartar
Autor

Colspan did not work. I have edited my post to add images.
Could you please check the last part of my original post?