Browse Source

Add option py3o_multi_in_one for Py3o reports

pull/125/head
Alexis de Lattre 8 years ago
parent
commit
8c1e1b5ac4
  1. 6
      report_py3o/models/ir_actions_report_xml.py
  2. 8
      report_py3o/models/py3o_report.py
  3. 1
      report_py3o/views/ir_report.xml

6
report_py3o/models/ir_actions_report_xml.py

@ -80,6 +80,12 @@ class IrActionsReportXml(models.Model):
"or an absolute path on your server." "or an absolute path on your server."
)) ))
report_type = fields.Selection(selection_add=[('py3o', "Py3o")]) report_type = fields.Selection(selection_add=[('py3o', "Py3o")])
py3o_multi_in_one = fields.Boolean(
string='Multiple Records in a Single Report',
help="If you execute a report on several records, "
"by default Odoo will generate a ZIP file that contains as many "
"files as selected records. If you enable this option, Odoo will "
"generate instead a single report for the selected records.")
@api.model @api.model
def render_report(self, res_ids, name, data): def render_report(self, res_ids, name, data):

8
report_py3o/models/py3o_report.py

@ -282,6 +282,7 @@ class Py3oReport(models.TransientModel):
with open(result_path, 'w+') as fd: with open(result_path, 'w+') as fd:
for chunk in r.iter_content(chunk_size): for chunk in r.iter_content(chunk_size):
fd.write(chunk) fd.write(chunk)
if len(model_instance) == 1:
self._postprocess_report( self._postprocess_report(
result_path, model_instance.id, save_in_attachment) result_path, model_instance.id, save_in_attachment)
return result_path return result_path
@ -345,6 +346,13 @@ class Py3oReport(models.TransientModel):
save_in_attachment = self._check_attachment_use( save_in_attachment = self._check_attachment_use(
res_ids, self.ir_actions_report_xml_id) or {} res_ids, self.ir_actions_report_xml_id) or {}
reports_path = [] reports_path = []
if (
len(res_ids) > 1 and
self.ir_actions_report_xml_id.py3o_multi_in_one):
reports_path.append(
self._create_single_report(
model_instances, data, save_in_attachment))
else:
for model_instance in model_instances: for model_instance in model_instances:
reports_path.append( reports_path.append(
self._get_or_create_single_report( self._get_or_create_single_report(

1
report_py3o/views/ir_report.xml

@ -15,6 +15,7 @@
<group name="py3o_params"> <group name="py3o_params">
<field name="py3o_filetype" /> <field name="py3o_filetype" />
<field name="py3o_multi_in_one"/>
<field name="py3o_is_local_fusion"/> <field name="py3o_is_local_fusion"/>
<field name="py3o_server_id" /> <field name="py3o_server_id" />
<field name="py3o_template_id" /> <field name="py3o_template_id" />

Loading…
Cancel
Save