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

I'm using Odoo14 CE, I tried to track the Html field log changes details.

Field name ==>description = fields.Html(string='Description',tracking=True)

But not working any inputs, please.

Advance thanks.

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

Now it's working thank you for your reply

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

in odoo17, it works like that:

if vals.get('html_field'):
self.message_post(body_is_html=True, body=f"Website Description: {self.html_field} --> {vals.get('html_field')}")


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

You are the best! I was looking everywhere and your solution was the one that worked:
body_is_html=True, is the key to make it work in Odoo v17.

Thanks a lot!

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

Actually body_is_html is depricated ...

Do

from markupsafe import Markup

body=Markup(...)

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

Hi,

tracking=True does not work with HTML field. if you need log the that field change in to chatter. you can override the write function of the model that contains the field, and post custom message in to chatter when writing in to that HTML field.

Example

def write(self, vals):
if vals.get('field_name'):
self.message_post(body="Field Name: %(old_value)s --> %(new_vale)s", old_value=self.field_name, new_value=vals.get('field_name'))
res = super(ClassName, self).write(vals)
return res

Regards

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 1 23
1880
2
thg 8 23
3497
1
thg 7 22
2278
1
thg 3 22
1938
0
thg 7 21
2374