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

Hi 

 I need to make server action to create daily leave allocation record based on employee tags 

i added the below python code to action server 

    def _daily_leaves(self):

            duration  = 5


                leave = self.env['hr.holidays'].create({


                    'category_id': '1',

                    'holiday_status_id': status.id,

                    'type': 'add',

                    'holiday_type': 'category',

                    'number_of_days_temp': duration

                })

                leave.action_approve()

                if leave.double_validation:

                    leave.action_validate()


and then i created scheduled action to trigar that action , the scheduled action 

  • Object: ir.actions.server
  • Method: _run_actions
  • Arguments: ([200],) the server action ID 

when i test the action it gives no error but no record added 


could any help in that 



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

Hi,

It seems your function not get called,  if it gets executed means you will get an error message for sure. Checking the python function you have written, there is a variable named status and it seems it not assigned any values.


So after activating the developer mode navigate to Settings -> Technical -> Automation -> Scheduled Action, and select the action you have created and run it manually, by clicking the Run Manually button, so that you can see the errors.


For creating the automated action. please refer this: https://www.cybrosys.com/blog/automated-action-in-odoo


Thanks

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
أكتوبر 23
8416
2
يونيو 23
3866
0
مارس 15
3665
0
مارس 15
3850
1
مارس 15
5049