Merge pull request #1 from expsa/system_notification
system_notifcation
This commit is contained in:
commit
37f9786761
|
|
@ -0,0 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import models
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
{
|
||||
'name': "System Notification",
|
||||
'version': '18.0.1.0.0',
|
||||
'summary': """""",
|
||||
'description': """
|
||||
""",
|
||||
'category': 'Odex30-base', # تم تغيير الفئة
|
||||
'depends': ['base_automation', 'mail'],
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'views/views.xml',
|
||||
'views/group_state_notification.xml',
|
||||
'data/mail_data.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'application': False,
|
||||
'auto_install': False,
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<template id="mail_notification_odex" name="System Notification Layout">
|
||||
<table border="0" cellpadding="0" cellspacing="0"
|
||||
style="padding-top: 16px; background-color: #F1F1F1; font-family:Verdana, Arial,sans-serif; color: #454748; width: 100%; border-collapse:separate;">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="590"
|
||||
style="padding: 24px; background-color: white; color: #454748; border-collapse:separate;">
|
||||
<tbody>
|
||||
<!-- HEADER -->
|
||||
<tr>
|
||||
<td align="center" style="min-width: 590px;">
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%"
|
||||
style="background-color: white; padding: 0; border-collapse:separate;">
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
</td>
|
||||
<td valign="middle" align="right">
|
||||
<img t-att-src="'/logo.png?company=%s' % (company.id or 0)"
|
||||
style="padding: 0px; margin: 0px; height: 48px;"
|
||||
t-att-alt="'%s' % company.name"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="text-align:center;">
|
||||
<hr width="100%"
|
||||
style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin:4px 0px 32px 0px;"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- CONTENT -->
|
||||
<tr>
|
||||
<td style="min-width: 590px;">
|
||||
<t t-out="message.body"/>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- FOOTER -->
|
||||
<tr>
|
||||
<td align="center" style="min-width: 590px; padding: 0 8px 0 8px; font-size:11px;">
|
||||
<hr width="100%"
|
||||
style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin: 16px 0px 4px 0px;"/>
|
||||
<b t-out="company.name"/><br/>
|
||||
<div style="color: #999999;">
|
||||
<t t-out="company.phone"/>
|
||||
<t t-if="company.email"> |
|
||||
<a t-att-href="'mailto:%s' % company.email"
|
||||
style="text-decoration:none; color: #999999;">
|
||||
<t t-out="company.email"/>
|
||||
</a>
|
||||
</t>
|
||||
<t t-if="company.website"> |
|
||||
<a t-att-href="'%s' % company.website"
|
||||
style="text-decoration:none; color: #999999;">
|
||||
<t t-out="company.website"/>
|
||||
</a>
|
||||
</t>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</template>
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1,276 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * system_notification
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 14.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-12-05 11:54+0000\n"
|
||||
"PO-Revision-Date: 2024-12-05 11:54+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model,name:system_notification.model_base_automation
|
||||
msgid "Automated Action"
|
||||
msgstr "إجراء آلي"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.actions.act_window,name:system_notification.base_automation_act
|
||||
msgid "Automated Actions"
|
||||
msgstr "الإجراءات التلقائية"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.ui.view,arch_db:system_notification.view_base_group_automation_tree
|
||||
msgid "Automation"
|
||||
msgstr "أتمتة"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation_notify__cc_groups_ids
|
||||
msgid "CC Notify Groups"
|
||||
msgstr "نسخة ايميل لـ"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.actions.act_window,help:system_notification.base_automation_act
|
||||
msgid "Click to setup a new automated automation."
|
||||
msgstr "انقر لإعداد أتمتة آلية جديدة."
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_automation_group__create_uid
|
||||
msgid "Created by"
|
||||
msgstr "أنشئ بواسطة"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_automation_group__create_date
|
||||
msgid "Created on"
|
||||
msgstr "أنشئ في"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_automation_group__display_name
|
||||
msgid "Display Name"
|
||||
msgstr "الاسم المعروض"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_automation_group__atuomation_ids
|
||||
msgid "Group States "
|
||||
msgstr "حالات المجموعة"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_automation_group__id
|
||||
msgid "ID"
|
||||
msgstr "المعرف"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_automation_group__last_update
|
||||
msgid "Last Modified on"
|
||||
msgstr "آخر تعديل في"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_automation_group__write_uid
|
||||
msgid "Last Updated by"
|
||||
msgstr "آخر تحديث بواسطة"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_automation_group__write_date
|
||||
msgid "Last Updated on"
|
||||
msgstr "آخر تحديث في"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_automation_group__model_id
|
||||
msgid "Model"
|
||||
msgstr "اسم الإجراء"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.ui.menu,name:system_notification.menu_root
|
||||
msgid "System Notification"
|
||||
msgstr "إشعارات النظام"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation_notify__to_groups_ids
|
||||
msgid "TO Notify Groups"
|
||||
msgstr "إشعار المجموعة"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model,name:system_notification.model_automation_group
|
||||
msgid "automation.group"
|
||||
msgstr "المجموعة التلقائية"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model,name:system_notification.model_ir_actions_server
|
||||
msgid "ir.actions.server"
|
||||
msgstr "ir.actions.server"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.ui.view,arch_db:system_notification.view_base_group_automation_form
|
||||
msgid "states"
|
||||
msgstr "الحالات"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.ui.menu,name:system_notification.menu_base_group_automation_form
|
||||
msgid "states notificatin"
|
||||
msgstr "حالات الاشعار"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation__notify_to_groups_ids
|
||||
msgid "TO Notify Groups"
|
||||
msgstr "إرسال للمجموعات"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation__notify_cc_groups_ids
|
||||
msgid "CC Notify Groups"
|
||||
msgstr "نسخة للمجموعات"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation__notify_note
|
||||
msgid "Notification Note"
|
||||
msgstr "ملاحظات الاشعار"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation__send_notify
|
||||
msgid "Send Notify"
|
||||
msgstr "إشعار داخلي"
|
||||
|
||||
#. module: system_notification
|
||||
#: model_terms:ir.ui.view,arch_db:system_notification.view_base_automation_form
|
||||
msgid "Notification Data"
|
||||
msgstr "بيانات الإشعار"
|
||||
|
||||
#. module: system_notification
|
||||
#: model_terms:ir.ui.view,arch_db:system_notification.view_base_automation_form
|
||||
msgid "HR Notification Data"
|
||||
msgstr "بيانات إشعارات الموارد البشرية"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,help:system_notification.field_base_automation__send_notify
|
||||
msgid "Send Notifications Within The System"
|
||||
msgstr "إرسال إشعارات داخل النظام"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation__notify_title
|
||||
msgid "Notification Title"
|
||||
msgstr "عنوان الإشعار"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation__notify_summary
|
||||
msgid "Notification Message"
|
||||
msgstr "رسالة الإشعار"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation__hr_notifys
|
||||
msgid "HR Notifys"
|
||||
msgstr "إشعار الموارد البشرية"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation__services_manager_id
|
||||
msgid "Services Manager"
|
||||
msgstr "الخدمات المشتركة"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation__ceo_notify
|
||||
msgid "CEO Manager"
|
||||
msgstr "الرئيس التنفيذي"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation__hr_manager_notify
|
||||
msgid "HR Manager"
|
||||
msgstr "مدير الموارد البشرية"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation__hr_email_notify
|
||||
msgid "HR E-Mail"
|
||||
msgstr "ايميل الموارد البشرية"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation__department_manager_notify
|
||||
msgid "Department Manager"
|
||||
msgstr "مدير الإدارة"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation__direct_manager_notify
|
||||
msgid "Direct Manager"
|
||||
msgstr "المدير المباشر"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation__employee_notify
|
||||
msgid "Employee Notify"
|
||||
msgstr "إشعار الموظف"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation__it_manager_id
|
||||
msgid "IT Manager"
|
||||
msgstr "مدير التقــنية"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation__cyber_security_id
|
||||
msgid "Cyber Security"
|
||||
msgstr "الآمن السيبراني"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation__admin_manager_id
|
||||
msgid "Admin Affairs Manager"
|
||||
msgstr "مدير الشئون الإدارية"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,field_description:system_notification.field_base_automation__financial_manager_id
|
||||
msgid "Financial Manager"
|
||||
msgstr "مدير المــالية"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,help:system_notification.field_base_automation__hr_notifys
|
||||
msgid "Send Notifications HR Moduls Depend on (Employee Id) only"
|
||||
msgstr "إرسال إشعار بخصوص منظومات الموارد البشرية إعتماداً على (إسم الموظف) فقط"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,help:system_notification.field_base_automation__direct_manager_notify
|
||||
msgid "Send Notification To The Employee's Direct Manager Only"
|
||||
msgstr "إرسال إشعار للمدير المباشر للموظف فقط حسب سجل الموظف"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,help:system_notification.field_base_automation__department_manager_notify
|
||||
msgid "Send Notification To The Department Manager For The Employee Only"
|
||||
msgstr "إرسال إشعار لمدير ادارة للموظف فقط حسب سجل الموظف"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,help:system_notification.field_base_automation__employee_notify
|
||||
msgid "Send Notification To The Employee Only"
|
||||
msgstr "إرسال إشعار للموظف فقط حسب سجل الموظف"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,help:system_notification.field_base_automation__ceo_notify
|
||||
msgid "Send Notification To The CEO Manager Only"
|
||||
msgstr "إرسال إشعار للرئيس التنفيذي فقط"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,help:system_notification.field_base_automation__hr_manager_notify
|
||||
msgid "Send Notification To The HR Manager Only"
|
||||
msgstr "إرسال إشعار لمدير الموارد البشرية فقط"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,help:system_notification.field_base_automation__hr_email_notify
|
||||
msgid "Send Notification To The HR E-Mail Only"
|
||||
msgstr "إرسال إشعار إيميل الموراد البشرية فقط"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,help:system_notification.field_base_automation__services_manager_id
|
||||
msgid "Send Notification To The Services Manager Only"
|
||||
msgstr "إرسال إشعار لمدير الخدمات المشتركة فقط"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,help:system_notification.field_base_automation__it_manager_id
|
||||
msgid "Send Notification To The IT Manager Only"
|
||||
msgstr "إرسال إشعار لمدير التقنية فقط"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,help:system_notification.field_base_automation__admin_manager_id
|
||||
msgid "Send Notification To The Admin Affairs Manager Only"
|
||||
msgstr "إرسال إشعار لمدير الشئون الإدارية فقط"
|
||||
|
||||
#. module: system_notification
|
||||
#: model:ir.model.fields,help:system_notification.field_base_automation__financial_manager_id
|
||||
msgid "Send Notification To The Financial Manager Only"
|
||||
msgstr "إرسال إشعار لمدير المالية فقط"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import models
|
||||
from . import group_state_notification
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class BaseGroupAutomation(models.Model):
|
||||
_name = 'automation.group'
|
||||
_rec_name = 'model_id'
|
||||
_description = 'Automation Group'
|
||||
|
||||
model_id = fields.Many2one('ir.model', string="Model", ondelete='cascade', required=True)
|
||||
atuomation_ids = fields.Many2many(
|
||||
comodel_name='base.automation',
|
||||
relation='automation_state_groups_rel',
|
||||
string='Group States'
|
||||
)
|
||||
|
||||
def unlink(self):
|
||||
"""
|
||||
Delete all record(s) from recordset
|
||||
return True on success, False otherwise
|
||||
"""
|
||||
for record in self.atuomation_ids:
|
||||
record.unlink()
|
||||
result = super(BaseGroupAutomation, self).unlink()
|
||||
return result
|
||||
|
|
@ -0,0 +1,225 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class BaseAutomation(models.Model):
|
||||
_inherit = 'base.automation'
|
||||
|
||||
# إضافة خيار الإشعار
|
||||
send_notify = fields.Boolean(string='Send Notify', help="Send Notifications Within The System")
|
||||
notify_title = fields.Char(string='Notification Title', related='model_id.name')
|
||||
notify_note = fields.Char(string='Notification Note')
|
||||
notify_summary = fields.Char(string='Notification Message')
|
||||
|
||||
notify_to_groups_ids = fields.Many2many(
|
||||
comodel_name='res.groups',
|
||||
relation='automation_notifications_to_groups_rel',
|
||||
string='TO Notify Groups'
|
||||
)
|
||||
|
||||
notify_cc_groups_ids = fields.Many2many(
|
||||
comodel_name='res.groups',
|
||||
relation='automation_notifications_cc_groups_rel',
|
||||
string='CC Notify Groups'
|
||||
)
|
||||
|
||||
hr_notifys = fields.Boolean(
|
||||
string='HR Notifys',
|
||||
help="Send Notifications HR Modules Depend on (Employee Id) only"
|
||||
)
|
||||
direct_manager_notify = fields.Boolean(string='Direct Manager Notify', help="Notify direct manager")
|
||||
department_manager_notify = fields.Boolean(string='Department Manager Notify', help="Notify department manager")
|
||||
employee_notify = fields.Boolean(string='Employee Notify', help="Notify employee")
|
||||
ceo_notify = fields.Boolean(string='CEO Manager', help="Notify CEO")
|
||||
hr_manager_notify = fields.Boolean(string='HR Manager', help="Notify HR manager")
|
||||
hr_email_notify = fields.Boolean(string='HR E-Mail', help="Notify HR email")
|
||||
services_manager_id = fields.Boolean(string='Services Manager', help="Notify services manager")
|
||||
it_manager_id = fields.Boolean(string='IT Manager', help="Notify IT manager")
|
||||
admin_manager_id = fields.Boolean(string='Admin Affairs Manager', help="Notify admin manager")
|
||||
financial_manager_id = fields.Boolean(string='Financial Manager', help="Notify financial manager")
|
||||
cyber_security_id = fields.Boolean(string='Cyber Security', help="Notify cyber security")
|
||||
|
||||
def check_record_access(self, user_id, record, mode='read'):
|
||||
try:
|
||||
record.with_user(user_id).check_access_rule(mode)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
def access_users(self, groups, record):
|
||||
users = []
|
||||
for group in groups:
|
||||
for user in group.users:
|
||||
if user.partner_id.email not in users and \
|
||||
self.check_record_access(user_id=user.id, record=record, mode='read') and \
|
||||
user.partner_id.email:
|
||||
if self.hr_notifys:
|
||||
if hasattr(record, 'employee_id') and record.employee_id:
|
||||
emp = record.employee_id.sudo()
|
||||
if self.direct_manager_notify and user.id == emp.parent_id.user_id.id:
|
||||
users.append(user.partner_id.email)
|
||||
elif self.department_manager_notify and user.id == emp.coach_id.user_id.id:
|
||||
users.append(user.partner_id.email)
|
||||
elif self.employee_notify and user.id == emp.user_id.id:
|
||||
users.append(user.partner_id.email)
|
||||
elif self.ceo_notify and user.id == emp.company_id.general_supervisor_id.user_id.id:
|
||||
users.append(user.partner_id.email)
|
||||
elif self.hr_manager_notify and user.id == emp.company_id.hr_manager_id.user_id.id:
|
||||
users.append(user.partner_id.email)
|
||||
elif self.services_manager_id and user.id == emp.company_id.services_manager_id.user_id.id:
|
||||
users.append(user.partner_id.email)
|
||||
elif self.it_manager_id and user.id == emp.company_id.it_manager_id.user_id.id:
|
||||
users.append(user.partner_id.email)
|
||||
elif self.admin_manager_id and user.id == emp.company_id.admin_manager_id.user_id.id:
|
||||
users.append(user.partner_id.email)
|
||||
elif self.financial_manager_id and user.id == emp.company_id.financial_manager_id.user_id.id:
|
||||
users.append(user.partner_id.email)
|
||||
elif self.cyber_security_id and user.id == emp.company_id.cyber_security_id.user_id.id:
|
||||
users.append(user.partner_id.email)
|
||||
elif self.hr_email_notify and emp.company_id.hr_email and emp.company_id.hr_email not in users:
|
||||
users.append(emp.company_id.hr_email)
|
||||
else:
|
||||
users.append(user.partner_id.email)
|
||||
else:
|
||||
users.append(user.partner_id.email)
|
||||
return ",".join(users)
|
||||
|
||||
def access_users_ids(self, groups, record):
|
||||
processed_users = set()
|
||||
for group in groups:
|
||||
for user in group.users:
|
||||
if user.id not in processed_users and \
|
||||
self.check_record_access(user_id=user.id, record=record, mode='read'):
|
||||
if self.hr_notifys:
|
||||
if hasattr(record, 'employee_id') and record.employee_id:
|
||||
emp = record.employee_id.sudo()
|
||||
if self.direct_manager_notify and user.id == emp.parent_id.user_id.id:
|
||||
processed_users.add(user.id)
|
||||
elif self.department_manager_notify and user.id == emp.coach_id.user_id.id:
|
||||
processed_users.add(user.id)
|
||||
elif self.employee_notify and user.id == emp.user_id.id:
|
||||
processed_users.add(user.id)
|
||||
elif self.ceo_notify and user.id == emp.company_id.general_supervisor_id.user_id.id:
|
||||
processed_users.add(user.id)
|
||||
elif self.hr_manager_notify and user.id == emp.company_id.hr_manager_id.user_id.id:
|
||||
processed_users.add(user.id)
|
||||
elif self.services_manager_id and user.id == emp.company_id.services_manager_id.user_id.id:
|
||||
processed_users.add(user.id)
|
||||
elif self.it_manager_id and user.id == emp.company_id.it_manager_id.user_id.id:
|
||||
processed_users.add(user.id)
|
||||
elif self.admin_manager_id and user.id == emp.company_id.admin_manager_id.user_id.id:
|
||||
processed_users.add(user.id)
|
||||
elif self.financial_manager_id and user.id == emp.company_id.financial_manager_id.user_id.id:
|
||||
processed_users.add(user.id)
|
||||
elif self.cyber_security_id and user.id == emp.company_id.cyber_security_id.user_id.id:
|
||||
processed_users.add(user.id)
|
||||
else:
|
||||
processed_users.add(user.id)
|
||||
else:
|
||||
processed_users.add(user.id)
|
||||
return list(processed_users)
|
||||
|
||||
def get_notify_message(self, record):
|
||||
user_ids = self.access_users_ids(self.notify_to_groups_ids, record)
|
||||
today = datetime.today()
|
||||
|
||||
for user in user_ids:
|
||||
data = {
|
||||
'res_id': record.id,
|
||||
'res_model_id': self.env['ir.model'].search([('model', '=', record._name)]).id,
|
||||
'user_id': user,
|
||||
'summary': _(self.name or 'Notification'),
|
||||
'activity_type_id': self.env.ref('mail.mail_activity_data_todo').id,
|
||||
'date_deadline': today
|
||||
}
|
||||
self.env['mail.activity'].create(data)
|
||||
|
||||
if self.hr_notifys:
|
||||
if not user_ids and self.notify_to_groups_ids:
|
||||
if hasattr(record, 'employee_id') and record.employee_id:
|
||||
hr_manager_user = record.employee_id.sudo().company_id.hr_manager_id.user_id.id
|
||||
data = {
|
||||
'res_id': record.id,
|
||||
'res_model_id': self.env['ir.model'].search([('model', '=', record._name)]).id,
|
||||
'user_id': hr_manager_user,
|
||||
'summary': _(self.name or 'Notification'),
|
||||
'activity_type_id': self.env.ref('mail.mail_activity_data_todo').id,
|
||||
'date_deadline': today
|
||||
}
|
||||
self.env['mail.activity'].create(data)
|
||||
|
||||
def get_mail_to(self, record):
|
||||
users = self.access_users(self.notify_to_groups_ids, record)
|
||||
if self.hr_notifys:
|
||||
if not users and self.notify_to_groups_ids:
|
||||
if hasattr(record, 'employee_id') and record.employee_id:
|
||||
hr_manager_mail = record.employee_id.sudo().company_id.hr_manager_id.user_id.partner_id.email
|
||||
users = hr_manager_mail
|
||||
return users
|
||||
|
||||
def get_mail_cc(self, record):
|
||||
users = self.access_users(self.notify_cc_groups_ids, record)
|
||||
if self.hr_notifys:
|
||||
if not users and self.notify_cc_groups_ids:
|
||||
if hasattr(record, 'employee_id') and record.employee_id:
|
||||
hr_mail = record.employee_id.sudo().company_id.hr_email
|
||||
users = hr_mail
|
||||
return users
|
||||
|
||||
def _process(self, records, domain_post=None):
|
||||
result = super()._process(records, domain_post)
|
||||
if self.send_notify:
|
||||
for record in records:
|
||||
self.get_notify_message(record)
|
||||
return result
|
||||
|
||||
|
||||
class MailActivity(models.Model):
|
||||
_inherit = 'mail.activity'
|
||||
|
||||
def action_notify(self):
|
||||
if not self:
|
||||
return
|
||||
|
||||
original_context = self.env.context
|
||||
body_template = self.env.ref('mail.message_activity_assigned')
|
||||
|
||||
for activity in self:
|
||||
if activity.user_id.lang:
|
||||
self = self.with_context(lang=activity.user_id.lang)
|
||||
body_template = body_template.with_context(lang=activity.user_id.lang)
|
||||
activity = activity.with_context(lang=activity.user_id.lang)
|
||||
|
||||
model_description = self.env['ir.model']._get(activity.res_model).display_name
|
||||
|
||||
body = body_template._render(
|
||||
{
|
||||
'activity': activity,
|
||||
'model_description': model_description,
|
||||
'access_link': self.env['mail.thread']._notify_get_action_link(
|
||||
'view',
|
||||
model=activity.res_model,
|
||||
res_id=activity.res_id
|
||||
),
|
||||
},
|
||||
engine='ir.qweb',
|
||||
minimal_qcontext=True
|
||||
)
|
||||
|
||||
record = self.env[activity.res_model].browse(activity.res_id)
|
||||
if activity.user_id:
|
||||
record.message_post(
|
||||
body=body,
|
||||
subject=_('%(activity_name)s: %(summary)s assigned to you',
|
||||
activity_name=activity.res_name,
|
||||
summary=activity.summary or activity.activity_type_id.name
|
||||
),
|
||||
partner_ids=activity.user_id.partner_id.ids,
|
||||
email_layout_xmlid='system_notification.mail_notification_odex',
|
||||
message_type='notification'
|
||||
)
|
||||
|
||||
body_template = body_template.with_context(original_context)
|
||||
self = self.with_context(original_context)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_automation_group_emp,automation.group.emp,model_automation_group,base.group_user,1,1,1,0
|
||||
|
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
@media (min-width: 768px){
|
||||
.rtl .navbar-right{
|
||||
float: left !important;
|
||||
}
|
||||
.rtl .navbar-right .dropdown .dropdown-menu{
|
||||
right: auto !important;
|
||||
left: 0 !important;
|
||||
}
|
||||
.rtl .navbar-left{
|
||||
float: right !important;
|
||||
}
|
||||
.rtl .navbar-left .dropdown .dropdown-menu{
|
||||
left: auto !important;
|
||||
right: 0 !important;
|
||||
}
|
||||
.navbar-nav.navbar-right:last-child{
|
||||
margin-left: auto;
|
||||
}
|
||||
.rtl .pull-left{
|
||||
float: right !important;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
<odoo>
|
||||
<data>
|
||||
<!-- base.automation inherit form view -->
|
||||
<record id="view_base_automation_form" model="ir.ui.view">
|
||||
<field name="name">base.automation.inherit.view.form</field>
|
||||
<field name="model">base.automation</field>
|
||||
<field name="inherit_id" ref="base_automation.view_base_automation_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<!-- إضافة الحقول بعد model_id -->
|
||||
<xpath expr="//field[@name='model_id']" position="after">
|
||||
<field name="send_notify"/>
|
||||
<field name="hr_notifys"/>
|
||||
</xpath>
|
||||
|
||||
<!-- إضافة التبويبات في النوت بوك -->
|
||||
<xpath expr="//notebook" position="inside">
|
||||
<page string="System Notification" name="system_notification">
|
||||
<group>
|
||||
<group string="Notification Settings">
|
||||
<field name="send_notify"/>
|
||||
<field name="hr_notifys"/>
|
||||
<field name="notify_to_groups_ids" widget="many2many_tags"/>
|
||||
<field name="notify_cc_groups_ids" widget="many2many_tags"/>
|
||||
<field name="notify_title"/>
|
||||
<field name="notify_summary"/>
|
||||
<field name="notify_note"/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
|
||||
<page string="HR Notification Data" name="hr_notifications">
|
||||
<group>
|
||||
<group>
|
||||
<field name="department_manager_notify"/>
|
||||
<field name="direct_manager_notify"/>
|
||||
<field name="employee_notify"/>
|
||||
<field name="ceo_notify"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="services_manager_id"/>
|
||||
<field name="hr_manager_notify"/>
|
||||
<field name="hr_email_notify"/>
|
||||
<field name="financial_manager_id"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="it_manager_id"/>
|
||||
<field name="cyber_security_id"/>
|
||||
<field name="admin_manager_id"/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<menuitem name="System Notification" id="system_notification.menu_root"/>
|
||||
|
||||
<record id="base_automation.menu_base_automation_form" model="ir.ui.menu">
|
||||
<field name="name">System Notifications</field>
|
||||
<field name="parent_id" ref="system_notification.menu_root"/>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<!-- Automation Form View -->
|
||||
<record id="view_base_group_automation_form" model="ir.ui.view">
|
||||
<field name="name">Automations</field>
|
||||
<field name="model">automation.group</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="model_id"/>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Automated Actions">
|
||||
<field name="atuomation_ids" context="{'default_model_id': model_id}">
|
||||
<list>
|
||||
<field name="name"/>
|
||||
<field name="model_id"/>
|
||||
<!-- <field name="state"/>-->
|
||||
<field name="trigger"/>
|
||||
<field name="active"/>
|
||||
</list>
|
||||
<form>
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="model_id"/>
|
||||
<!-- <field name="state"/>-->
|
||||
<field name="trigger"/>
|
||||
<field name="active"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Automation List View -->
|
||||
<record id="view_base_group_automation_list" model="ir.ui.view">
|
||||
<field name="name">base.automation.list</field>
|
||||
<field name="model">automation.group</field>
|
||||
<field name="arch" type="xml">
|
||||
<list string="Automation Groups">
|
||||
<field name="model_id"/>
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Automation Action -->
|
||||
<record id="base_automation_act" model="ir.actions.act_window">
|
||||
<field name="name">Automated Actions</field>
|
||||
<field name="res_model">automation.group</field>
|
||||
<field name="view_mode">list,form</field>
|
||||
<field name="view_id" ref="view_base_group_automation_list"/>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_create">
|
||||
Click to setup a new automated automation.
|
||||
</p>
|
||||
<p>
|
||||
Use automated actions to automatically trigger actions for
|
||||
various screens. Example: a lead created by a specific user may
|
||||
be automatically set to a specific sales channel, or an
|
||||
opportunity which still has status pending after 14 days might
|
||||
trigger an automatic reminder email.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_base_group_automation_form"
|
||||
parent="base_automation.menu_base_automation_form"
|
||||
name="states notification"
|
||||
action="base_automation_act"/>
|
||||
</odoo>
|
||||
Loading…
Reference in New Issue