跳至內容
選單
此問題已被標幟
1 回覆
1105 瀏覽次數

Hello Odoo Community:

   I have created a custom field under the Gamification.goal model. I'd like execute the following code not for specific user_id A, 

for rec in self:

    rec['x_completeness'] = (1100*rec.completeness/100)

And I'd like to excute the next code solely for specific user_id A 

for rec in self:

    rec['x_completeness'] = (400*rec.completeness/100)

Please give me some suggestions. Thanks a lot!

頭像
捨棄
作者

I have solved the problem with automated actions
Now I'd like to copy the value x_completeness (field type is Float) to a different custom field x_merit under the Payslip model; how should I write the python coding under automated actions? Many thanks!

最佳答案

Hi,

To execute specific code for user_id,A,

Replace ''A"  with the actual id of the specific user 

for rec in self:

    if self.env.user.id == A:

           rec['x_completeness'] = (400*rec.completeness/100)

    else:

           rec['x_completeness'] = (1100*rec.completeness/100)



Hope it helps,

頭像
捨棄
作者

Thanks a lot. It worked!

相關帖文 回覆 瀏覽次數 活動
0
2月 25
1255
0
1月 25
1094
1
12月 24
1383
1
6月 22
5524
1
2月 19
4922