[IMP] web: Add support of js_class attribute for qweb views

Task 2119567
This commit is contained in:
Lucas Lefèvre
2020-01-21 13:16:58 +01:00
parent 8b89f63d2c
commit 3519b9872e
+5 -2
View File
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import babel.dates
import pytz
from lxml import etree
from odoo import _, api, fields, models
from odoo.osv.expression import AND
@@ -202,9 +203,11 @@ class Base(models.AbstractModel):
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
r = super().fields_view_get(view_id, view_type, toolbar, submenu)
# avoid leaking the raw (un-rendered) template, also avoids bloating
# the response payload for no reason
# the response payload for no reason. Only send the root node,
# to send attributes such as `js_class`.
if r['type'] == 'qweb':
r['arch'] = '<qweb/>'
root = etree.fromstring(r['arch'])
r['arch'] = etree.tostring(etree.Element('qweb', root.attrib))
return r
@api.model