2017-07-14 17 views
5

क्या यह संभव है कि पेड़ दृश्य में एचटीएमएल प्रदर्शित हो?पेड़ दृश्य odoo में एचटीएमएल प्रदर्शित करें

उदाहरण के लिए स्ट्रिंग के लिए मजबूत जोड़ने < strong> मेरे STRING </strong>

मैं कोशिश उपयोग विजेट = "html" लेकिन मजबूत टैग दिख रहा है!

.py

@api.depends('name') 
def _get_html(self): 
    self.html_text = "<strong>" + str(self.name) + "</strong>" 

    html_text = fields.Char(compute='_get_html') 

.xml

<field name="html_text"/> 
+2

आप प्रश्न में अपने ट्री दृश्य जोड़ सकते हैं? –

+2

@VikiChavada मैं अपना उदाहरण जोड़ रहा हूँ! –

उत्तर

7

सूची दृश्य में एचटीएमएल सक्षम करने के लिए आप (Odoo v10 के लिए) के रूप में नीचे) विधि _format (ओवरराइड करने के लिए की जरूरत है।

जेएस

odoo.define('html_in_tree_field.web_ext', function (require) { 
    "use strict"; 
    var Listview = require('web.ListView'); 
    var formats = require('web.formats'); 

    Listview.Column.include({ 
     _format: function (row_data, options) { 
     // Removed _.escape() function to display html content. 
     // Before : return _.escape(formats.format_value(row_data[this.id].value, this, options.value_if_empty)); 
     return formats.format_value(row_data[this.id].value, this, options.value_if_empty); 
     } 
    }); 
}); 
जेएस के ऊपर जोड़ने के लिए

एक्सएमएल।

<?xml version="1.0" encoding="utf-8"?> 
<odoo> 
    <template id="assets_ext" inherit_id="web.assets_backend"> 
     <xpath expr="." position="inside"> 
      <script type="text/javascript" src="/html_in_tree_field/static/src/js/web_ext.js"></script> 
     </xpath> 
    </template> 
</odoo> 

__manifest__.py

{ 
... 
... 
'data': [ 
     ... 
     'views/above_xml_filename.xml', 
    ], 
.... 
} 
संबंधित मुद्दे