Hi,
I'm creating a wizard to write the refuse reason for Applicant (hr.applicant). I want receive the value of the fields on wizard form before it be saved. Is there any way to do it?
Code to open wizard
@api.multi
def archive_applicant_sure(self):
return {
'name': _('Update Your Refuse Reason'),
'type': 'ir.actions.act_window',
'view_mode': 'form',
'view_type': 'form',
'res_model': 'hr.applicant',
'target': 'new',
'view_id': self.env.ref('icoeuro_hr.hr_applicant_interview_refuse_wizard', False).id,
'res_id': self.id,
}
Wizard form
<!-- Refuse wizard -->
<record model="ir.ui.view" id="hr_applicant_interview_refuse_wizard">
<field name="name">hr.applicant.refuse.wizard.form</field>
<field name="model">hr.applicant</field>
<field name="arch" type="xml">
<form>
<group string="Refuse Reason">
<field name="refuse_reason" nolabel="1" required="1"/>
</group>
<footer>
<button string="Save" type="object" name="archive_applicant" class="oe_highlight"/>
<button string="Cancel" class="btn-secondary" special="cancel"/>
</footer>
</form>
</field>
</record>
The function that I want to receive the value
@api.multi
def archive_applicant(self, form):
print(form)
# self._context.get('refuse_reason')
if form.get('refuse_reason'):
self.action_applicant_refuse(form.get('refuse_reason'))
else:
raise UserError(_('You must type some reason'))
return {'type': 'ir.actions.act_window_close'}
Now, when I click "Save" in wizard form Odoo execute the write function then archive_applicant and the form parameter do not receive the field value. I know we can use other solution but if we have a way to do this, I think we can apply it to some other case