Skip to content
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

Añadir banner company para la plantilla #41

Merged
merged 4 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions poweremail_generic_template/__terp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"data/banners/banner_generic_email_template_body.xml",
"data/banners/banner_generic_email_template_footer.xml",
"data/banners/banner_generic_email_template_css.xml",
"data/banners/banner_generic_email_template_company.xml",
],
"active": False,
"installable": True
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="report.banner" id="banner_generic_email_template_company">
<field name="name">Email genérico (TEMPLATE): compañia (company)</field>
<field name="code">generic_email_template_company</field>
<field name="start_date">2000-01-01</field>
<field name="sequence">0</field>
<field name="res_model">no.required</field>
<field name="description">La compañia a la que hace referencia la plantilla</field>
<field name="html[en_US]" file="emails/generic/components/company/en.mako"/>
<field name="html[ca_ES]" file="emails/generic/components/company/en.mako"/>
<field name="html[es_ES]" file="emails/generic/components/company/en.mako"/>
</record>
</data>
</openerp>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
object.company_id
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% company = object.company_id %>
<% company = env['company'] %>
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="content-block">
Expand Down
22 changes: 17 additions & 5 deletions poweremail_generic_template/emails/generic/index.mako
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
from datetime import datetime
from poweremail.poweremail_template import get_value

pool = object.pool
cursor = object._cr
uid = object._uid
today = datetime.today().date().strftime('%Y-%m-%d')

banner_o = pool.get('report.banner')
Expand All @@ -15,8 +12,23 @@ banners = banner_o.get_report_banners(
today, object.id, context={'lang': lang}
)

body_html = get_value(cursor, uid, object.id, message=banners['generic_email_template_body'], template=template, context={'lang': lang})
footer_html = get_value(cursor, uid, object.id, message=banners['generic_email_template_footer'], template=template, context={'lang': lang})
try:
company = eval(banners['generic_email_template_company'])
except:
company = False

if not company:
company = pool.get('res.company').browse(cursor, uid, 1, context={})

env['company'] = company
ctx = {
'lang': lang,
'raise_exception': True,
}
ctx.update(env)

body_html = get_value(cursor, uid, object.id, message=banners['generic_email_template_body'], template=template, context=ctx)
footer_html = get_value(cursor, uid, object.id, message=banners['generic_email_template_footer'], template=template, context=ctx)
%>
<html>
<head>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
from oopgrade.oopgrade import load_data


def up(cursor, installed_version):
if not installed_version:
return
load_data(cursor, 'poweremail_generic_template', 'data/banners/banner_generic_email_template_company.xml')
lcbautista marked this conversation as resolved.
Show resolved Hide resolved


def down(cursor, installed_version):
pass

migrate = up