İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
5055 Görünümler

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 



Avatar
Vazgeç
En İyi Yanıt

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

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Eki 23
8357
2
Haz 23
3806
0
Mar 15
3595
0
Mar 15
3785
1
Mar 15
4980