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

Make attachments of other models #85

Draft
wants to merge 3 commits into
base: v5_backport
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
18 changes: 18 additions & 0 deletions migrations/5.0.25.5.0/post-0001_add_new_column.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from tools import config
import pooler


def up(cursor, installed_version):
if not installed_version or config.updating_all:
return

pool = pooler.get_pool(cursor.dbname)

pool.get("poweremail.templates")._auto_init(cursor, context={'module': 'poweremail'})


def down(cursor, installed_version):
pass


migrate = up
21 changes: 17 additions & 4 deletions poweremail_send_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,24 @@ def create_report_attachment(self, cr, uid, template, vals, screen_vals, mail_id
service = netsvc.LocalService(reportname)
if template.report_template.context:
context.update(eval(template.report_template.context))
if screen_vals['single_email'] and len(report_record_ids) > 1:
# The optional attachment will be generated as a single file for all these records
(result, format) = service.create(cr, uid, report_record_ids, data, context=context)

if template.report_template_object_reference:
if screen_vals['single_email'] and len(report_record_ids) > 1:
report_reference_ids = []
for record_id in report_record_ids:
report_reference_ids.append(self.get_value(cr, uid, template, template.report_template_object_reference, context, record_id))
record_to_print_ids = report_record_ids
else:
report_reference_id = self.get_value(cr, uid, template, template.report_template_object_reference, context, id)
record_to_print_ids = [report_reference_id]
else:
(result, format) = service.create(cr, uid, [src_rec_id], data, context=context)
if screen_vals['single_email'] and len(report_record_ids) > 1:
record_to_print_ids = report_record_ids
else:
record_to_print_ids = [src_rec_id]

(result, format) = service.create(cr, uid, record_to_print_ids, data, context=context)

attach_vals = {
'name': _('%s (Email Attachment)') % tools.ustr(vals['pem_subject']),
'datas': base64.b64encode(result),
Expand Down
1 change: 1 addition & 0 deletions poweremail_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ def _get_model_data_name_search(
'report_template':fields.many2one(
'ir.actions.report.xml',
'Report to send'),
'report_template_object_reference': fields.char('Reference of the report', size=300, required=False),
#'report_template':fields.reference('Report to send',[('ir.actions.report.xml','Reports')],size=128),
'allowed_groups':fields.many2many(
'res.groups',
Expand Down
14 changes: 12 additions & 2 deletions poweremail_template_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
-->
<openerp>
<data>
<record model="ir.ui.view" id="poweremail_template_attachment_form">
<record model="ir.ui.view" id="poweremail_template_attachment_form">
<field name="name">poweremail.template.attachment.form</field>
<field name="model">poweremail.template.attachment</field>
<field name="type">form</field>
Expand Down Expand Up @@ -72,7 +72,7 @@
<!--
I dont advice using the html widget
because tinymce is interfering too
much with the html generated
much with the html generated

Sunday,30 May 2010:Enabling HTML as
community votes for it
Expand Down Expand Up @@ -136,6 +136,16 @@
<field name="save_to_drafts" colspan="4"/>
<field name="inline" colspan="4"/>
</group>
<field name="server_action" readonly="1" />
<separator string="Attachments (Report to attach)"
colspan="4" />
<field name="file_name" colspan="2" />
<field name="report_template" colspan="2"/>
<field name="report_template_object_reference" colspan="2"/>
<field name="tmpl_attachment_ids" colspan="4" nolabel="1"/>
<separator string="Log partner events"
colspan="4" />
<field name="partner_event" />
<group>
<separator colspan="4" string="Allowed User Groups" />
<field name="allowed_groups" string="Allowed User Groups" nolabel="1" colspan="4"/>
Expand Down