コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
5290 ビュー

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
8362
1
9月 23
2528
2
3月 22
6355
1
11月 19
7127
1
3月 19
4307