跳至内容
菜单
此问题已终结
8 回复
14001 查看

Hy,

I succeeded in displaying html in text field thanks to the widget="html" in the fomr view of order lines Is it possible to do as well in the tree view? Using type="html" nor widget="html" failed.

Thanks in advanced

形象
丢弃
编写者

I tried this one without success : https://www.openerp.com/apps/6.1/trp_web_treeview_html_widget/ No error is displayed or thrown. Nothing special is done

编写者

Obviously not possible in v7

最佳答案

To enable the HTML in list view you need to override the method _format() as below.(for Odoo v10)


**JS**


    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 to add above JS.**


    <?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',

        ],

    ....

    }

形象
丢弃
最佳答案

Hello, you can find something here for v7 :


https://apps.odoo.com/apps/7.0/web_list_html_widget/

形象
丢弃
最佳答案

thanks for your answer, chavada viki. I faced with similar issue and it worked!

形象
丢弃
最佳答案

i am facing same issue. did you find any solution for this?

形象
丢弃

Did you find an answer for this? Would need this functionality as well.

Not Yet. but i find one alternate solution for this. i take one new text field. for form view i display field which has widget as html. and for tree view i display copied text field(display as normal text). did you get??