Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
1816 Tampilan

I have a model Person with a One2Many photo field (Photo model).

In the same form view I have the person data and a a tree view for the photos. 

I overwrite the write method of the model Person and the unlink method of the Photo model for validation needs. If in the form I delete a photo and save is first called the write method of person and later the unlink method of photo.

My question is the following: How can I know in the write method of the person that there is a foto in the "unlink state"?

Avatar
Buang
Jawaban Terbai

Hello Daniel,

In write method you can identify using numbers

your one2many field will having (4,0,vals)   --> means  adding new record

your one2many field will having (1,one2many id,False)   or (2,one2many id,False)  here one for updating and one for deletion.
Note :  by using print or debug you can get it, please verify  either 1 or 2 will be the delete record condition

Avatar
Buang