跳至內容
選單
此問題已被標幟
1 回覆
5086 瀏覽次數

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
10月 23
8415
2
6月 23
3865
0
3月 15
3665
0
3月 15
3849
1
3月 15
5045