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
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
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
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.")
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.
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
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
3
thg 8 24
|
5109 | ||
Where is Docs for Employee
Đã xử lý
|
|
2
thg 11 22
|
1827 | |
Biz owners under EMPLOYEE app?
Đã xử lý
|
|
1
thg 12 22
|
1608 | |
|
2
thg 11 24
|
18507 | ||
|
3
thg 5 25
|
834 |