Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
4176 มุมมอง

Hi,

I've set an action trigerred when the partner status or contact (or some other contact's infos) is changing. It creates a note record containing status and extra datas. Thanks to that I can log all different changes.

I want to add the user name info. How is it possible? We have the write_uid info and I think this is the data to manage.


Here is the script I set :

if record.is_company:

  records.message_post(body="Modif Nom, mobile ou état: nom=" + str(record.name) + " /mobile=" + str(record.mobile) + " / by " + str(record.write_uid))


Is there some get_name function for that?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

To build on Komal's answer, use just "env" instead of "self.env" in automated actions.

อวตาร
ละทิ้ง
ผู้เขียน

Thanks Jack, but I don't see the effect.

Trace is now in the note recard : " / by res.users(2,))"

I certainly missed something, the py code is now:

if record.is_company:

records.message_post(body="Modif Nom, mobile ou état: nom=" + str(record.name) + " /mobile=" + str(record.mobile) + " / by " + str(env.user))

How to get the name instead of the user ID?

try appending ".id" onto the end->env.user.id or try env.uid

ผู้เขียน

Okay, it gives me the sole UID (with both env.uid or env.user.id) but now how to get the name of user?

Sorry Day Xamo,

Didn't read the original question, I thought you were after the ID.

For the name, you would want to use env.user.name.

Thanks,

ผู้เขียน

PER-FECT

And it's incredibely simple, thank you

คำตอบที่ดีที่สุด

change str(record.write_uid) to self.env.user

อวตาร
ละทิ้ง
ผู้เขียน

Hi Komal, it doesn't work, it gives an error while executing the script:

ValueError: <class 'NameError'>: "name 'self' is not defined" while evaluating

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ส.ค. 25
406
2
ส.ค. 25
1409
0
ก.พ. 25
1527
1
ส.ค. 25
2133
Odoo 18 - Notes module แก้ไขแล้ว
1
ม.ค. 25
2441