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

Hello, 

I'm trying to define a new automated action in odoo through the odoo interface, but I can't get the python expression to work.

I want to update a datetime field in my crm.claim module, that I have defined in my code as

date': fields.datetime('Claim Date', select = True) 

So I create an automated action, and in server actions to run, I create a new action like this

Base Model: claim

Action to do: Write on record

Update the Current Record

Value MappingFieldEvaluation TypeValue
Claim DatePython Expressiontime.today()

 However, I get

ValueError: "'module' object has no attribute 'today'" while evaluating
u'time.today()'

I've tried importing the time module too, but I get the same error. Even a print "test" doesn't work.

What's the correct way of writing a Python Expression using odoo's interface?

Thank you

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

Hello,

You can do:

 object.write({'x_mytime': datetime.datetime.today()})

But what is your use case ? 

Because fyi, you have the 'magic' field write_date that is already updated on each write !

 

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Automated action : return another action แก้ไขแล้ว
3
ก.ค. 20
9845
1
ก.ค. 18
5600
3
เม.ย. 24
2170
1
ก.ย. 23
2021
0
พ.ค. 21
4483