There's more...

There are a few more helper functions worth mentioning. If you need to generate a pseudo-random color for an element, use the kanban_color(some_variable) function, which will return a CSS class that sets the background and color properties. This is usually used in the t-att-class elements.

If you want to display an image stored in a binary field, use kanban_image(modelname, fieldname, record.id.raw_value), which returns a data URI if you included the field in your fields list and the field is set, a placeholder if the field is not set, or a URL that makes Odoo stream the field's contents if you didn't include the field in your fields list. Do not include the field in the fields list if you need to display a lot of records simultaneously or you expect very big images. Usually, you'd use this in a t-att-src attribute of an img element.

Doing design in kanban views can be a bit annoying. What often works better is generating HTML using a function field of the HTML type, and generating this HTML from a Qweb view. This way, you're still doing QWeb, but on the server side, which is a lot more convenient when you need to work on a lot of data.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset