summaryrefslogtreecommitdiff
path: root/addons/report
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2016-06-15 12:40:59 +0200
committerChristophe Simonis <chs@odoo.com>2016-06-15 12:40:59 +0200
commitbaf494c67ba7ecba331b24bcfa5eed9bde8a16da (patch)
tree3b2c9ec3cacabcf0a5b0fb78a667d5e1b27505dc /addons/report
parent133490b4d0e347d75bab20da8e5e0ad1f95d3a2d (diff)
parent1d81bb06a47b1aee1b7a0dcdaa03084ddedf8b7b (diff)
[MERGE] forward port of branch saas-9 up to 1d81bb0
# Conflicts: # addons/account_extra_reports/i18n/ca.po # addons/account_extra_reports/i18n/fi.po # addons/account_extra_reports/i18n/pl.po # addons/account_extra_reports/i18n/te.po # addons/account_extra_reports/i18n/zh_CN.po # addons/account_full_reconcile/i18n/hu.po # addons/account_full_reconcile/i18n/pl.po # addons/crm/crm_lead_menu.xml # addons/crm_claim/i18n/es_PE.po # addons/crm_claim/i18n/hu.po # addons/crm_claim/i18n/ja.po # addons/crm_claim/i18n/pl.po # addons/delivery/views/delivery_view.xml # addons/product/product_view.xml # addons/project_timesheet/i18n/es_PE.po # addons/stock/stock_view.xml
Diffstat (limited to 'addons/report')
-rw-r--r--addons/report/i18n/es_PE.po7
-rw-r--r--addons/report/i18n/hu.po4
-rw-r--r--addons/report/i18n/pl.po4
-rw-r--r--addons/report/models/report.py52
4 files changed, 47 insertions, 20 deletions
diff --git a/addons/report/i18n/es_PE.po b/addons/report/i18n/es_PE.po
index 943f1be267d..33e6467602c 100644
--- a/addons/report/i18n/es_PE.po
+++ b/addons/report/i18n/es_PE.po
@@ -3,13 +3,14 @@
# * report
#
# Translators:
+# Carlos Eduardo Rodriguez Rossi <crodriguez@samemotion.com>, 2016
msgid ""
msgstr ""
"Project-Id-Version: Odoo 9.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-09-29 10:26+0000\n"
-"PO-Revision-Date: 2016-02-09 23:06+0000\n"
-"Last-Translator: Martin Trigaux\n"
+"PO-Revision-Date: 2016-06-09 23:33+0000\n"
+"Last-Translator: Carlos Eduardo Rodriguez Rossi <crodriguez@samemotion.com>\n"
"Language-Team: Spanish (Peru) (http://www.transifex.com/odoo/odoo-9/language/es_PE/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -369,7 +370,7 @@ msgstr ""
#. module: report
#: model:ir.ui.view,arch_db:report.external_layout_footer
msgid "Phone:"
-msgstr "Telefono:"
+msgstr "Teléfono:"
#. module: report
#: selection:report.paperformat,orientation:0
diff --git a/addons/report/i18n/hu.po b/addons/report/i18n/hu.po
index 13f9c07d255..728020e70bb 100644
--- a/addons/report/i18n/hu.po
+++ b/addons/report/i18n/hu.po
@@ -10,7 +10,7 @@ msgstr ""
"Project-Id-Version: Odoo 9.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-09-29 10:26+0000\n"
-"PO-Revision-Date: 2016-04-12 10:04+0000\n"
+"PO-Revision-Date: 2016-06-06 19:55+0000\n"
"Last-Translator: krnkris\n"
"Language-Team: Hungarian (http://www.transifex.com/odoo/odoo-9/language/hu/)\n"
"MIME-Version: 1.0\n"
@@ -289,7 +289,7 @@ msgstr "Utoljára frissítve, által"
#: model:ir.model.fields,field_description:report.field_report_paperformat_write_date
#: model:ir.model.fields,field_description:report.field_report_write_date
msgid "Last Updated on"
-msgstr "Utoljára frissítve ekkor"
+msgstr "Utoljára frissítve "
#. module: report
#: selection:report.paperformat,format:0
diff --git a/addons/report/i18n/pl.po b/addons/report/i18n/pl.po
index 74b4893ce7b..aa29ceb24f8 100644
--- a/addons/report/i18n/pl.po
+++ b/addons/report/i18n/pl.po
@@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: Odoo 9.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-09-29 10:26+0000\n"
-"PO-Revision-Date: 2016-04-20 22:02+0000\n"
+"PO-Revision-Date: 2016-06-09 05:01+0000\n"
"Last-Translator: Grzegorz Grzelak <grzegorz.grzelak@openglobe.pl>\n"
"Language-Team: Polish (http://www.transifex.com/odoo/odoo-9/language/pl/)\n"
"MIME-Version: 1.0\n"
@@ -26,7 +26,7 @@ msgstr "&amp;zwyżkowanie;"
#: model:ir.ui.view,arch_db:report.layout
#: model:ir.ui.view,arch_db:report.minimal_layout
msgid "&lt;!DOCTYPE html&gt;"
-msgstr ""
+msgstr "&lt;!DOCTYPE html&gt;"
#. module: report
#: selection:report.paperformat,format:0
diff --git a/addons/report/models/report.py b/addons/report/models/report.py
index 448f29b10a5..3aabbd3b929 100644
--- a/addons/report/models/report.py
+++ b/addons/report/models/report.py
@@ -28,6 +28,17 @@ from pyPdf import PdfFileWriter, PdfFileReader
from reportlab.graphics.barcode import createBarcodeDrawing
+# A lock occurs when the user wants to print a report having multiple barcode while the server is
+# started in threaded-mode. The reason is that reportlab has to build a cache of the T1 fonts
+# before rendering a barcode (done in a C extension) and this part is not thread safe. We attempt
+# here to init the T1 fonts cache at the start-up of Odoo so that rendering of barcode in multiple
+# thread does not lock the server.
+try:
+ createBarcodeDrawing('Code128', value='foo', format='png', width=100, height=100, humanReadable=1).asString('png')
+except Exception:
+ pass
+
+
#--------------------------------------------------------------------------
# Helpers
#--------------------------------------------------------------------------
@@ -115,11 +126,11 @@ class Report(osv.Model):
"""
# If the report is using a custom model to render its html, we must use it.
# Otherwise, fallback on the generic html rendering.
- try:
- report_model_name = 'report.%s' % report_name
- particularreport_obj = self.pool[report_model_name]
+ report_model_name = 'report.%s' % report_name
+ particularreport_obj = self.pool.get(report_model_name)
+ if particularreport_obj is not None:
return particularreport_obj.render_html(cr, uid, ids, data=data, context=context)
- except KeyError:
+ else:
report = self._get_report_from_name(cr, uid, report_name)
report_obj = self.pool[report.model]
docs = report_obj.browse(cr, uid, ids, context=context)
@@ -296,19 +307,20 @@ class Report(osv.Model):
save_in_attachment['loaded_documents'] = {}
if report.attachment:
+ records = self.pool[report.model].browse(cr, uid, ids)
+ filenames = self._attachment_filename(cr, uid, records, report)
+ attachments = None
+ if report.attachment_use:
+ attachments = self._attachment_stored(cr, uid, records, report, filenames=filenames)
for record_id in ids:
- obj = self.pool[report.model].browse(cr, uid, record_id)
- filename = eval(report.attachment, {'object': obj, 'time': time})
+ filename = filenames[record_id]
# If the user has checked 'Reload from Attachment'
- if report.attachment_use:
- alreadyindb = [('datas_fname', '=', filename),
- ('res_model', '=', report.model),
- ('res_id', '=', record_id)]
- attach_ids = self.pool['ir.attachment'].search(cr, uid, alreadyindb)
- if attach_ids:
+ if attachments:
+ attachment = attachments[record_id]
+ if attachment:
# Add the loaded pdf in the loaded_documents list
- pdf = self.pool['ir.attachment'].browse(cr, uid, attach_ids[0]).datas
+ pdf = attachment.datas
pdf = base64.decodestring(pdf)
save_in_attachment['loaded_documents'][record_id] = pdf
_logger.info('The PDF document %s was loaded from the database' % filename)
@@ -330,6 +342,20 @@ class Report(osv.Model):
return Report._check_attachment_use(
self._model, self._cr, self._uid, records.ids, report, context=self._context)
+ @api.model
+ def _attachment_filename(self, records, report):
+ return dict((record.id, eval(report.attachment, {'object': record, 'time': time})) for record in records)
+
+ @api.model
+ def _attachment_stored(self, records, report, filenames=None):
+ if not filenames:
+ filenames = self._attachment_filename(records, report)
+ return dict((record.id, self.env['ir.attachment'].search([
+ ('datas_fname', '=', filenames[record.id]),
+ ('res_model', '=', report.model),
+ ('res_id', '=', record.id)
+ ], limit=1)) for record in records)
+
def _check_wkhtmltopdf(self):
return wkhtmltopdf_state