Skip to Content
Menu
This question has been flagged
1 Reply
6496 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

 

Avatar
Discard

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

Author

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

Best Answer

Try this,

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

 

 

 

 

Avatar
Discard