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 add custom fields in fields_view_get

By
Python
on 7/25/14, 11:52 PM 1,230 views

Hi everyone,

i want to add custom field which i had created in ir.model.fields. my field are <field name="x_gh" /> and <field name="x_rrr" />.this code does'nt dispaly field those fields. Here is the code example: Please Help

 

 

def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
        result = super(project_requirement, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
        requirement_obj = self.pool.get('project.requirement')
        active_id = context.get('active_id', False)      
        if view_type == 'tree':          
            result['arch'] = '''
            <tree string="Requirement Tree">
                        <field name="parent_requirement_seq" readonly="True"/>
                        <field name="priority" modifiers="{}"/>
                        <field name="responsible" modifiers="{}"/>
                        <field name="x_gh" />

                        <field name="x_rrr" />
                    </tree>'''

        if view_type == 'form':
            result['arch'] = '''
                <form string="Requirement Form" version="8.0">
                    <header>
                        <button name="fields_view_get" String="Fields view get" type="object" class="oe_highlight" />
                    </header>
                    <sheet>
                        <div class="oe_title">
                            <h1>
                                <label for="" string="Requirements " />
                            </h1>
                        </div>
                        <group>
                            <group>                                                              
                                <field name="priority" widget="select"/>
                                <field name="responsible" widget="select"/>

                                 <field name="x_rrr" />

                                <field name="x_gh" />
                            </group>                       

                       </group>
                    </sheet>
                </form>
            '''

        return result

 

Did you try to add the field in result['fields']?

Sajad KK
on 7/26/14, 12:12 AM

Thanks sajad,,, i got by changing my fuction like this: result['fields'].update({"x_gh": {'string': 'x_GH By', 'type': 'char'}}) Cheers...

Python
on 7/26/14, 1:19 AM
0
Sajad KK
On 7/26/14, 12:44 AM

Try this,

result['fields'].update({"x_gh": {'string': 'x_GH By', 'type': 'char'}})

 

 

 

 

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

2 follower(s)

Stats

Asked: 7/25/14, 11:52 PM
Seen: 1230 times
Last updated: 3/16/15, 8:10 AM