コンテンツへスキップ
メニュー
この質問にフラグが付けられました
3 返信
2569 ビュー

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
5115
2
11月 22
1827
1
12月 22
1609
2
11月 24
18527
3
5月 25
842