تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
3576 أدوات العرض

I'm creating a new project task to an existing project via an automated action. 

I need to assign a known value to the field projct_id in the model project.task. 

The ID of the project to assign to the field project_id in my case is = 5

I don't know the correct syntax:

env['project.task'].create({'name' :record.origin, 'project_id'  :record. ??? })

الصورة الرمزية
إهمال
أفضل إجابة

If you are hardcoding the value (not recommended) the syntax is

'project_id' : 5

الصورة الرمزية
إهمال
الكاتب

I fully agree with you that it is not a good practice to hardcode a value.

However, thsi is a case where I need to assign a specific project according to pre-determined cases specified in the automated action. Do you know any condition for which the ID change once the record is created in the database?

The id will never change after the record is created.

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
نوفمبر 23
2162
2
ديسمبر 23
5780
1
نوفمبر 22
2618
1
أغسطس 22
2659
2
يناير 22
5863