anyone help please!
Hello community, i need to execute some python codes in the server side before the window action below is calling, and after the python code executed the winodow action should be call.
menu:
name='Inbox'
parent="main_menu_letter_management"
sequence="20" action="action_egp_letter_inbox_tree_view"/>
window action:
"
Letters
egp.letter.inbox
tree,form
{"default_desired_value": ""}
[('recipients', '=', context.get('default_desired_value'))]
[(False, 'tree'), (ref('egp_letter_inbox_form_view'), 'form')]
"
python function:
def open_custom_window(self):
employee = self.env['hr.employee'].search([('user_id', '=', self.env.user.id)], limit=1)
print('the employee gotted id', employee.id)
departments = self.env['hr.department'].search([('manager_id', '=', employee.id)], limit=1)
print('department gotted id ', departments.id)
action = self.env.ref('egp_letter.action_egp_letter_inbox_tree_view')
computed_value = departments.id
action.write({'context': {'default_desired_value': computed_value}})
return self.env.ref('egp_letter.action_egp_letter_inbox_tree_view')
Hmm I look into your code and i see your problem is the context 'default_desired_value' didn't have as you want right ?