commit
4896fa8f18
|
@ -144,6 +144,7 @@ CREATE TABLE res_users (
|
|||
context_tz varchar(64) default null,
|
||||
signature text,
|
||||
-- action_id int references ir_act_window on delete set null,
|
||||
context_lang varchar(64) default '',
|
||||
action_id int,
|
||||
primary key(id)
|
||||
);
|
||||
|
|
|
@ -32,7 +32,7 @@ class report(object):
|
|||
return txt.group(0)
|
||||
def _sub1(txt):
|
||||
if len(txt.group(4)) > 1:
|
||||
return []
|
||||
return " "
|
||||
match = rml_parents
|
||||
if type in ['odt','sxw']:
|
||||
match = sxw_parents
|
||||
|
@ -44,7 +44,7 @@ class report(object):
|
|||
n.set('rml_loop', txt.group(2))
|
||||
return '[['+txt.group(1)+"''"+txt.group(4)+']]'
|
||||
t = _regex1.sub(_sub1, node.text)
|
||||
if t == []:
|
||||
if t == " ":
|
||||
t = _regex11.sub(_sub1, node.text)
|
||||
t = _regex3.sub(_sub3, t)
|
||||
node.text = _regex2.sub(_sub2, t)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
|
@ -29,6 +29,8 @@ regex_t = re.compile('\(([0-9\.]*),([0-9\.]*),([0-9\.]*)\)')
|
|||
regex_h = re.compile('#([0-9a-zA-Z][0-9a-zA-Z])([0-9a-zA-Z][0-9a-zA-Z])([0-9a-zA-Z][0-9a-zA-Z])')
|
||||
|
||||
def get(col_str):
|
||||
if col_str == None:
|
||||
col_str = ''
|
||||
global allcols
|
||||
if col_str in allcols.keys():
|
||||
return allcols[col_str]
|
||||
|
|
|
@ -44,12 +44,10 @@ from lxml import etree
|
|||
_regex = re.compile('\[\[(.+?)\]\]')
|
||||
|
||||
def _child_get(node, self=None, tagname=None):
|
||||
tr_flag = True
|
||||
for n in node:
|
||||
if self and self.localcontext and n.get('rml_loop', False):
|
||||
oldctx = self.localcontext
|
||||
for ctx in eval(n.get('rml_loop'),{}, self.localcontext):
|
||||
tr_flag = False
|
||||
self.localcontext.update(ctx)
|
||||
if (tagname is None) or (n.tag==tagname):
|
||||
if n.get('rml_except', False):
|
||||
|
@ -69,8 +67,6 @@ def _child_get(node, self=None, tagname=None):
|
|||
else:
|
||||
yield n
|
||||
self.localcontext = oldctx
|
||||
if n.tag == 'tr' and tr_flag:
|
||||
yield n
|
||||
continue
|
||||
if self and self.localcontext and n.get('rml_except', False):
|
||||
try:
|
||||
|
|
|
@ -179,6 +179,7 @@ class rml_parse(object):
|
|||
self.lang_dict = {}
|
||||
self.default_lang = {}
|
||||
self.lang_dict_called = False
|
||||
self._transl_regex = re.compile('(\[\[.+?\]\])')
|
||||
|
||||
def setTag(self, oldtag, newtag, attrs=None):
|
||||
return newtag, attrs
|
||||
|
@ -264,10 +265,18 @@ class rml_parse(object):
|
|||
return ret_lst
|
||||
|
||||
def _translate(self,text):
|
||||
lang = self.localcontext.get('lang', False)
|
||||
if lang and not text.isspace():
|
||||
lang = self.localcontext['lang']
|
||||
if lang and text and not text.isspace():
|
||||
transl_obj = self.pool.get('ir.translation')
|
||||
return transl_obj._get_source(self.cr, self.uid, self.name, 'rml', lang, text.replace('\n',' ').strip()) or text
|
||||
piece_list = self._transl_regex.split(text)
|
||||
for pn in range(len(piece_list)):
|
||||
if not self._transl_regex.match(piece_list[pn]):
|
||||
source_string = piece_list[pn].replace('\n', ' ').strip()
|
||||
if len(source_string):
|
||||
translated_string = transl_obj._get_source(self.cr, self.uid, self.name, 'rml', lang, source_string)
|
||||
if translated_string:
|
||||
piece_list[pn] = piece_list[pn].replace(source_string, translated_string)
|
||||
text = ''.join(piece_list)
|
||||
return text
|
||||
|
||||
def _add_header(self, rml_dom, header=1):
|
||||
|
@ -290,6 +299,17 @@ class rml_parse(object):
|
|||
found.getparent().replace(found,tag)
|
||||
return True
|
||||
|
||||
def set_context(self, objects, data, ids, report_type = None):
|
||||
self.localcontext['data'] = data
|
||||
self.localcontext['objects'] = objects
|
||||
self.datas = data
|
||||
self.ids = ids
|
||||
self.objects = objects
|
||||
if report_type:
|
||||
if report_type=='odt' :
|
||||
self.localcontext.update({'name_space' :common.odt_namespace})
|
||||
else:
|
||||
self.localcontext.update({'name_space' :common.sxw_namespace})
|
||||
|
||||
class report_sxw(report_rml, preprocess.report):
|
||||
def __init__(self, name, table, rml=False, parser=rml_parse, header=True, store=False):
|
||||
|
@ -299,19 +319,6 @@ class report_sxw(report_rml, preprocess.report):
|
|||
self.header = header
|
||||
self.store = store
|
||||
|
||||
def set_context(self, objects, data, ids, rml_parser, report_xml = None):
|
||||
rml_parser.localcontext['data'] = data
|
||||
rml_parser.localcontext['objects'] = objects
|
||||
rml_parser.datas = data
|
||||
rml_parser.ids = ids
|
||||
rml_parser.objects = objects
|
||||
if report_xml:
|
||||
if report_xml.report_type=='odt' :
|
||||
rml_parser.localcontext.update({'name_space' :common.odt_namespace})
|
||||
else:
|
||||
rml_parser.localcontext.update({'name_space' :common.sxw_namespace})
|
||||
|
||||
|
||||
def getObjects(self, cr, uid, ids, context):
|
||||
table_obj = pooler.get_pool(cr.dbname).get(self.table)
|
||||
return table_obj.browse(cr, uid, ids, list_class=browse_record_list, context=context, fields_process=_fields_process)
|
||||
|
@ -402,7 +409,7 @@ class report_sxw(report_rml, preprocess.report):
|
|||
rml = report_xml.report_rml_content
|
||||
rml_parser = self.parser(cr, uid, self.name2, context)
|
||||
objs = self.getObjects(cr, uid, ids, context)
|
||||
self.set_context(objs, data, ids, rml_parser,report_xml)
|
||||
rml_parser.set_context(objs, data, ids, report_xml.report_type)
|
||||
processed_rml = self.preprocess_rml(etree.XML(rml),report_xml.report_type)
|
||||
if report_xml.header:
|
||||
rml_parser._add_header(processed_rml)
|
||||
|
@ -426,7 +433,7 @@ class report_sxw(report_rml, preprocess.report):
|
|||
rml_parser.parents = sxw_parents
|
||||
rml_parser.tag = sxw_tag
|
||||
objs = self.getObjects(cr, uid, ids, context)
|
||||
self.set_context(objs, data, ids,rml_parser,report_xml)
|
||||
rml_parser.set_context(objs, data, ids,report_xml.report_type)
|
||||
|
||||
rml_dom_meta = node = etree.XML(meta)
|
||||
elements = node.findall(rml_parser.localcontext['name_space']["meta"]+"user-defined")
|
||||
|
@ -456,7 +463,7 @@ class report_sxw(report_rml, preprocess.report):
|
|||
rml_parser.parents = sxw_parents
|
||||
rml_parser.tag = sxw_tag
|
||||
objs = self.getObjects(cr, uid, ids, context)
|
||||
self.set_context(objs, data, ids, rml_parser,report_xml)
|
||||
rml_parser.set_context(objs, data, ids, report_xml.report_type)
|
||||
rml_dom = self.preprocess_rml(etree.XML(rml),report_type)
|
||||
create_doc = self.generators[report_type]
|
||||
odt = create_doc(rml_dom,rml_parser.localcontext)
|
||||
|
|
|
@ -108,7 +108,7 @@ class Cursor(object):
|
|||
self.count+=1
|
||||
if '%d' in query or '%f' in query:
|
||||
log(query, netsvc.LOG_WARNING)
|
||||
log("SQL queries mustn't containt %d or %f anymore. Use only %s", netsvc.LOG_WARNING)
|
||||
log("SQL queries mustn't contain %d or %f anymore. Use only %s", netsvc.LOG_WARNING)
|
||||
if params:
|
||||
query = query.replace('%d', '%s').replace('%f', '%s')
|
||||
|
||||
|
@ -116,6 +116,7 @@ class Cursor(object):
|
|||
now = mdt.now()
|
||||
|
||||
try:
|
||||
params = params or None
|
||||
res = self._obj.execute(query, params)
|
||||
except Exception, e:
|
||||
log("bad query: %s" % self._obj.query)
|
||||
|
|
Loading…
Reference in New Issue