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

Custom modules output is not showing value, but it showing the id. How can i solve this?

By
rosey
on 8/30/13, 7:24 AM 709 views

__init__.py

import freight

__openerp__.py

{ 'name': 'Freight Information',

'category': 'General',

'version': '1.1',

'depends': ['base','web'],

'data': ['freight_view.xml'],    

'auto_install': False,

}

freight.py

from openerp.osv import fields, osv

class freight_freight(osv.osv):

_name = "freight.freight"    
_columns = {
    'source' : fields.many2one('source.source','Source',required=True), 
            'destination': fields.many2one('destination.destination','Destination',required=True),
    'cost' : fields.char('Charge', size=6, required=True),
           }

freight_freight()

freight_view.xml

<openerp>
<data>

    <record model = "ir.ui.view" id = "freight_search">
        <field name = "name"> freight.search </field>
        <field name = "model">freight.freight</field>           
        <field name = "arch" type = "xml"> 
        <search string = "Freight Search" version="7.0">                
            <field name = "source"/>
            <field name = "destination"/>   
            <field name = "cost"/>                  
        </search>
        </field>  
    </record>




    <record model = "ir.ui.view" id = "freight_tree">
        <field name = "name">freight.tree</field>
        <field name = "model">freight.freight</field>           
        <field name = "arch" type = "xml">
        <tree string = "Freight" version="7.0">                     
            <field name = "source"/>    
            <field name = "destination"/>   
            <field name = "cost"/>              
        </tree>
        </field>
    </record>


    <record model = "ir.ui.view" id = "freight_form">
        <field name = "name">freight.search.form</field>
        <field name = "model">freight.freight</field>           
        <field name = "arch" type = "xml">
        <form string = "Freight" version="7.0">             
            <field name = "source"/>
            <field name = "destination"/>
            <field name = "cost"/>
        </form>
        </field>
    </record>



    <record model = "ir.actions.act_window" id = "action_freight">
        <field name = "name">Freight Information</field>
        <field name = "res_model">freight.freight</field>
        <field name = "view_type">form</field>
        <field name = "view_mode">tree,form</field>
    </record>
</data>

</openerp>

Is there any error in my code?

In the source & destination many2one field, it shows like source.source,1... & destionation.destionation,1...

How can i solve this?

0

Grover Menacho

--Grover Menacho--
2523
| 5 7 8
La Paz, Bolivia
--Grover Menacho--

Systems Engineer + MBA

Grover Menacho
On 8/30/13, 11:03 AM

It's because system couldn't find a name into that models. Add this to your classes 'source.source' and 'destination.destination':

class destination_destination(osv.osv):
...
_rec_name='some_field'

When you are not adding a 'name' field to the model you have to add the above line because the system is going to look for name or _rec_name, if it finds the rec_name then it's going to display that value.

But is doesnt work. Still showing, destination.destination,1 etc

rosey
on 9/2/13, 3:24 AM

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: 8/30/13, 7:24 AM
Seen: 709 times
Last updated: 3/16/15, 8:10 AM