Skip to Content
Menu
This question has been flagged
2 Replies
1594 Views

I used (related) instead of onchange in my fields and it really does work in user interface but it didn't record in Database.When I open pgAdmin to check databse ,there is no record except name(field). 

There is My code .............>>>>

Examples .....

_name = text.model

name = fields.Many2one('op.admission.register', string="Name")
date_of_birth = fields.Date('Date Of Birth', related='name.birthday', readonly=True)
st_email = fields.Char('Email', related='st_name.email', readonly=True)

When i went to check (Text.model) in database  ,  there is no record in other fields except (name).

i would like to change all data  when i choose name. Please,give me some adivces and Thank you.


Avatar
Discard
Best Answer

Hi Hannay:

You Can use like this , it will store in database.

date_of_birth = fields.Date('Date Of Birth', related='name.birthday', readonly=True, store=True)
st_email = fields.Char('Email', related='st_name.email', readonly=True, store=True)
Avatar
Discard
Best Answer

Hi Hannay:

The data in the related fields is retrieved by the ORM from the referenced model/table when you get the data. This is similar to retrieving data from the reference table using foreign key references in a relational database. 

Avatar
Discard