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

Hello:

I'am trying to create a custom app via Studio. It's super simple, it has 3 fields: username, date, text_description. 

username and date are supposed to be set by default. I'd like to know how to set the username equal to the current logged in user and the date equal to the currrent timestamp.

Please consider that I'm using Studio. 


Thanks

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

TWO OPTIONS:


Via the Window Action:

Add this to the Window Action context:

{'default_x_studio_date': context_today()}

This is normally used in Odoo to support filters in Search Views, where it needs to be converted by adding .strftime('%Y-%m-%d') but works just fine in Window Actions as I have shown.


Via a calculated field:

1. Click MORE at the bottom of the Field Properties tab.



2. Enter this code in the COMPUTE field for DATE:



Note that x_studio_field_IFERO was the name of the custom date field I added, yours will be different.


3. Enter this code in the COMPUTE field for USER.



Note that x_studio_field_aMyLf was the name of the custom one2many field (res.users) I added, yours will be different.

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

Hi Ray,

   How can we set current date in Studio reports also?

   Please help

Thanks

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

Hello, I have tried your code using Odoo Studio in Odoo Version 14.0 But I am getting an error in View:

Can some one help me regarding this:


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Menu's with different default filter แก้ไขแล้ว
1
ก.ค. 25
1350
2
มี.ค. 25
1614
0
ก.พ. 25
1247
0
ก.พ. 25
1437
0
ก.พ. 25
1390