@@ -27,8 +27,10 @@ from lxml import etree
|
||||
from report import render
|
||||
import libxml2
|
||||
import libxslt
|
||||
import locale
|
||||
|
||||
import time, os
|
||||
import mx.DateTime
|
||||
|
||||
class report_printscreen_list(report_int):
|
||||
def __init__(self, name):
|
||||
@@ -87,7 +89,8 @@ class report_printscreen_list(report_int):
|
||||
n.text = text
|
||||
config.append(n)
|
||||
|
||||
_append_node('date', time.strftime('%d/%m/%Y'))
|
||||
#_append_node('date', time.strftime('%d/%m/%Y'))
|
||||
_append_node('date', time.strftime(str(locale.nl_langinfo(locale.D_FMT).replace('%y', '%Y'))))
|
||||
_append_node('PageSize', '%.2fmm,%.2fmm' % tuple(pageSize))
|
||||
_append_node('PageWidth', '%.2f' % (pageSize[0] * 2.8346,))
|
||||
_append_node('PageHeight', '%.2f' %(pageSize[1] * 2.8346,))
|
||||
@@ -106,7 +109,7 @@ class report_printscreen_list(report_int):
|
||||
for f in fields_order:
|
||||
s = 0
|
||||
ince += 1
|
||||
if fields[f]['type'] in ('date','time','float','integer'):
|
||||
if fields[f]['type'] in ('date','time','datetime','float','integer'):
|
||||
s = 60
|
||||
strmax -= s
|
||||
if fields[f]['type'] in ('float','integer'):
|
||||
@@ -132,13 +135,11 @@ class report_printscreen_list(report_int):
|
||||
|
||||
new_doc.append(header)
|
||||
lines = etree.Element("lines")
|
||||
|
||||
tsum = []
|
||||
count = len(fields_order)
|
||||
for i in range(0,count):
|
||||
tsum.append(0)
|
||||
|
||||
|
||||
for line in results:
|
||||
node_line = etree.Element("row")
|
||||
count = -1
|
||||
@@ -158,10 +159,28 @@ class report_printscreen_list(report_int):
|
||||
if fields[f]['type'] in ('one2many','many2many') and line[f]:
|
||||
line[f] = '( '+tools.ustr(len(line[f])) + ' )'
|
||||
|
||||
if fields[f]['type'] == 'float':
|
||||
if fields[f]['type'] == 'float' and line[f]:
|
||||
precision=(('digits' in fields[f]) and fields[f]['digits'][1]) or 2
|
||||
line[f]='%.2f'%(line[f])
|
||||
|
||||
if fields[f]['type'] == 'date' and line[f]:
|
||||
format = str(locale.nl_langinfo(locale.D_FMT).replace('%y', '%Y'))
|
||||
d1= mx.DateTime.strptime(line[f],'%Y-%m-%d')
|
||||
new_d1 = d1.strftime(format)
|
||||
line[f] = new_d1
|
||||
|
||||
if fields[f]['type'] == 'time' and line[f]:
|
||||
format = str(locale.nl_langinfo(locale.T_FMT))
|
||||
d1= mx.DateTime.strptime(line[f],'%H:%M:%S')
|
||||
new_d1 = d1.strftime(format)
|
||||
line[f] = new_d1
|
||||
|
||||
if fields[f]['type'] == 'datetime' and line[f]:
|
||||
format = str(locale.nl_langinfo(locale.D_FMT).replace('%y', '%Y'))+' '+str(locale.nl_langinfo(locale.T_FMT))
|
||||
d1= mx.DateTime.strptime(line[f],'%Y-%m-%d %H:%M:%S')
|
||||
new_d1 = d1.strftime(format)
|
||||
line[f] = new_d1
|
||||
|
||||
col = etree.Element("col")
|
||||
col.set('para','yes')
|
||||
col.set('tree','no')
|
||||
@@ -169,7 +188,6 @@ class report_printscreen_list(report_int):
|
||||
col.text = tools.ustr(line[f] or '')
|
||||
if temp[count] == 1:
|
||||
tsum[count] = float(tsum[count]) + float(line[f]);
|
||||
|
||||
else:
|
||||
col.text = '/'
|
||||
node_line.append(col)
|
||||
@@ -197,7 +215,6 @@ class report_printscreen_list(report_int):
|
||||
|
||||
lines.append(node_line)
|
||||
|
||||
|
||||
new_doc.append(lines)
|
||||
styledoc = libxml2.parseFile(os.path.join(tools.config['root_path'],'addons/base/report/custom_new.xsl'))
|
||||
style = libxslt.parseStylesheetDoc(styledoc)
|
||||
|
||||
+3
-3
@@ -659,9 +659,9 @@ class cache(object):
|
||||
if time.time()-self.timeout > self.lasttime:
|
||||
self.lasttime = time.time()
|
||||
t = time.time()-self.timeout
|
||||
for key in self.cache.keys():
|
||||
if self.cache[key][1]<t:
|
||||
del self.cache[key]
|
||||
old_keys = [key for key in self.cache if self.cache[key][1] < t]
|
||||
for key in old_keys:
|
||||
del self.cache[key]
|
||||
|
||||
kwargs2 = self._unify_args(*args, **kwargs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user