How to use a many2one field to display two fields together in OpenERP (odoo)? -


I have a column where I currently have a many2one The field is the name of the employee of another class. The thing is that I just need more than the name, I will bring the name + last name .

I understand that I have to use the function field , but I do not understand where the new functions are where the values ​​are to be seen.

If anyone can point me in the document or a similar example, I really appreciate it.

Thanks

You can use it to get the 'name_get' method You can. Self.browse (cr, uid, id, context = context) to record result = {}: result

  def name_get (self, cr, uid, id, context = none): result [Record.id] = record.name + "" + record.lastname Return Results. Items ()  

The following is just one example:

A model 'sale .order ", there are several models in the form of a 'postpost'. Suppose that you want to display that partner's 'First name' and 'Last name' on those pages.

So for that you have to write your code in the 'Resp Poster' and not 'Sales'. In the 'Order' model

Here is the code in the 'res.partner' model.

  class res_partner_extention (osv.osv): _inherit = 'res.partner' def name_get (auto, cr, uid, id, context = none): self Results for partners in Broaus (CR, UID, ID, Context = Reference) = {}: Results [partner.id] = partner.name + "+ + partner.lastname return result.teams ()  

So now, when you try to look at the partner field in 'sale.order', when you click on that many page partner fields, it will also give you the 'last name' as 'first name' So you do not need to do anything to the 'sale.order' model nor do you need to have an area in the form of a 'field.function' Must be defined.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -