Skip to content

Commit

Permalink
Merge pull request #41 from gisce/add_template_company_banner
Browse files Browse the repository at this point in the history
Añadir banner company para la plantilla
  • Loading branch information
lcbautista authored Aug 2, 2024
2 parents fc5dfa5 + a219030 commit 4703f31
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 6 deletions.
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,15 @@
# -*- coding: utf-8 -*-
from oopgrade.oopgrade import load_data
from tools import config


def up(cursor, installed_version):
if not installed_version or config.updating_all:
return
load_data(cursor, 'poweremail_generic_template', 'data/banners/banner_generic_email_template_company.xml')


def down(cursor, installed_version):
pass

migrate = up

0 comments on commit 4703f31

Please sign in to comment.