Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
1001 Widoki

I added wizard to select two dates and send data from wizard to report 
this wizard is hown when i click on تبرير غياب submenu i need to get name of employee of this hr.employee (Ernest Reed) to print it in report  with the data given from wizard  how can i do that?

wizard code:

class AbsencePrintWizard(models.TransientModel):
_name = 'absence.print.wizard'
_description = 'Employee Print Wizard'


date_from=fields.Date()
date_to=fields.Date()
employee_id=fields.Many2one('hr.employee')
absence_days = fields.Integer(compute="compute_absence_days")
annual_timeoff_days=fields.Integer(compute="compute_annual_timeoff_days")
remaining_annual_timeoff_days=fields.Integer(compute="compute_annual_timeoff_days")
emergency_timeoff_days = fields.Integer(compute="compute_emergency_timeoff_days")
remaining_emergency_timeoff_days = fields.Integer(compute="compute_emergency_timeoff_days")
absence_days_in_year=fields.Integer(compute="compute_absence_days")
   	​def print_report(self):
​data={
'name':self.employee_id.name,
'job':self.employee_id.job_title,
'work_location':self.employee_id.work_location_id.name,
'absence_days':self.absence_days,
'total_annual_timeoff':self.annual_timeoff_days,
'remaining_annual_timeoff_days':self.remaining_annual_timeoff_days,
'total_emergency_timeoff':self.emergency_timeoff_days,
'remaining_emergency_timeoff_days':self.remaining_emergency_timeoff_days,
'create_date':self.create_date.date(),
'year':self.create_date.date().year,
'absence_days_in_year':self.absence_days_in_year,


}
return self.env.ref('gescoly_timeoff.Absence_leave_report_id').report_action(self,data=data)




Awatar
Odrzuć
Najlepsza odpowiedź

Hi,
If the employee get is getting added in the employee_id field in the wizard, you can access the employee information  from this field.

If the employee_id is not getting filled the employee record, you can get the active employee record using active_id. Either you can browse and get the employee record using active_id and set to this field or directly you can pass it to the report. Setting the value to the field will be better.

self.env['hr.employee'].browse(self._context.get('active_ids', []))

or 


self.env['hr.employee'].browse(self._context.get('active_id', []))


If its allowed to print multiple employees together from tree, use active_ids.



Thanks

Awatar
Odrzuć
Najlepsza odpowiedź

Hi 

You can browse the current employee_id in the wizard and call name and other fields from that 

employee = self. env['hr. employee'].browse(self.employee_id)

employee_name = employee.name

job = employee.job_title



Regards

Awatar
Odrzuć
Autor

I want to delete employee_id from wizard and getting employee data from the current screen