跳至内容
菜单
此问题已终结
4 回复
4647 查看

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
4879
1
7月 25
2170
2
7月 25
7676
2
7月 25
4099
2
7月 25
3839