콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
4 답글
4999 화면

Default_get method not setting the values to the field in odoo 14. I'm using the 'active_id' context, I can print it but I can't affect it to the field.

This is my code:

@api.model
def default_get(self, fields):
res = super(HrRefusWizard, self).default_get(fields)
res['employee_id'] = self._context.get('active_id')
return res

refus = fields.Text(string='Comentaire de refus', required=False)
employee_id = fields.Many2one('hr.employee', string='Employee', required=True)

Help me please

아바타
취소
베스트 답변

Hello Mchakkah Alaa,

I think you should try like with below code

@api.model
def default_get(self, fields):
res = super(HrRefusWizard, self).default_get(fields)
employee = self.env['hr.employee'].browse(self._context['active_id'])
if lead:
res['employee_id'] = employee.id
return res

refus = fields.Text(string='Comentaire de refus', required=False)
employee_id = fields.Many2one('hr.employee', string='Employee', required=True)

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

아바타
취소
베스트 답변

Facing the same problem for One2many pop up. All the examples are given using wizard, not using pop up that appears in One2many relationship. 

아바타
취소
작성자 베스트 답변

No it’s not working I just tried it!

아바타
취소
베스트 답변

I think you have to declare the fields above default get method.


아바타
취소
관련 게시물 답글 화면 활동
1
8월 21
5155
3
9월 25
2922
0
8월 25
526
1
8월 25
2640
2
7월 25
8330