diff --git a/poweremail_generic_template/__terp__.py b/poweremail_generic_template/__terp__.py index c2ec593..482db27 100644 --- a/poweremail_generic_template/__terp__.py +++ b/poweremail_generic_template/__terp__.py @@ -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 diff --git a/poweremail_generic_template/data/banners/banner_generic_email_template_company.xml b/poweremail_generic_template/data/banners/banner_generic_email_template_company.xml new file mode 100644 index 0000000..8b1755b --- /dev/null +++ b/poweremail_generic_template/data/banners/banner_generic_email_template_company.xml @@ -0,0 +1,16 @@ + + + + + + diff --git a/poweremail_generic_template/emails/generic/components/company/en.mako b/poweremail_generic_template/emails/generic/components/company/en.mako new file mode 100644 index 0000000..f4d8c1b --- /dev/null +++ b/poweremail_generic_template/emails/generic/components/company/en.mako @@ -0,0 +1 @@ +object.company_id \ No newline at end of file diff --git a/poweremail_generic_template/emails/generic/components/footer/en.mako b/poweremail_generic_template/emails/generic/components/footer/en.mako index 4e9a37c..4502826 100644 --- a/poweremail_generic_template/emails/generic/components/footer/en.mako +++ b/poweremail_generic_template/emails/generic/components/footer/en.mako @@ -1,4 +1,4 @@ -<% company = object.company_id %> +<% company = env['company'] %>
diff --git a/poweremail_generic_template/emails/generic/index.mako b/poweremail_generic_template/emails/generic/index.mako index 3202411..bc7d6fd 100644 --- a/poweremail_generic_template/emails/generic/index.mako +++ b/poweremail_generic_template/emails/generic/index.mako @@ -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') @@ -15,8 +12,17 @@ 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}) +company = eval(banners['generic_email_template_company']) + +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) %> diff --git a/poweremail_generic_template/migrations/5.0.24.9.0/post-0001_load_generic_template_company_banner.py b/poweremail_generic_template/migrations/5.0.24.9.0/post-0001_load_generic_template_company_banner.py new file mode 100644 index 0000000..227daa3 --- /dev/null +++ b/poweremail_generic_template/migrations/5.0.24.9.0/post-0001_load_generic_template_company_banner.py @@ -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') + + +def down(cursor, installed_version): + pass + +migrate = up \ No newline at end of file