Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
5053 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
říj 23
8354
2
čvn 23
3799
0
bře 15
3590
0
bře 15
3783
1
bře 15
4977