'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
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)
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 = []
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,
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')
html = create_doc(mako_html,html_parser.localcontext)
return (html,'html')
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: