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

I need to capture changes in field 'stage_id' in model 'crm.lead' and trigger a function. More specifically, it needs to work when the Opportunity stage is changed via kanban view.

I tried using @api.depends... but it looks like these @api.depends functions are only triggered if there is a field 'X' with _compute pointing to such function. But I need that field 'X' to be manually modifiable (and it looks _compute prevents it).

Can this be handle in any way?

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

OK, typing error: I typed '_compute=' in fields definition instead of 'compute='.

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

Check for the value in the ORM methods i.e. create & write, this way, Vals/values will provide if any changes made to any fields..

However, If you are using Version 8 or so,  Message log will capture activities of the status [trackvisibility]

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

Yes, I am overriding write() method often, as changes can be detected by the presence (or not, if fields was not changed) of a key in 'values' dictionary. And also, previous value can be checked with self.your_field, against values.get('your_field', None) or similar. Trackvisibility is nice to log changes, but not to do something else along a change.

For the record, note that stored computed/related fields bypass the `write` method. You need to override `_write` instead to detect changes in `vals`.

Bài viết liên quan Trả lời Lượt xem Hoạt động
6
thg 1 23
15980
1
thg 7 21
3630
11
thg 5 18
12472
9
thg 3 15
5949
1
thg 2 24
12701