hi, im doing a many2one relation i can show the name of the relation field(foreign key) but i retrieve onlu its id, how can i retrieve other fields?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
You can use rec_name for retrieving a single value. But if u want to display more than one field means go for name_get method
def name_get(self, cr, uid, ids, context=None):
res = []
for obj in self.browse(cr, uid, ids, context=context):
var = obj.name +"Email("+obj.email+")"
res.append((obj.id, var))
return res
Use the above method in your parent class and simply call that class on your manytoone relational field.
Syntax of name_get orm method
name_get(cr, user, ids, context=None)
Parameters:
cr -- database cursor
user (integer) -- current user id
ids -- list of ids
context (dictionary) -- context arguments, like lang, time zone
Returns:
tuples with the text representation of requested objects for to-many relationships
but th field i would like to retrive is not in the same class
I have updated answer.. Check it...
please if im retrieving well the id how can access other fields?i must pass by sql queries?
Use browse method. It will give you the entire fields in other object as well as same object. If u already have ids and want to access particular field means use search orm method.
Check many2one relation table "name" column is available. It shows "name" column value in many2one selection or add the below code in python file
rec_name = "fieldname"
Here after its shows rec_name field value shows in many2one selection.
using browse ORM method you can access all other fields.
Example:-
def meth_name(self, cr, uid, ids, context=None):
table_obj = self.pool.get('table.name')
for val in table_obj.browse(cr, uid, ids, context=context):
field1_value = val.column1
field2_value = val.column2
return field1_value
i doing this right and it shows me the field i need,but how to access to other fields????
updated the sample code to access other fields.