modifying system email templates
This commit is contained in:
parent
4989de4f76
commit
27cbf9d1cd
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -48,14 +48,12 @@
|
|||
</table>
|
||||
</p><br/>
|
||||
<p style="font-size: 1.1em; text-align: right;">
|
||||
<a href="${object.get_url()}" target="_blank">
|
||||
<a href="${object.get_url()}" target="_blank" style="background-color: #3F5D7E; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;">
|
||||
رابط المعاملة
|
||||
</a>
|
||||
</p>
|
||||
<p style="font-size: 1.1em;text-align: right">
|
||||
<a href="${user.company_id.website}">${user.company_id.name}</a>
|
||||
|
||||
|
||||
<p style="font-size: 1.1em;text-align: right; color: #3F5D7E;">
|
||||
تم الإرسال بواسطة <span style="color: #3F5D7E; font-weight: bold;">${user.company_id.name}</span> باستخدام <span style="color: #3F5D7E; font-weight: bold;">اودكس</span>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -48,10 +48,12 @@
|
|||
</table>
|
||||
</p><br/>
|
||||
<p style="font-size: 1.1em;text-align: right">
|
||||
<a href="${object.get_url()}">رابط المعاملة</a>
|
||||
<a href="${object.get_url()}" target="_blank" style="background-color: #3F5D7E; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;">
|
||||
رابط المعاملة
|
||||
</a>
|
||||
</p>
|
||||
<p style="font-size: 1.1em;text-align: right">
|
||||
<a href="${user.company_id.website}">${user.company_id.name}</a>
|
||||
<p style="font-size: 1.1em;text-align: right; color: #3F5D7E;">
|
||||
تم الإرسال بواسطة <span style="color: #3F5D7E; font-weight: bold;">${user.company_id.name}</span> باستخدام <span style="color: #3F5D7E; font-weight: bold;">اودكس</span>
|
||||
</p>
|
||||
</div>
|
||||
]]>
|
||||
|
|
@ -245,11 +247,12 @@
|
|||
</table>
|
||||
</p><br/>
|
||||
<p style="font-size: 1.1em; text-align: right;">
|
||||
<a href="${object.get_url()}" target="_blank">
|
||||
<a href="${object.get_url()}" target="_blank" style="background-color: #3F5D7E; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;">
|
||||
رابط المعاملة
|
||||
</a>
|
||||
</p>
|
||||
<p style="font-size: 1.1em;text-align: right">
|
||||
<p style="font-size: 1.1em;text-align: right; color: #3F5D7E;">
|
||||
تم الإرسال بواسطة <span style="color: #3F5D7E; font-weight: bold;">${user.company_id.name}</span> باستخدام <span style="color: #3F5D7E; font-weight: bold;">اودكس</span>
|
||||
<a href="${user.company_id.website}">${user.company_id.name}</a>
|
||||
</p>
|
||||
</div>
|
||||
|
|
@ -318,9 +321,12 @@
|
|||
</table>
|
||||
</p><br/>
|
||||
<p style="font-size: 1.1em;text-align: right;">
|
||||
<a href="${object.get_url()}">رابط المعاملة</a>
|
||||
<a href="${object.get_url()}" target="_blank" style="background-color: #3F5D7E; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;">
|
||||
رابط المعاملة
|
||||
</a>
|
||||
</p>
|
||||
<p style="font-size: 1.1em;text-align: right">
|
||||
<p style="font-size: 1.1em;text-align: right; color: #3F5D7E;">
|
||||
تم الإرسال بواسطة <span style="color: #3F5D7E; font-weight: bold;">${user.company_id.name}</span> باستخدام <span style="color: #3F5D7E; font-weight: bold;">اودكس</span>
|
||||
<a href="${user.company_id.website}">${user.company_id.name}</a>
|
||||
</p>
|
||||
</div>
|
||||
|
|
@ -381,9 +387,12 @@
|
|||
</table>
|
||||
</p><br/>
|
||||
<p style="font-size: 1.1em;text-align: right;">
|
||||
<a href="${object.get_url()}">رابط المعاملة</a>
|
||||
<a href="${object.get_url()}" target="_blank" style="background-color: #3F5D7E; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;">
|
||||
رابط المعاملة
|
||||
</a>
|
||||
</p>
|
||||
<p style="font-size: 1.1em;text-align: right">
|
||||
تم الإرسال بواسطة <span style="color: #3F5D7E; font-weight: bold;">${user.company_id.name}</span> باستخدام <span style="color: #3F5D7E; font-weight: bold;">اودكس</span>
|
||||
<a href="${user.company_id.website}">${user.company_id.name}</a>
|
||||
</p>
|
||||
</div>
|
||||
|
|
@ -437,10 +446,12 @@
|
|||
</table>
|
||||
</p><br/>
|
||||
<p style="font-size: 1.1em;text-align: right;">
|
||||
<a href="${object.get_url()}">رابط المعاملة</a>
|
||||
<a href="${object.get_url()}" target="_blank" style="background-color: #3F5D7E; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;">
|
||||
رابط المعاملة
|
||||
</a>
|
||||
</p>
|
||||
<p style="font-size: 1.1em;text-align: right">
|
||||
<a href="${user.company_id.website}">${user.company_id.name}</a>
|
||||
تم الإرسال بواسطة <span style="color: #3F5D7E; font-weight: bold;">${user.company_id.name}</span> باستخدام <span style="color: #3F5D7E; font-weight: bold;">اودكس</span>
|
||||
</p>
|
||||
</div>
|
||||
]]>
|
||||
|
|
@ -507,11 +518,13 @@
|
|||
<br/>
|
||||
|
||||
<p style="font-size: 1.1em;text-align: right">
|
||||
<a href="${object.get_url()}">رابط المعاملة</a>
|
||||
<a href="${object.get_url()}" target="_blank" style="background-color: #3F5D7E; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;">
|
||||
رابط المعاملة
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p style="font-size: 1.1em;text-align: right">
|
||||
<a href="${user.company_id.website}">${user.company_id.name}</a>
|
||||
تم الإرسال بواسطة <span style="color: #3F5D7E; font-weight: bold;">${user.company_id.name}</span> باستخدام <span style="color: #3F5D7E; font-weight: bold;">اودكس</span>
|
||||
|
||||
|
||||
</p>
|
||||
|
|
@ -579,11 +592,13 @@
|
|||
<br/>
|
||||
|
||||
<p style="font-size: 1.1em;text-align: right">
|
||||
<a href="${object.get_url()}">رابط المعاملة</a>
|
||||
<a href="${object.get_url()}" target="_blank" style="background-color: #3F5D7E; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;">
|
||||
رابط المعاملة
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p style="font-size: 1.1em;text-align: right">
|
||||
<a href="${user.company_id.website}">${user.company_id.name}</a>
|
||||
تم الإرسال بواسطة <span style="color: #3F5D7E; font-weight: bold;">${user.company_id.name}</span> باستخدام <span style="color: #3F5D7E; font-weight: bold;">اودكس</span>
|
||||
|
||||
|
||||
</p>
|
||||
|
|
@ -651,11 +666,13 @@
|
|||
<br/>
|
||||
|
||||
<p style="font-size: 1.1em;text-align: right">
|
||||
<a href="${object.get_url()}">رابط المعاملة</a>
|
||||
<a href="${object.get_url()}" target="_blank" style="background-color: #3F5D7E; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;">
|
||||
رابط المعاملة
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p style="font-size: 1.1em;text-align: right">
|
||||
<a href="${user.company_id.website}">${user.company_id.name}</a>
|
||||
تم الإرسال بواسطة <span style="color: #3F5D7E; font-weight: bold;">${user.company_id.name}</span> باستخدام <span style="color: #3F5D7E; font-weight: bold;">اودكس</span>
|
||||
</p>
|
||||
</div>
|
||||
]]>
|
||||
|
|
@ -708,10 +725,12 @@
|
|||
</p><br/>
|
||||
<br/>
|
||||
<p style="font-size: 1.1em;text-align: right">
|
||||
<a href="${object.get_url()}">رابط المعاملة</a>
|
||||
<a href="${object.get_url()}" target="_blank" style="background-color: #3F5D7E; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;">
|
||||
رابط المعاملة
|
||||
</a>
|
||||
</p>
|
||||
<p style="font-size: 1.1em;text-align: right">
|
||||
<a href="${user.company_id.website}">${user.company_id.name}</a>
|
||||
تم الإرسال بواسطة <span style="color: #3F5D7E; font-weight: bold;">${user.company_id.name}</span> باستخدام <span style="color: #3F5D7E; font-weight: bold;">اودكس</span>
|
||||
</p>
|
||||
</div>
|
||||
]]>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,94 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<!-- Inherit and customize the system_notification mail notification template -->
|
||||
<template id="mail_notification_odex_custom" inherit_id="system_notification.mail_notification_odex">
|
||||
<!-- Replace Odoo logo with ODEX logo -->
|
||||
<xpath expr="//img[@t-att-src]" position="replace">
|
||||
<img t-att-src="(website_url or (company and company.get_base_url() or '')) + '/exp_transaction_documents/static/src/img/Odex-logo.png'"
|
||||
style="padding: 0px; margin: 0px; height: 48px; max-width: 200px;"
|
||||
alt="ODEX"/>
|
||||
</xpath>
|
||||
|
||||
<!-- Update footer text -->
|
||||
<xpath expr="//div[contains(@style, 'color: #999999')]" position="replace">
|
||||
<div style="color: #999999; text-align: center; direction: rtl;">
|
||||
<p style="margin: 8px 0; color: #000000; font-weight: bold;">
|
||||
تم الإرسال بواسطة <span style="color: #3F5D7E; font-weight: bold;"><t t-esc="company.name"/></span> باستخدام <span style="color: #3F5D7E; font-weight: bold;">أودكس</span>
|
||||
</p>
|
||||
<div>
|
||||
<t t-esc="company.phone"/>
|
||||
<t t-if="company.email"> |
|
||||
<a t-att-href="'mailto:%s' % company.email" style="text-decoration:none; color: #999999;"><t t-esc="company.email"/></a>
|
||||
</t>
|
||||
<t t-if="company.website"> |
|
||||
<a t-att-href="'%s' % company.website" style="text-decoration:none; color: #999999;">
|
||||
<t t-esc="company.website"/>
|
||||
</a>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<!-- Inherit and customize the default Odoo mail.message_notification_email template -->
|
||||
<!-- This template is used for emails sent from chatter -->
|
||||
<!-- File location: d:\Khabir\odoo14-addons\addons\mail\data\mail_data.xml -->
|
||||
<template id="message_notification_email_custom" inherit_id="mail.message_notification_email">
|
||||
<!-- Replace Odoo logo with ODEX logo -->
|
||||
<!-- Original: <img t-att-src="'/logo.png?company=%s' % (company.id or 0)" .../> -->
|
||||
<!-- Using t-att-src with base URL - Python method will also fix this -->
|
||||
<xpath expr="//td[@valign='center' and @align='right']//img[@t-att-src]" position="replace">
|
||||
<img t-att-src="(website_url or (company and company.get_base_url() or '')) + '/exp_transaction_documents/static/src/img/Odex-logo.png'"
|
||||
style="padding: 0px; margin: 0px; height: auto; max-width: 200px; max-height: 36px;"
|
||||
alt="ODEX"/>
|
||||
</xpath>
|
||||
|
||||
<!-- Update footer text "Sent by ... using Odoo" -->
|
||||
<xpath expr="//p[contains(@style, 'color: #555555')]" position="replace">
|
||||
<p style="color: #000000; margin-top:32px; font-weight: bold; text-align: right; direction: rtl;">
|
||||
تم الإرسال بواسطة
|
||||
<span t-if="company.name">
|
||||
<a t-if="website_url" t-att-href="website_url" style="text-decoration:none; color: #3F5D7E; font-weight: bold;">
|
||||
<span t-esc="company.name"/>
|
||||
</a>
|
||||
<span t-if="not website_url" style="color: #3F5D7E; font-weight: bold;" t-esc="company.name"/>
|
||||
</span>
|
||||
باستخدام
|
||||
<span style="color: #3F5D7E; font-weight: bold;">أودكس</span>
|
||||
</p>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<!-- Inherit and customize mail.mail_notification_light template -->
|
||||
<!-- This template is also commonly used for email notifications -->
|
||||
<template id="mail_notification_light_custom" inherit_id="mail.mail_notification_light">
|
||||
<!-- Replace Odoo logo with ODEX logo -->
|
||||
<xpath expr="//img[@t-att-src]" position="replace">
|
||||
<img t-att-src="'/exp_transaction_documents/static/src/img/Odex-logo.png'"
|
||||
style="padding: 0px; margin: 0px; height: 48px;"
|
||||
alt="ODEX"/>
|
||||
</xpath>
|
||||
|
||||
<!-- Update footer text -->
|
||||
<xpath expr="//div[contains(@style, 'color: #999999')]" position="replace">
|
||||
<div style="color: #999999; text-align: center; direction: rtl;">
|
||||
<p style="margin: 8px 0; color: #000000; font-weight: bold;">
|
||||
تم الإرسال بواسطة <span style="color: #3F5D7E; font-weight: bold;"><t t-esc="company.name"/></span> باستخدام <span style="color: #3F5D7E; font-weight: bold;">أودكس</span>
|
||||
</p>
|
||||
<div>
|
||||
<t t-esc="company.phone"/>
|
||||
<t t-if="company.email"> |
|
||||
<a t-att-href="'mailto:%s' % company.email" style="text-decoration:none; color: #999999;"><t t-esc="company.email"/></a>
|
||||
</t>
|
||||
<t t-if="company.website"> |
|
||||
<a t-att-href="'%s' % company.website" style="text-decoration:none; color: #999999;">
|
||||
<t t-esc="company.website"/>
|
||||
</a>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
@ -44,14 +44,12 @@
|
|||
</table>
|
||||
</p><br/>
|
||||
<p style="font-size: 1.1em; text-align: right;">
|
||||
<a href="${object.get_url()}" target="_blank">
|
||||
<a href="${object.get_url()}" target="_blank" style="background-color: #3F5D7E; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;">
|
||||
رابط المعاملة
|
||||
</a>
|
||||
</p>
|
||||
<p style="font-size: 1.1em;text-align: right">
|
||||
<a href="${user.company_id.website}">${user.company_id.name}</a>
|
||||
|
||||
|
||||
<p style="font-size: 1.1em;text-align: right; color: #3F5D7E;">
|
||||
تم الإرسال بواسطة <span style="color: #3F5D7E; font-weight: bold;">${user.company_id.name}</span> باستخدام <span style="color: #3F5D7E; font-weight: bold;">اودكس</span>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
|
@ -113,12 +111,12 @@
|
|||
</table>
|
||||
</p><br/>
|
||||
<p style="font-size: 1.1em;text-align: right;">
|
||||
<a href="${object.get_url()}">رابط المعاملة</a>
|
||||
<a href="${object.get_url()}" target="_blank" style="background-color: #3F5D7E; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;">
|
||||
رابط المعاملة
|
||||
</a>
|
||||
</p>
|
||||
<p style="font-size: 1.1em;text-align: right">
|
||||
<a href="${user.company_id.website}">${user.company_id.name}</a>
|
||||
|
||||
|
||||
<p style="font-size: 1.1em;text-align: right; color: #3F5D7E;">
|
||||
تم الإرسال بواسطة <span style="color: #3F5D7E; font-weight: bold;">${user.company_id.name}</span> باستخدام <span style="color: #3F5D7E; font-weight: bold;">اودكس</span>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
|
@ -180,10 +178,12 @@
|
|||
</table>
|
||||
</p><br/>
|
||||
<p style="font-size: 1.1em;text-align: right;">
|
||||
<a href="${object.get_url()}">رابط المعاملة</a>
|
||||
<a href="${object.get_url()}" target="_blank" style="background-color: #3F5D7E; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;">
|
||||
رابط المعاملة
|
||||
</a>
|
||||
</p>
|
||||
<p style="font-size: 1.1em;text-align: right">
|
||||
<a href="${user.company_id.website}">${user.company_id.name}</a>
|
||||
تم الإرسال بواسطة <span style="color: #3F5D7E; font-weight: bold;">${user.company_id.name}</span> باستخدام <span style="color: #3F5D7E; font-weight: bold;">اودكس</span>
|
||||
|
||||
|
||||
</p>
|
||||
|
|
@ -235,12 +235,12 @@
|
|||
</table>
|
||||
</p><br/>
|
||||
<p style="font-size: 1.1em;text-align: right;">
|
||||
<a href="${object.get_url()}">رابط المعاملة</a>
|
||||
<a href="${object.get_url()}" target="_blank" style="background-color: #3F5D7E; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;">
|
||||
رابط المعاملة
|
||||
</a>
|
||||
</p>
|
||||
<p style="font-size: 1.1em;text-align: right">
|
||||
<a href="${user.company_id.website}">${user.company_id.name}</a>
|
||||
|
||||
|
||||
<p style="font-size: 1.1em;text-align: right; color: #3F5D7E;">
|
||||
تم الإرسال بواسطة <span style="color: #3F5D7E; font-weight: bold;">${user.company_id.name}</span> باستخدام <span style="color: #3F5D7E; font-weight: bold;">اودكس</span>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -7,4 +7,5 @@ from . import internal_transaction
|
|||
from . import outgoing_transaction
|
||||
from . import incoming_transaction
|
||||
from . import tools
|
||||
from . import mail_thread
|
||||
#
|
||||
|
|
|
|||
|
|
@ -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('<img', '<img src="%s" ' % absolute_logo_url, 1)
|
||||
return img_tag
|
||||
|
||||
# Replace img tags with alt="ODEX"
|
||||
body_html = re.sub(
|
||||
r'<img[^>]*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 <a> 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)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 109 KiB |
Loading…
Reference in New Issue