Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
sty 23
2403
2
lis 20
3999
2
mar 15
9349
2
lis 15
6141
0
mar 15
3788