update system notification from zfp

This commit is contained in:
Bakry 2024-07-10 17:16:27 +03:00
parent 1e670e3af4
commit eba5834cbf
5 changed files with 95 additions and 17 deletions

View File

@ -7,14 +7,12 @@
'description': """
""",
'category' : 'Odex25-base',
# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/11.0/odoo/addons/base/module/module_data.xml
# for the full list
# any module necessary for this one to work correctly
'depends': ['base_automation'],
'depends': ['base_automation','mail'],
# always loaded
'data': [

View File

@ -31,7 +31,7 @@ msgid "Automation"
msgstr "أتمتة"
#. module: system_notification
#: model:ir.model.fields,field_description:system_notification.field_base_automation_notify__cc_groups_ids
#: model:ir.model.fields,field_description:system_notification.field_base_automation_notify_cc_groups_ids
msgid "CC Notify Groups"
msgstr "نسخة ايميل لـ"
@ -41,47 +41,47 @@ 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
#: 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
#: 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
#: 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
#: 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
#: 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
#: 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
#: 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
#: 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
#: model:ir.model.fields,field_description:system_notification.field_automation_group_model_id
msgid "Model"
msgstr "اسم الإجراء"
@ -91,10 +91,23 @@ msgid "System Notification"
msgstr "إشعارات النظام"
#. module: system_notification
#: model:ir.model.fields,field_description:system_notification.field_base_automation_notify__to_groups_ids
#: 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.actions.act_window,help:system_notification.base_automation_act
msgid "Use automated actions to automatically trigger actions for\n"
" various screens. Example: a lead created by a specific user may\n"
" be automatically set to a specific sales channel, or an\n"
" opportunity which still has status pending after 14 days might\n"
" trigger an automatic reminder email."
msgstr "استخدم الإجراءات التلقائية لتشغيل الإجراءات تلقائيًا لـ\n"
" شاشات مختلفة. مثال: قد يتم إنشاء عميل محتمل بواسطة مستخدم معين\n"
" يتم تعيينها تلقائيًا إلى قناة مبيعات معينة ، أو ملف\n"
" الفرصة التي لا تزال بحالة معلقة بعد 14 يومًا\n"
" تشغيل رسالة بريد إلكتروني للتذكير التلقائي."
#. module: system_notification
#: model:ir.model,name:system_notification.model_automation_group
msgid "automation.group"

View File

@ -1,11 +1,19 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api
from odoo import models, fields, api
class BaseAutomation(models.Model):
_inherit = 'base.automation'
# add new optine send notify
send_notify = fields.Boolean(string='Send Notify')
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')
# end option
notify_to_groups_ids = fields.Many2many(comodel_name='res.groups',
relation='automation_notifications_to_groups_rel',
string='TO Notify Groups')
@ -29,6 +37,41 @@ class BaseAutomation(models.Model):
if self.has_access(user_id=user.id, record=record, mode='read') and user.partner_id.email:
users.append(user.partner_id.email)
return ",".join(users)
# todo start to add method return access users ids list
def access_users_ids(self, groups, record):
# partner_ids = set()
processed_users = set()
for group in groups:
for user in group.users:
if user.id not in processed_users and self.has_access(user_id=user.id, record=record, mode='read'):
# partner_ids.add(user.partner_id.id)
processed_users.add(user.id)
return list(processed_users)
# def access_partner_ids(self, groups, record):
# partner_ids = []
# for group in groups:
# for user in group.users:
# if self.has_access(user_id = user.id, record=record, mode='read'):
# partner_ids.append(user.partner_id.id)
# return partner_ids
# todo end
def get_notify_message(self,record):
user_ids = self.access_users_ids(self.notify_to_groups_ids, record)
for user in user_ids:
record.activity_schedule('mail.mail_activity_todo', user_id=user,)
# notification_ids = [(0, 0, {'res_partner_id': p,'notification_type': 'inbox'})]
# self.env['mail.message'].sudo().create({
# 'message_type': 'notification',
# 'body': self.notify_note,
# 'subject':self.notify_summary,
# 'model': record._name,
# 'res_id': record.id,
# 'partner_ids': partner_ids,
# 'notification_ids': notification_ids,
# })
# end notify method
def get_mail_to(self, record):
users = self.access_users(self.notify_to_groups_ids, record)
@ -93,5 +136,8 @@ class ServerActions(models.Model):
'email_cc': old_email_cc,
}
action.template_id.write(old_template_values)
if automation.send_notify:
print('true send....')
automation.get_notify_message(record)
return False
return super(ServerActions, self)._run_action_email(eval_context=eval_context)

View File

@ -0,0 +1 @@

View File

@ -8,11 +8,31 @@
<field name="arch" type="xml">
<!-- Add your xpath here -->
<xpath expr="//field[@name='template_id']" position="after">
<!-- add notify option -->
<field name="send_notify"/>
<!-- end -->
<field name="notify_to_groups_ids" widget="many2many_tags"
attrs="{'invisible': [('state', '!=', 'email')],'required': [('state', '=', 'email')]}"/>
<field name="notify_cc_groups_ids" widget="many2many_tags"
attrs="{'invisible': [('state', '!=', 'email')],'required': [('state', '=', 'email')]}"/>
</xpath>
<!-- add notify fields -->
<xpath expr="//notebook" position="inside">
<page string="Notification Data" attrs="{'invisible': [('send_notify', '!=', True)]}">
<group>
<group>
<!-- <field name="notify_to_users" attrs="{'required': [('state', 'in', ['code'])]}" widget="many2many_tags"/>-->
<field name="notify_title" attrs="{'required': [('send_notify', '=', True)]}"/>
</group>
<group>
<field name="notify_summary" attrs="{'required': [('send_notify', '=', True)]}"/>
<field name="notify_note" attrs="{'required': [('send_notify', '=', True)]}"/>
</group>
</group>
</page>
</xpath>
<!-- end -->
</field>
</record>
<menuitem name="System Notification" id="system_notification.menu_root"/>
@ -22,4 +42,4 @@
<field name="parent_id" ref="system_notification.menu_root"/>
</record>
</data>
</odoo>
</odoo>