Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1324 Lượt xem
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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 1 23
2416
2
thg 11 20
4014
2
thg 3 15
9352
2
thg 11 15
6154
0
thg 3 15
3798