跳至內容
選單
此問題已被標幟
1 回覆
5317 瀏覽次數

Our module has code like this: 

class product_product(osv.osv):
    _inherit = "product.product"
    _name = 'product.product'

    def _jdescription(self, cr, uid, ids, fields, arg, context=None):
        result = {}
        for record in self.browse(cr, uid, ids, context=context):
            print record.code, record.lst_price, record.serialized_description
            if record.serialized_description:
                json = simplejson.loads(record.serialized_description)
                print json
                l = ''
                for k, v in json.iteritems():
                    if v:
                        l += "<dt>%s</dt><dd>%s</dd>" % (k, v)
                description_list = "<dl>%s</dl>" % l
                result[record.id] = description_list
        return result

    _columns = {
        'serialized_description': fields.text('Description', type="text"),
        'jdescription': fields.function(_jdescription, type="text"),
    }

We insert jdesription in product_view.xml like this: 

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="product_normal_form_view" model="ir.ui.view">
            <field name="name">product.normal.form.inherit</field>
            <field name="model">product.product</field>
            <field name="priority">5</field>
            <field name="inherit_id" ref="product.product_normal_form_view"/>
            <field name="arch" type="xml">
                <notebook position="inside">
                    <page string="Description">
                        <field name='jdescription' />
                    </page>
                </notebook>
            </field>
        </record> 
  </data>
</openerp>

 

Html of course returns to client escaped. So we have following questions: 

1) Are there any kind of forloop built in openerp views?

2) Are there any way to turn off html escape for field? 

3) What is ERP way to view serialized data? 

頭像
捨棄
最佳答案

Hi,

have you find the solution? Same question..

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
9月 23
8418
1
9月 23
2575
2
3月 22
6419
1
11月 19
7179
1
3月 19
4344