Odoo Help


How to create field with dynamic label name????

on 7/3/13, 11:03 AM 1,007 views


I select "March" we get 31 days in sequence like 1,2,3,4..........31 with their respective 'days' like Mon,Tue.....Sun . Now 31 field should be created with Label name Mon 1 June,Tue 2 June etc.......

This should happen with all 12 month.

Thanks Jack

Roel Zantinge
On 11/10/15, 6:25 AM

this is rather tricky to do via the XML files.

More effective is to overwrite fields_view_get method (tested for OE 7.0), like so:

def fields_view_get(self, cr, uid, view_id=None, view_type=None,
context=None, toolbar=False, submenu=False):
overwriting to set dynamic label on the field reading_normal.

    res = super(meter_reading_electricity, self).fields_view_get(
                       cr, uid, view_id=view_id, view_type=view_type,
    context=context, toolbar=toolbar, submenu=submenu)
    if view_type == 'form':
        doc = etree.XML(res['arch'])

        nodes = doc.xpath("//field[@name='reading_normal']")
        nodes[0].set('string', 'My dynamic label')

        res['arch'] = etree.tostring(doc)
    return res

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 7/3/13, 11:03 AM
Seen: 1007 times
Last updated: 11/10/15, 6:30 AM