Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
4 Antwoorden
4637 Weergaven

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

Avatar
Annuleer
Beste antwoord

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

Avatar
Annuleer
Beste antwoord

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

Avatar
Annuleer
Auteur Beste antwoord

No it’s not working I just tried it!

Avatar
Annuleer
Beste antwoord

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


Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
aug. 21
4877
1
jul. 25
2136
2
jul. 25
7651
2
jul. 25
4077
2
jul. 25
3823