跳至內容
選單
此問題已被標幟
1323 瀏覽次數
I am creating a mobile application about HRM that connects to odoo using api. Currently, I perform operations with the hr.leave model, but some methods in this model use employees taken from env so they cannot be used via the api, what should I do now? I hope odoo support team will help


// Method in hr.leave 
def action_approve(self, check_state=True):
if check_state and any(holiday.state != 'confirm' for holiday in self):
raise UserError(_('Time off request must be confirmed ("To Approve") in order to approve it.'))

current_employee = self.env.user.employee_id // this method use employee in env to validate
@Validator.validate_token
@http.route('/api/v1/mobile/hrm/leave', methods=["POST"], type="http", auth="none", csrf=False)
.....
leave_result = request.env['hr.leave'].sudo().search([
('id', 'in', leave_id)
], limit=1)
leave_result.action_approve() // Error

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
1月 23
2416
2
11月 20
4014
2
3月 15
9352
2
11月 15
6154
0
3月 15
3797