diff --git a/odex25_transactions/exp_transaction_documents/__manifest__.py b/odex25_transactions/exp_transaction_documents/__manifest__.py index a43582da9..8f828dbad 100644 --- a/odex25_transactions/exp_transaction_documents/__manifest__.py +++ b/odex25_transactions/exp_transaction_documents/__manifest__.py @@ -19,11 +19,12 @@ Managing Communications Transcations flows """, 'website': 'http://www.exp-sa.com', 'depends': ['base', 'base_odex', 'mail','attachment_indexation','odex25_sign','html_text', 'odex_sms','sale', - 'sale_management'], + 'sale_management','system_notification'], 'data': [ 'security/groups.xml', 'security/ir.model.access.csv', 'email_templates/out_templates.xml', + 'email_templates/mail_notification_template.xml', 'data/cm_data.xml', 'data/ir_cron.xml', 'views/entity.xml', diff --git a/odex25_transactions/exp_transaction_documents/email_templates/incoming_templates.xml b/odex25_transactions/exp_transaction_documents/email_templates/incoming_templates.xml index ed9a46b95..fe984d65b 100644 --- a/odex25_transactions/exp_transaction_documents/email_templates/incoming_templates.xml +++ b/odex25_transactions/exp_transaction_documents/email_templates/incoming_templates.xml @@ -48,14 +48,12 @@


- + رابط المعاملة

-

- ${user.company_id.name} - - +

+ تم الإرسال بواسطة ${user.company_id.name} باستخدام اودكس

diff --git a/odex25_transactions/exp_transaction_documents/email_templates/internal_templates.xml b/odex25_transactions/exp_transaction_documents/email_templates/internal_templates.xml index 63f1526a2..5d1650760 100644 --- a/odex25_transactions/exp_transaction_documents/email_templates/internal_templates.xml +++ b/odex25_transactions/exp_transaction_documents/email_templates/internal_templates.xml @@ -48,10 +48,12 @@


- رابط المعاملة + + رابط المعاملة +

-

- ${user.company_id.name} +

+ تم الإرسال بواسطة ${user.company_id.name} باستخدام اودكس

]]> @@ -245,11 +247,12 @@


- + رابط المعاملة

-

+

+ تم الإرسال بواسطة ${user.company_id.name} باستخدام اودكس ${user.company_id.name}

@@ -318,9 +321,12 @@


- رابط المعاملة + + رابط المعاملة +

-

+

+ تم الإرسال بواسطة ${user.company_id.name} باستخدام اودكس ${user.company_id.name}

@@ -381,9 +387,12 @@


- رابط المعاملة + + رابط المعاملة +

+ تم الإرسال بواسطة ${user.company_id.name} باستخدام اودكس ${user.company_id.name}

@@ -437,10 +446,12 @@


- رابط المعاملة + + رابط المعاملة +

- ${user.company_id.name} + تم الإرسال بواسطة ${user.company_id.name} باستخدام اودكس

]]> @@ -507,11 +518,13 @@

- رابط المعاملة + + رابط المعاملة +

- ${user.company_id.name} + تم الإرسال بواسطة ${user.company_id.name} باستخدام اودكس

@@ -579,11 +592,13 @@

- رابط المعاملة + + رابط المعاملة +

- ${user.company_id.name} + تم الإرسال بواسطة ${user.company_id.name} باستخدام اودكس

@@ -651,11 +666,13 @@

- رابط المعاملة + + رابط المعاملة +

- ${user.company_id.name} + تم الإرسال بواسطة ${user.company_id.name} باستخدام اودكس

]]> @@ -708,10 +725,12 @@



- رابط المعاملة + + رابط المعاملة +

- ${user.company_id.name} + تم الإرسال بواسطة ${user.company_id.name} باستخدام اودكس

]]> diff --git a/odex25_transactions/exp_transaction_documents/email_templates/mail_notification_template.xml b/odex25_transactions/exp_transaction_documents/email_templates/mail_notification_template.xml new file mode 100644 index 000000000..81a7598a2 --- /dev/null +++ b/odex25_transactions/exp_transaction_documents/email_templates/mail_notification_template.xml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + diff --git a/odex25_transactions/exp_transaction_documents/email_templates/out_templates.xml b/odex25_transactions/exp_transaction_documents/email_templates/out_templates.xml index 964ee9e82..529437e02 100644 --- a/odex25_transactions/exp_transaction_documents/email_templates/out_templates.xml +++ b/odex25_transactions/exp_transaction_documents/email_templates/out_templates.xml @@ -44,14 +44,12 @@


- + رابط المعاملة

-

- ${user.company_id.name} - - +

+ تم الإرسال بواسطة ${user.company_id.name} باستخدام اودكس

@@ -113,12 +111,12 @@


- رابط المعاملة + + رابط المعاملة +

-

- ${user.company_id.name} - - +

+ تم الإرسال بواسطة ${user.company_id.name} باستخدام اودكس

@@ -180,10 +178,12 @@


- رابط المعاملة + + رابط المعاملة +

- ${user.company_id.name} + تم الإرسال بواسطة ${user.company_id.name} باستخدام اودكس

@@ -235,12 +235,12 @@


- رابط المعاملة + + رابط المعاملة +

-

- ${user.company_id.name} - - +

+ تم الإرسال بواسطة ${user.company_id.name} باستخدام اودكس

diff --git a/odex25_transactions/exp_transaction_documents/models/__init__.py b/odex25_transactions/exp_transaction_documents/models/__init__.py index 852cb75bd..f84c9155d 100644 --- a/odex25_transactions/exp_transaction_documents/models/__init__.py +++ b/odex25_transactions/exp_transaction_documents/models/__init__.py @@ -7,4 +7,5 @@ from . import internal_transaction from . import outgoing_transaction from . import incoming_transaction from . import tools +from . import mail_thread # diff --git a/odex25_transactions/exp_transaction_documents/models/mail_thread.py b/odex25_transactions/exp_transaction_documents/models/mail_thread.py new file mode 100644 index 000000000..d380cf417 --- /dev/null +++ b/odex25_transactions/exp_transaction_documents/models/mail_thread.py @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- + +import re +import logging +from odoo import models, api + +_logger = logging.getLogger(__name__) + + +class MailMail(models.Model): + _inherit = 'mail.mail' + + @api.model + def create(self, vals): + """Override create to modify email HTML: fix logo and button colors""" + # Modify body_html before creating the record + if vals.get('body_html'): + body_html = vals['body_html'] + + # Fix logo path - use correct base URL + # Get base URL from system parameter OR company + base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') + if not base_url: + try: + base_url = self.env.company.get_base_url() if hasattr(self.env, 'company') and self.env.company else '' + except: + base_url = '' + + if base_url: + logo_path = '/exp_transaction_documents/static/src/img/Odex-logo.png' + absolute_logo_url = '%s%s' % (base_url.rstrip('/'), logo_path) + + # Replace img tag src with absolute URL + def fix_logo_url(match): + img_tag = match.group(0) + # Remove loading="lazy" attribute + img_tag = re.sub(r'\s+loading\s*=\s*["\'][^"\']*["\']', '', img_tag, flags=re.IGNORECASE) + + # Replace src with absolute URL + if 'src=' in img_tag: + img_tag = re.sub( + r'src\s*=\s*["\'][^"\']*["\']', + r'src="%s"' % absolute_logo_url, + img_tag, + flags=re.IGNORECASE + ) + else: + if 'alt=' in img_tag: + img_tag = re.sub( + r'(alt=["\']ODEX["\'])', + r'\1 src="%s"' % absolute_logo_url, + img_tag, + flags=re.IGNORECASE + ) + else: + img_tag = img_tag.replace(']*alt=["\']ODEX["\'][^>]*>', + fix_logo_url, + body_html, + flags=re.IGNORECASE + ) + + _logger.info("Logo URL set to: %s", absolute_logo_url) + + # Change button background color from #875A7B to #3F5D7E + # This replaces inline styles in tags + body_html = re.sub( + r'background-color:\s*#875A7B', + r'background-color: #3F5D7E', + body_html + ) + body_html = re.sub( + r'border:\s*0px\s+solid\s+#875A7B', + r'border: 0px solid #3F5D7E', + body_html + ) + # Also handle buttons without spaces in color code + body_html = re.sub( + r'background-color:#875A7B', + r'background-color: #3F5D7E', + body_html + ) + body_html = re.sub( + r'border:0px\s+solid\s*#875A7B', + r'border: 0px solid #3F5D7E', + body_html + ) + + vals['body_html'] = body_html + + # Create mail record + return super(MailMail, self).create(vals) + diff --git a/odex25_transactions/exp_transaction_documents/static/src/img/Odex-logo.png b/odex25_transactions/exp_transaction_documents/static/src/img/Odex-logo.png new file mode 100644 index 000000000..7a277c643 Binary files /dev/null and b/odex25_transactions/exp_transaction_documents/static/src/img/Odex-logo.png differ