Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
5291 Ansichten

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? 

Avatar
Verwerfen
Beste Antwort

Hi,

have you find the solution? Same question..

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Sept. 23
8363
1
Sept. 23
2530
2
März 22
6356
1
Nov. 19
7127
1
März 19
4307