Odoo Help

Welcome!

This community 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.

0

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

By
Jack
on 7/3/13, 11:03 AM 838 views

Hiiii,

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

0
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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

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