Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
5046 Vistas

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
Descartar
Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
oct 23
8338
2
jun 23
3787
0
mar 15
3581
0
mar 15
3767
1
mar 15
4972