Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
4399 Lượt xem

Hello,

I have declared a field w ith a default value as follows :

status = fields.Char(string="Status_Vente", required=False, editable=False, default='Disponible')

I would like to change the "status" value when i click in button. This button is defined in another class.

I have tried to change the "status" value by this instruction, but it dosen't work for me :

def button_action(self):

...........
self.status= 'Vendu'


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi Zakaria,
You can't do that.

The self now contains the instances of the new class.
You can do it by the following way.

 

def button_action(self):

instance_of_needed_model = self.env['needed.model'].browse(needed record id)
instance_of_needed_model.write({'status': 'Vendu'})

Thank you. 

Ảnh đại diện
Huỷ bỏ
Tác giả

Thank you bro

Dear Zakaria ,

Don't forget to accept this answer.

Tác giả

Yes thank you