[FIX] Small changes in barcode controller and set default values when creating paper format
bzr revid: sle@openerp.com-20140221101520-tg522m1w38jdp55p
This commit is contained in:
parent
35b64811e9
commit
0304f71112
|
@ -53,7 +53,6 @@ class tax_report(http.Controller, common_report_header):
|
||||||
}
|
}
|
||||||
return request.registry['report'].render(self.cr, self.uid, [], 'account.report_vat', docargs)
|
return request.registry['report'].render(self.cr, self.uid, [], 'account.report_vat', docargs)
|
||||||
|
|
||||||
|
|
||||||
def _get_basedon(self, form):
|
def _get_basedon(self, form):
|
||||||
return form['form']['based_on']
|
return form['form']['based_on']
|
||||||
|
|
||||||
|
|
|
@ -360,7 +360,6 @@ class Report(http.Controller):
|
||||||
def _build_wkhtmltopdf_args(self, paperformat, specific_paperformat_args=None):
|
def _build_wkhtmltopdf_args(self, paperformat, specific_paperformat_args=None):
|
||||||
"""Build arguments understandable by wkhtmltopdf from an ir.actions.report.paperformat
|
"""Build arguments understandable by wkhtmltopdf from an ir.actions.report.paperformat
|
||||||
record.
|
record.
|
||||||
Sample: <img t-att-src="'/report/getbarcode/QR/%s/200/200' % o.name"/>
|
|
||||||
|
|
||||||
:paperformat: ir.actions.report.paperformat record associated to a document
|
:paperformat: ir.actions.report.paperformat record associated to a document
|
||||||
:specific_paperformat_args: a dict containing prioritized wkhtmltopdf arguments
|
:specific_paperformat_args: a dict containing prioritized wkhtmltopdf arguments
|
||||||
|
@ -456,12 +455,10 @@ class Report(http.Controller):
|
||||||
response.headers.add('Content-Disposition', 'attachment; filename=report.pdf;')
|
response.headers.add('Content-Disposition', 'attachment; filename=report.pdf;')
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@http.route([
|
@http.route(['/report/barcode', '/report/barcode/<type>/<value>'], type='http', auth="user")
|
||||||
'/report/getbarcode/<type>/<value>',
|
|
||||||
'/report/getbarcode/<type>/<value>/<int:width>/<int:height>',
|
|
||||||
], type='http', auth="user")
|
|
||||||
def barcode(self, type, value, width=300, height=50):
|
def barcode(self, type, value, width=300, height=50):
|
||||||
"""Contoller able to render barcode images thanks to reportlab.
|
"""Contoller able to render barcode images thanks to reportlab.
|
||||||
|
Sample: <img t-att-src="'/report/barcode/QR/%s' % o.name"/>
|
||||||
|
|
||||||
:param type: Accepted types: 'Codabar', 'Code11', 'Code128', 'EAN13', 'EAN8', 'Extended39',
|
:param type: Accepted types: 'Codabar', 'Code11', 'Code128', 'EAN13', 'EAN8', 'Extended39',
|
||||||
'Extended93', 'FIM', 'I2of5', 'MSI', 'POSTNET', 'QR', 'Standard39', 'Standard93',
|
'Extended93', 'FIM', 'I2of5', 'MSI', 'POSTNET', 'QR', 'Standard39', 'Standard93',
|
||||||
|
@ -469,9 +466,11 @@ class Report(http.Controller):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
barcode = createBarcodeImageInMemory(
|
barcode = createBarcodeImageInMemory(
|
||||||
type, value=value, format='jpg', width=width, height=height
|
type, value=value, format='png', width=width, height=height
|
||||||
)
|
)
|
||||||
except (ValueError, AttributeError):
|
except (ValueError, AttributeError):
|
||||||
raise exceptions.HTTPException(description='Cannot convert into barcode.')
|
raise exceptions.HTTPException(description='Cannot convert into barcode.')
|
||||||
|
except AssertionError:
|
||||||
|
raise exceptions.HTTPException(description='Please upgrade reportlab to at least 3.0.')
|
||||||
|
|
||||||
return request.make_response(barcode, headers=[('Content-Type', 'image/jpg')])
|
return request.make_response(barcode, headers=[('Content-Type', 'image/png')])
|
||||||
|
|
|
@ -76,7 +76,7 @@ class report_paperformat(osv.Model):
|
||||||
'Orientation'),
|
'Orientation'),
|
||||||
'header_line': fields.boolean('Display a header line'),
|
'header_line': fields.boolean('Display a header line'),
|
||||||
'header_spacing': fields.integer('Header spacing'),
|
'header_spacing': fields.integer('Header spacing'),
|
||||||
'dpi': fields.integer('Output DPI'),
|
'dpi': fields.integer('Output DPI', required=True),
|
||||||
'report_ids': fields.one2many('ir.actions.report.xml',
|
'report_ids': fields.one2many('ir.actions.report.xml',
|
||||||
'paperformat_id',
|
'paperformat_id',
|
||||||
'Associated reports',
|
'Associated reports',
|
||||||
|
@ -94,6 +94,20 @@ class report_paperformat(osv.Model):
|
||||||
'page width/height.', ['format']),
|
'page width/height.', ['format']),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
_defaults = {
|
||||||
|
'format': 'A4',
|
||||||
|
'margin_top': 40,
|
||||||
|
'margin_bottom': 20,
|
||||||
|
'margin_left': 7,
|
||||||
|
'margin_right': 7,
|
||||||
|
'page_height': False,
|
||||||
|
'page_width': False,
|
||||||
|
'orientation': 'Landscape',
|
||||||
|
'header_line': False,
|
||||||
|
'header_spacing': 35,
|
||||||
|
'dpi': 90,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class res_company(osv.Model):
|
class res_company(osv.Model):
|
||||||
_inherit = 'res.company'
|
_inherit = 'res.company'
|
||||||
|
|
Loading…
Reference in New Issue