Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
4716 มุมมอง

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.


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ส.ค. 21
4944
1
ก.ค. 25
2353
2
ก.ค. 25
7839
2
ก.ค. 25
4232
2
ก.ค. 25
4010