コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1312 ビュー
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
2403
2
11月 20
4001
2
3月 15
9349
2
11月 15
6142
0
3月 15
3789