Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
1307 Visualizações
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

Avatar
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
1
jan. 23
2400
2
nov. 20
3999
2
mar. 15
9349
2
nov. 15
6140
0
mar. 15
3785