Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
7413 Lượt xem
Hi , 
i want to read the current id to increment it by one for updating record 
i tryed : 
rec = self.id +1
record = self.env['model.name'].search([('id', '=', rec)])
record.write({'field' : value }) 
but i got error 
also how to do :
record = self.env['model.name'].search([('id', '=', self.id)])
self.env['model.name'].browse(record).write({'field': 'value'})
Thanks in advance
 


Ảnh đại diện
Huỷ bỏ

You just need to learn basics of odoo customization: https://goo.gl/8HgnCF

Câu trả lời hay nhất

If self represents the current record, record with ID = self.id + 1 does not exist, so you can't write to it.

You must CREATE it first.

Please review https://www.odoo.com/documentation/12.0/reference/orm.html#common-orm-methods to see how to use CREATE.

In your posts, please post the actual error instead of "i got error" because there could be information in the error message that helps answer your post - otherwise we have to guess.  :)

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 9 21
18559
0
thg 3 17
3308
2
thg 2 23
12633
1
thg 3 22
2134
1
thg 8 24
5866