-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add template body text optional inliner #155
Open
xavierteres
wants to merge
8
commits into
gisce:v5_backport
Choose a base branch
from
Som-Energia:ADD_optional_inliner
base: v5_backport
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a80314f
Add template body text optional inliner
xavierteres 628f3d5
🐛 (inliner): Add missing import
destanyol 676cf0f
🔧 (inliner): ADD inliner TESTS
destanyol 112efb2
🏗️ (inliner): ADD migration script
destanyol b0f1cf0
🏗️ (inlining): Install package in migration script
destanyol 6f7ea19
🐛 (inliner): Fix migration script
destanyol 15b46bd
Merge branch 'v5_backport' into ADD_optional_inliner
destanyol 0cd17ca
Merge branch 'v5_backport' into ADD_optional_inliner
destanyol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# coding=utf-8 | ||
import logging | ||
import pooler | ||
|
||
from oopgrade.oopgrade import load_data_records | ||
|
||
|
||
def up(cursor, installed_version): | ||
if not installed_version: | ||
return | ||
|
||
logger = logging.getLogger("openerp.migration") | ||
logger.info("Creating pooler") | ||
pool = pooler.get_pool(cursor.dbname) | ||
|
||
# Afegir columna a poweremail.templates | ||
logger.info("Updating table table: poweremail.templates") | ||
pool.get("poweremail.templates")._auto_init( | ||
cursor, context={"module": "poweremail"} | ||
) | ||
logger.info("Table updated succesfully.") | ||
|
||
list_of_records = [ | ||
"poweremail_template_form", | ||
] | ||
load_data_records( | ||
cursor, "poweremail", "poweremail_template_view.xml", | ||
list_of_records, mode="update" | ||
) | ||
logger.info("poweremail_template_view.xml successfully updated") | ||
|
||
|
||
def down(cursor, installed_version): | ||
pass | ||
|
||
|
||
migrate = up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# coding=utf-8 | ||
import logging | ||
from tools import pip_install | ||
|
||
|
||
def up(cursor, installed_version): | ||
if not installed_version: | ||
return | ||
|
||
logger = logging.getLogger("openerp.migration") | ||
logger.info('Installing premailer package...') | ||
pip_install('premailer==2.9.6', '--force') | ||
logger.info('Premailer package installed successfully!') | ||
|
||
|
||
def down(cursor, installed_version): | ||
pass | ||
|
||
|
||
migrate = up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
mako | ||
qreu>=0.7.5 | ||
html2text | ||
premailer==2.9.6 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Entenc que una versió superior no és compatible amb python 2.7 no? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -538,3 +538,105 @@ def test_save_to_mailbox(self, mock_function, mock_function_2, mock_function_3, | |
self.assertEqual(len(mail_created_vals['pem_attachments_ids']), 2) | ||
self.assertIn(attachment_report_id, mail_created_vals['pem_attachments_ids']) | ||
self.assertIn(attachment_id, mail_created_vals['pem_attachments_ids']) | ||
|
||
def test_save_to_mailbox_inlining(self): | ||
with Transaction().start(self.database) as txn: | ||
uid = txn.user | ||
cursor = txn.cursor | ||
mailbox_obj = self.openerp.pool.get('poweremail.mailbox') | ||
pm_tmp_obj = self.openerp.pool.get('poweremail.templates') | ||
imd_obj = self.openerp.pool.get('ir.model.data') | ||
pw_account_obj = self.openerp.pool.get('poweremail.core_accounts') | ||
send_wizard_obj = self.openerp.pool.get('poweremail.send.wizard') | ||
|
||
# Dummy value for an invoice id | ||
fact_id = 6 | ||
# Agafem un template de prova per posar a l'attachment | ||
template_id = imd_obj.get_object_reference( | ||
cursor, uid, 'poweremail', 'default_template_poweremail' | ||
)[1] | ||
|
||
# Creem un wizard 'poweremail_send_wizard' | ||
body_text = """ | ||
<html> | ||
<style type="text/css"> | ||
h1 { border:1px solid black } | ||
p { color:red;} | ||
</style> | ||
<h1 style="font-weight:bolder">Peter</h1> | ||
<p>Hej</p> | ||
</html> | ||
""" | ||
|
||
wizard_vals = { | ||
'rel_model_ref': fact_id, | ||
'requested': 1, | ||
'from': 1, | ||
'attachment_ids': [], | ||
'body_text': body_text, | ||
'cc': False, | ||
'body_html': False, | ||
'bcc': False, | ||
'priority': '1', | ||
'to': '[email protected]', | ||
'state': 'single', | ||
'ref_template': template_id, | ||
'single_email': 0, | ||
'rel_model': 301, | ||
'signature': False, | ||
'report': False, | ||
'subject': 'Factura electricidad False', | ||
'generated': False, | ||
'full_success': False, | ||
} | ||
|
||
# Creem un mailbox | ||
wizard_id = send_wizard_obj.create(cursor, uid, wizard_vals) | ||
|
||
pw_account_id = pw_account_obj.create(cursor, uid, { | ||
'name': 'test', | ||
'user': 1, | ||
'email_id': 'test@email', | ||
'smtpserver': 'smtp.gmail.com', | ||
'smtpport': '587', | ||
'company': 'no', | ||
'state': 'approved', | ||
}) | ||
|
||
# Escribim el que necessitem als templates | ||
template_vals = { | ||
'enforce_from_account': pw_account_id, | ||
'inline': True | ||
} | ||
pm_tmp_obj.write(cursor, uid, template_id, template_vals) | ||
|
||
mail_vals = { | ||
'pem_from': 'test@email', | ||
'pem_to': '[email protected]', | ||
'pem_cc': False, | ||
'pem_bcc': False, | ||
'pem_subject': 'Factura electricidad False', | ||
'pem_body_text': body_text, | ||
'pem_body_html': False, | ||
'pem_account_id': 1, | ||
'priority': '1', | ||
'state': 'na', | ||
} | ||
|
||
mailbox_obj.create(cursor, uid, mail_vals) | ||
|
||
context = {} | ||
context['template_id'] = template_id | ||
context['lang'] = False | ||
context['src_rec_id'] = fact_id | ||
context['tz'] = False | ||
context['src_rec_ids'] = [fact_id] | ||
context['active_ids'] = [fact_id] | ||
context['type'] = 'out_invoice' | ||
context['active_id'] = fact_id | ||
|
||
inlined_html = '<html>\n<head></head>\n<body>\n<h1 style="border:1px solid black; font-weight:bolder">Peter</h1>\n<p style="color:red">Hej</p>\n</body>\n</html>\n' | ||
|
||
mail_ids = send_wizard_obj.save_to_mailbox(cursor, uid, [wizard_id], context=context) | ||
pem_body_text = mailbox_obj.read(cursor, uid, mail_ids[0], ['pem_body_text'])['pem_body_text'] | ||
self.assertEqual(pem_body_text, inlined_html) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idioma del mòdul és l'anglès.