콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
3068 화면

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

아바타
취소
베스트 답변

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

아바타
취소
관련 게시물 답글 화면 활동
3
8월 24
5575
2
11월 22
2083
1
12월 22
1830
2
11월 24
20322
3
5월 25
1565