X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=openerp%2Freport%2Freport_sxw.py;h=9b317bb09544ec8d89f746f00363bbbf5433e2ae;hb=68e03147ff944637ffa66e0869469279005e32e8;hp=7402104f9d0126b4e8af70fe54e027872b40c327;hpb=2bd470802300efc493b116940c21bf6940a0ecdd;p=odoo%2Fodoo.git diff --git a/openerp/report/report_sxw.py b/openerp/report/report_sxw.py index 7402104..9b317bb 100644 --- a/openerp/report/report_sxw.py +++ b/openerp/report/report_sxw.py @@ -170,6 +170,7 @@ class rml_parse(object): 'setHtmlImage' : self.set_html_image, 'strip_name' : self._strip_name, 'time' : time, + 'display_address': self.display_address, # more context members are setup in setCompany() below: # - company_id # - logo @@ -267,7 +268,7 @@ class rml_parse(object): d = obj._field.digits[1] or DEFAULT_DIGITS return d - def formatLang(self, value, digits=None, date=False, date_time=False, grouping=True, monetary=False, dp=False): + def formatLang(self, value, digits=None, date=False, date_time=False, grouping=True, monetary=False, dp=False, currency_obj=False): """ Assuming 'Account' decimal.precision=3: formatLang(value) -> digits=2 (default) @@ -305,7 +306,16 @@ class rml_parse(object): date = datetime(*value.timetuple()[:6]) return date.strftime(date_format) - return self.lang_dict['lang_obj'].format('%.' + str(digits) + 'f', value, grouping=grouping, monetary=monetary) + res = self.lang_dict['lang_obj'].format('%.' + str(digits) + 'f', value, grouping=grouping, monetary=monetary) + if currency_obj: + if currency_obj.position == 'after': + res='%s %s'%(res,currency_obj.symbol) + elif currency_obj and currency_obj.position == 'before': + res='%s %s'%(currency_obj.symbol, res) + return res + + def display_address(self, address_browse_record): + return self.pool.get('res.partner.address')._display_address(self.cr, self.uid, address_browse_record) def repeatIn(self, lst, name,nodes_parent=False): ret_lst = [] @@ -385,8 +395,12 @@ class report_sxw(report_rml, preprocess.report): return table_obj.browse(cr, uid, ids, list_class=browse_record_list, context=context, fields_process=_fields_process) def create(self, cr, uid, ids, data, context=None): + if context is None: + context = {} if self.internal_header: - context.update({'internal_header':self.internal_header}) + context.update(internal_header=self.internal_header) + # skip osv.fields.sanitize_binary_value() because we want the raw bytes in all cases + context.update(bin_raw=True) pool = pooler.get_pool(cr.dbname) ir_obj = pool.get('ir.actions.report.xml') report_xml_ids = ir_obj.search(cr, uid, @@ -513,12 +527,13 @@ class report_sxw(report_rml, preprocess.report): context = context.copy() report_type = report_xml.report_type context['parents'] = sxw_parents - - # if binary content was passed as unicode, we must - # re-encode it as a 8-bit string using the pass-through - # 'latin1' encoding, to restore the original byte values. - # See also osv.fields.sanitize_binary_value() - binary_report_content = report_xml.report_sxw_content.encode("latin1") + binary_report_content = report_xml.report_sxw_content + if isinstance(report_xml.report_sxw_content, unicode): + # if binary content was passed as unicode, we must + # re-encode it as a 8-bit string using the pass-through + # 'latin1' encoding, to restore the original byte values. + # See also osv.fields.sanitize_binary_value() + binary_report_content = report_xml.report_sxw_content.encode("latin1") sxw_io = StringIO.StringIO(binary_report_content) sxw_z = zipfile.ZipFile(sxw_io, mode='r') @@ -650,3 +665,5 @@ class report_sxw(report_rml, preprocess.report): html = create_doc(mako_html,html_parser.localcontext) return (html,'html') + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: