Se rendre au contenu
Menu
Cette question a été signalée
3 Réponses
2590 Vues

How to create an automated action that gives an internal note if the employee is filed due to dismissal or resignation and within the internal note the person responsible for the employee is posted in odoo enterprice 14

Avatar
Ignorer
Meilleure réponse

Hello Matias,

I hope you are doing well.

Here, you can find example of automated action for the internal note to notify the person responsible for the employee is filed due to dismissal or resignation in odoo.

Find Example in comment. 

I hope this can help you.

Thanks & Regards,
Email:   odoo@aktivsoftware.com 

Skype: kalpeshmaheshwari

Avatar
Ignorer

Please find code example here :-

For Example -
Note - Check Indentation of the code after pasting the code.
- Change the f String as per your requirement.
- 'employee' object refers to the employee who has been fired or filed resignation.
- 'employee.parent_id' refers to the responsible person or the Manager.

- Create an automated action by adding
name, model( Employee (hr.employee) as per your requirement),
trigger(update as per your requirement), Trigger fields (Departure Reason (hr.employee), Apply on ( Paste the Below Domain in the Code editor ) as per your requirement), Action To Do ( Execute Python Code ).

Apply on Domain :- ["|", ("departure_reason_id.name", "=", "Fired"), ("departure_reason_id.name", "=", "Resigned"), ("active", "=", False)]

- In the Python Code Below Paste this code:-

for employee in records:
if employee.parent_id:
employee.parent_id.message_post(message_type="notification" ,body=f"Notification: {employee.name} has recently {'faced termination' if employee.departure_reason_id.name == 'Fired' else 'resigned'} from their position within our organization.")

Auteur Meilleure réponse

doing an automatic action with: action to perform: execute python code trigger condition: on update monitored field: departure_reason apply on: (departure_reason == 'fired' | departure_reason == 'resigned') & active == False With that, the code will be executed with the conditions I want, what I can't find is that the python code sends an internal note notification **to the responsible employee** of the subordinate who was fired or resigned and only he receives the notification. On the other hand, the f-string function, as you propose, does not work with {} objects inside, since it is taken as an error or as a string, none of these options works.

Avatar
Ignorer
Meilleure réponse

Hi,

for this Create an Automated action (Settings->Automated Actions->Scheduled Actions), with Model "Employee" and in Action to Do  - select Execute Python Code

Suppose in your employee form you have the field with name "employee_state" , you can write the python code as below:

filed_employees = self.env['hr.employee'].search([('employee_state', 'in', ['dismiss', 'resign'])])

for employee in filed_employees:
note = f"The employee has been filed due to {employee.state}." \
f" The responsible person is {employee.parent_id.name}."

employee.message_post(body=note, subtype='mt_note')

Hope this will help you

Thanks

Avatar
Ignorer
Publications associées Réponses Vues Activité
3
août 24
5144
2
nov. 22
1839
1
déc. 22
1615
2
nov. 24
18646
3
mai 25
884