Skip to content
Permalink
Browse files

⬆️1️⃣2️⃣

  • Loading branch information...
fedoranvar committed Aug 6, 2019
1 parent de9408d commit 361df284c65ef1ae70e35103fffa997e7c14207d
@@ -1,31 +1,40 @@
Allows create signature templates for users. For example,
===================================
Signature templates for user email
===================================

---
Add templated signature for users

<p>${user.name}, ${user.function} of ${user.partner_id.company_id.name}</p>
Credits
=======

<p>${user.phone},
Contributors
------------
* `Ivan Yelizariev <https://it-projects.info/team/yelizariev>`__
* `Anvar Kildebekov <https://it-projects.info/team/kildebekov>`__

% if user.mobile
Sponsors
--------
* `IT-Projects LLC <https://it-projects.info>`__

${user.mobile},
Maintainers
-----------
* `IT-Projects LLC <https://it-projects.info>`__

% endif
To get a guaranteed support you are kindly requested to purchase the module at `odoo apps store <https://apps.odoo.com/apps/modules/12.0/res_users_signature/>`__.

${user.email}</p>
Thank you for understanding!

<p><img src="data:image/png;base64,${user.company_id.logo_web}"/></p>
`IT-Projects Team <https://www.it-projects.info/team>`__

Will be converted to
Further information
===================

---
Demo: http://runbot.it-projects.info/demo/12.0/misc-addons

<p>Bob, sale manager of You Company</p>
HTML Description: https://apps.odoo.com/apps/modules/12.0/res_users_signature/

<p>+123456789, sales@example.com</p>
Usage instructions: `<doc/index.rst>`_

<p><img src="data:image/png;base64,ABCDE....12345="/></p>
Changelog: `<doc/changelog.rst>`_

Tested on 8.0 ab7b5d7732a7c222a0aea45bd173742acd47242d

Further information and discussion: https://yelizariev.github.io/odoo/module/2015/03/17/email-signature-template.html
Tested on Odoo 12.0 32c2666d189047db66eb7b1392ea34b086fd341e
@@ -1 +1,2 @@
from . import res_users_signature_models
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from . import models
@@ -1,15 +1,19 @@
{
'name': 'Signature templates for user emails',
'version': '1.0.0',
'version': '12.0.1.0.0',
'author': 'IT-Projects LLC, Ivan Yelizariev',
'license': 'LGPL-3',
'category': 'Social Network',
'images': ["images/main.png"],
'website': 'https://yelizariev.github.io',
'depends': ['base'],
'data': [
'res_users_signature_views.xml',
'views/res_users_signature_views.xml',
'security/res_users_signature_security.xml',
'security/ir.model.access.csv',
],
'installable': False
'python': [
'html2text',
],
'installable': True
}
@@ -0,0 +1,4 @@
`1.0.0`
-------

- **Init version**
@@ -0,0 +1,44 @@
===================================
Signature templates for user emails
===================================

Installation
============

* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way

Usage
=====

* Open menu ``[[ {Menu} ]]>> {Submenu} >> {Subsubmenu}``
* Click ``[{Button Name}]``

Allows create signature templates for users. For example,

---

<p>${user.name}, ${user.function} of ${user.partner_id.company_id.name}</p>

<p>${user.phone},

% if user.mobile

${user.mobile},

% endif

${user.email}</p>

<p><img src="data:image/png;base64,${user.company_id.logo_web}"/></p>

Will be converted to

---

<p>Bob, sale manager of You Company</p>

<p>+123456789, sales@example.com</p>

<p><img src="data:image/png;base64,ABCDE....12345="/></p>

* RESULT: {what user gets, how the modules changes default behaviour}
Binary file not shown.
@@ -0,0 +1 @@
from . import res_users_signature_models
@@ -1,36 +1,32 @@
from openerp import fields as old_fields
from openerp import api, models, fields, tools
from odoo import api, models, fields, tools
try:
from openerp.addons.email_template.email_template import mako_template_env
from odoo.addons.mail.models.mail_template import mako_template_env
except ImportError:
try:
from openerp.addons.mail.mail_template import mako_template_env
except ImportError:
pass
pass

from openerp.loglevels import ustr
from odoo.loglevels import ustr
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email.utils import COMMASPACE
from email.utils import formatdate
from email.utils import make_msgid
from email import Encoders
from openerp.tools import html2text
from email import encoders

import html2text
import re
import base64

from openerp.addons.base.models.ir_mail_server import encode_rfc2822_address_header, encode_header, encode_header_param
from odoo.addons.base.models.ir_mail_server import encode_rfc2822_address_header, encode_header, encode_header_param


class ResUsers(models.Model):
_inherit = 'res.users'

signature_id = fields.Many2one('res.users.signature', string='Signature template', help='Keep empty to edit signature manually')

'signature': old_fields.Html('Signature', sanitize=False)

_columns = {
'signature': fields.Html('Signature', sanitize=False)
}

@api.one
@api.onchange('signature_id')
@@ -53,6 +49,7 @@ def write(self, vals):

class ResUsersSignature(models.Model):
_name = 'res.users.signature'
_description = 'Users signatures'

name = fields.Char('Name')
comment = fields.Text('Internal note')
@@ -112,7 +109,7 @@ class IrMailServer(models.Model):
def build_email(self, email_from, email_to, subject, body, email_cc=None, email_bcc=None, reply_to=False,
attachments=None, message_id=None, references=None, object_id=False, subtype='plain', headers=None,
body_alternative=None, subtype_alternative='plain'):
""" copy-pasted from openerp/addons/base/models/ir_mail_server.py::build_email """
""" copy-pasted from odoo/addons/base/models/ir_mail_server.py::build_email """

ftemplate = '__image-%s__'
fcounter = 0
@@ -184,7 +181,7 @@ def build_email(self, email_from, email_to, subject, body, email_cc=None, email_
msg['Bcc'] = encode_rfc2822_address_header(COMMASPACE.join(email_bcc))
msg['Date'] = formatdate()
# Custom headers may override normal headers or provide additional ones
for key, value in headers.iteritems():
for key, value in headers.items():
msg[ustr(key).encode('utf-8')] = encode_header(value)

if subtype == 'html' and not body_alternative and html2text:
@@ -212,11 +209,11 @@ def build_email(self, email_from, email_to, subject, body, email_cc=None, email_

# The default RFC2231 encoding of Message.add_header() works in Thunderbird but not GMail
# so we fix it by using RFC2047 encoding for the filename instead.
part.set_param('name', filename_rfc2047)
part.sudo().set_param('name', filename_rfc2047)
part.add_header('Content-Disposition', 'attachment', filename=filename_rfc2047)
part.add_header('Content-ID', '<%s>' % filename_rfc2047) # NEW STUFF

part.set_payload(fcontent)
Encoders.encode_base64(part)
encoders.encode_base64(part)
msg.attach(part)
return msg
@@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="administrator" model="res.groups">
<field name="name">Signature administrator</field>
<field name="comment">the user will have access to edit signatures</field>
</record>

</data>
</openerp>
<odoo>
<record id="administrator" model="res.groups">
<field name="name">Signature administrator</field>
<field name="comment">the user will have access to edit signatures</field>
<field name="users" eval="[(4, ref('base.user_admin'))]"/>
</record>
</odoo>
@@ -0,0 +1,52 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span8">
<h2>Need our service?</h2>
<p class="oe_mt32">Contact us by <a href="mailto:apps@it-projects.info">email</a> or fill out <a href="https://www.it-projects.info/page/website.contactus " target="_blank">request form</a></p>
<ul>
<li><a href="mailto:apps@it-projects.info">apps@it-projects.info <i class="fa fa-envelope-o"></i></a></li>
<li><a href="https://www.it-projects.info/page/website.contactus " target="_blank">https://www.it-projects.info/page/website.contactus <i class="fa fa-list-alt"></i></a></li>
<li><a href="https://m.me/itprojectsllc" target="_blank">https://m.me/itprojectsllc <i class="fa fa-facebook-square"></i></a></li>
<li>skype@it-projects.info <i class="fa fa-skype"></i></li>
</ul>
</div>
<div class="oe_span4">
<div class="stamp" style="width:200px;">
<div style="margin-top: 15px;
position: relative;
font-family:'Vollkorn', serif;
font-size: 16px;
line-height: 25px;
text-transform: uppercase;
font-weight: bold;
color: #75526b;
border: 3px dashed #75526b;
float: left;
padding: 4px 12px;
-webkit-transform: rotate(8deg);
-o-transform: rotate(8deg);
-moz-transform: rotate(8deg);
-ms-transform: rotate(8deg);">
Tested on Odoo<br/>12.0 community
</div>
<!--<div style="margin-top: 15px;
position: relative;
font-family:'Vollkorn', serif;
font-size: 16px;
line-height: 25px;
text-transform: uppercase;
font-weight: bold;
color: #75526b;
border: 3px dashed #75526b;
float: left;
padding: 4px 12px;
-webkit-transform: rotate(6deg);
-o-transform: rotate(6deg);
-moz-transform: rotate(6deg);
-ms-transform: rotate(6deg);">
Tested on Odoo<br/>10.0 enterprise
</div>-->
</div>
</div>
</div>
</section>
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<odoo>

<record id="view_users_form" model="ir.ui.view">
<field name="name">res.users.form</field>
@@ -58,7 +57,7 @@
</field>
</record>


<!--
<record id="action_update_signature_multi" model="ir.actions.server">
<field name="name">Update signatures</field>
<field name="model_id" ref="model_res_users_signature"/>
@@ -74,6 +73,16 @@
<field name="name">Update signatures</field>
<field eval="'ir.actions.server,%d'%action_update_signature_multi" name="value"/>
</record>
-->
<record id="ir_update_signature_multi" model="ir.actions.server">
<field name="name">Update signatures</field>
<field name="model_id" ref="model_res_users_signature"/>
<field name="binding_model_id" ref="model_res_users_signature"/>
<field name="state">code</field>
<field name="code">
self.action_update_signature(cr, uid, context['active_ids'], context=context)
</field>
</record>

<record id="action_res_users_signature" model="ir.actions.act_window">
<field name="name">Signatures</field>
@@ -86,5 +95,4 @@

<menuitem action="action_res_users_signature" id="menu_action_res_users_signature" parent="base.menu_users"/>

</data>
</openerp>
</odoo>
@@ -1,8 +1,43 @@
Signature templates for user emails (HR)
========================================
Signature templates for user email (HR)
========================================

Connector for modules:

* Signature templates for user emails
* HR

Credits
=======

Contributors
------------
* `Ivan Yelizariev <https://it-projects.info/team/yelizariev>`__
* `Anvar Kildebekov <https://it-projects.info/team/kildebekov>`__

Sponsors
--------
* `IT-Projects LLC <https://it-projects.info>`__

Maintainers
-----------
* `IT-Projects LLC <https://it-projects.info>`__

To get a guaranteed support you are kindly requested to purchase the module at `odoo apps store <https://apps.odoo.com/apps/modules/12.0/res_users_signature_hr/>`__.

Thank you for understanding!

`IT-Projects Team <https://www.it-projects.info/team>`__

Further information
===================

Demo: http://runbot.it-projects.info/demo/12.0/res_users_signature_hr

HTML Description: https://apps.odoo.com/apps/modules/12.0/res_users_signature_hr/

Usage instructions: `<doc/index.rst>`_

Changelog: `<doc/changelog.rst>`_

Tested on Odoo 12.0 32c2666d189047db66eb7b1392ea34b086fd341e
@@ -1,14 +1,15 @@
{
'name': "Signature templates for user emails (HR)",
'version': '1.0.0',
'version': '12.0.1.0.0',
'author': 'IT-Projects LLC, Ivan Yelizariev',
'license': 'LGPL-3',
'category': 'Custom',
'images': ["images/main.png"],
'website': 'https://yelizariev.github.io',
'depends': ['res_users_signature', 'hr'],
'data': [
'views.xml',
'views/res_users_signature_hr_views.xml',
],
'installable': False,
'installable': True,
'auto_install': True,
}

0 comments on commit 361df28

Please sign in to comment.
You can’t perform that action at this time.