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

For those (especially studio users) who may find it useful...

Normal Server action:



for record in records:
if record.x_save_history:
vals = { 'x_name' = record.x_name,
'x_value' = record.x_val
} env['x_history'].create(vals)


used for all records selected is creating same result as below scheduled action:

Scheduled action:

recs = model.search([])

for rec in recs:
if rec.x_save_history:
vals = {
 'x_name' = rec.x_name,
'x_value' = rec.x_val
}
 env['x_history'].create(vals)
Ảnh đại diện
Huỷ bỏ

please provide more details.

Tác giả Câu trả lời hay nhất

In Server action you have predefined variable 'records' containing all selected records. 

In Scheduled action you have to "select" records with 'recs = model.search([])' 


Rest of code is example action on records

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