[IMP] qweb: add many2many qweb widget

Instead of looping on x2m values in the qweb report, this new widget will
automatically render the x2m values for you (separeted with a comma).
This commit is contained in:
Christophe Matthieu
2018-08-13 17:09:28 +02:00
parent 14176015f5
commit acbcf36db4
+12
View File
@@ -301,6 +301,18 @@ class ManyToOneConverter(models.AbstractModel):
return nl2br(html_escape(value, options)) if value else ''
class ManyToManyConverter(models.AbstractModel):
_name = 'ir.qweb.field.many2many'
_inherit = 'ir.qweb.field'
@api.model
def value_to_html(self, value, options):
if not value:
return False
text = ', '.join(value.sudo().mapped('display_name'))
return nl2br(html_escape(text, options))
class HTMLConverter(models.AbstractModel):
_name = 'ir.qweb.field.html'
_inherit = 'ir.qweb.field'