Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
5293 Zobrazení

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
Zrušit
Nejlepší odpověď

Hi,

have you find the solution? Same question..

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
zář 23
8367
1
zář 23
2531
2
bře 22
6358
1
lis 19
7128
1
bře 19
4308