From c68d44a938966968fddbc4f52d4fe859f20f1b7e Mon Sep 17 00:00:00 2001 From: "Harry (Open ERP)" Date: Tue, 14 Jul 2009 10:22:22 +0530 Subject: [PATCH 01/11] [IMP] import/export : added Database ID, ID bzr revid: hmo@tinyerp.com-20090714045222-ryvq3bgymzqs66xt --- bin/osv/orm.py | 173 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 133 insertions(+), 40 deletions(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 2fcf91f1616..1331beec681 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -434,14 +434,14 @@ class orm_template(object): def __export_row(self, cr, uid, row, fields, context=None): - def check_type(type,r): - if type == 'float': + def check_type(field_type): + if field_type == 'float': return 0.0 - elif type == 'integer': + elif field_type == 'integer': return 0 - elif type == 'char': - return '' - return r + elif field_type == 'boolean': + return False + return '' lines = [] data = map(lambda x: '', range(len(fields))) @@ -452,14 +452,27 @@ class orm_template(object): r = row i = 0 while i < len(f): - r = r[f[i]] + if f[i] == 'db_id': + r = r['id'] + elif f[i] == 'id': + model_data = self.pool.get('ir.model.data') + data_ids = model_data.search(cr, uid, [('model','=',r._table_name),('res_id','=',r['id'])]) + if len(data_ids): + d = model_data.read(cr, uid, data_ids, ['name','module'])[0] + if d['module']: + r = '%s.%s'%(d['module'],d['name']) + else: + r = d['name'] + else: + break + else: + r = r[f[i]] if not r: if f[i] in self._columns: - r = check_type(self._columns[f[i]]._type,r) + r = check_type(self._columns[f[i]]._type) elif f[i] in self._inherit_fields: - r = check_type(self._inherit_fields[f[i]][2]._type,r) - - data[fpos] = tools.ustr(r) + r = check_type(self._inherit_fields[f[i]][2]._type) + data[fpos] = r break if isinstance(r, (browse_record_list, list)): first = True @@ -482,41 +495,65 @@ class orm_template(object): break i += 1 if i == len(f): + if isinstance(r, browse_record): + r = r.name data[fpos] = tools.ustr(r or '') return [data] + lines - def export_data(self, cr, uid, ids, fields, context=None): + def export_data(self, cr, uid, ids, fields_to_export, context=None, imp_comp= False): if not context: context = {} - fields = map(lambda x: x.split('/'), fields) + cols = self._columns.copy() + for f in self._inherit_fields: + cols.update({f: self._inherit_fields[f][2]}) + fields_to_export = map(lambda x: x.split('/'), fields_to_export) + fields_export = fields_to_export+[] + warning = '' + warning_fields = [] + for field in fields_export: + if imp_comp and len(field)>1: + warning_fields.append('/'.join(map(lambda x:x in cols and cols[x].string or x,field))) + elif len (field) <=1: + if imp_comp and cols.get(field and field[0],False): + if ((isinstance(cols[field[0]], fields.function) and not cols[field[0]].store) \ + or isinstance(cols[field[0]], fields.related)\ + or isinstance(cols[field[0]], fields.one2many)): + warning_fields.append('/'.join(map(lambda x:x in cols and cols[x].string or x,field))) datas = [] + if imp_comp and len(warning_fields): + warning = 'Following columns cannot be exported since you select to be import compatible.\n%s' %('\n'.join(warning_fields)) + cr.rollback() + return {'warning' : warning} for row in self.browse(cr, uid, ids, context): - datas += self.__export_row(cr, uid, row, fields, context) - return datas + datas += self.__export_row(cr, uid, row, fields_to_export, context) + return {'datas':datas} def import_data(self, cr, uid, fields, datas, mode='init', current_module='', noupdate=False, context=None, filename=None): if not context: context = {} fields = map(lambda x: x.split('/'), fields) logger = netsvc.Logger() - - def process_liness(self, datas, prefix, fields_def, position=0): + ir_model_data_obj = self.pool.get('ir.model.data') + def process_liness(self, datas, prefix, current_module, model_name, fields_def, position=0): line = datas[position] row = {} translate = {} todo = [] warning = '' data_id = False + data_res_id = False + is_xml_id = False + is_db_id = False + ir_model_data_obj = self.pool.get('ir.model.data') # # Import normal fields # for i in range(len(fields)): if i >= len(line): raise Exception(_('Please check that all your lines have %d columns.') % (len(fields),)) - field = fields[i] - if field == ["id"]: - data_id = line[i] + if not line[i]: continue + field = fields[i] if (len(field)==len(prefix)+1) and field[len(prefix)].endswith(':id'): res_id = False if line[i]: @@ -526,8 +563,7 @@ class orm_template(object): if '.' in word: module, xml_id = word.rsplit('.', 1) else: - module, xml_id = current_module, word - ir_model_data_obj = self.pool.get('ir.model.data') + module, xml_id = current_module, word id = ir_model_data_obj._get_id(cr, uid, module, xml_id) res_id2 = ir_model_data_obj.read(cr, uid, [id], @@ -540,8 +576,7 @@ class orm_template(object): if '.' in line[i]: module, xml_id = line[i].rsplit('.', 1) else: - module, xml_id = current_module, line[i] - ir_model_data_obj = self.pool.get('ir.model.data') + module, xml_id = current_module, line[i] id = ir_model_data_obj._get_id(cr, uid, module, xml_id) res_id = ir_model_data_obj.read(cr, uid, [id], ['res_id'])[0]['res_id'] @@ -554,6 +589,63 @@ class orm_template(object): continue if (len(field) == len(prefix)+1) and \ (prefix == field[0:len(prefix)]): + if field[len(prefix)] == "id": + # XML ID + db_id = False + is_xml_id = data_id = line[i] + d = data_id.split('.') + module = len(d)>1 and d[0] or '' + name = len(d)>1 and d[1] or d[0] + data_ids = ir_model_data_obj.search(cr, uid, [('module','=',module),('model','=',model_name),('name','=',name)]) + if len(data_ids): + d = ir_model_data_obj.read(cr, uid, data_ids, ['res_id'])[0] + db_id = d['res_id'] + if is_db_id and not db_id: + data_ids = ir_model_data_obj.search(cr, uid, [('module','=',module),('model','=',model_name),('res_id','=',is_db_id)]) + if not len(data_ids): + ir_model_data_obj.create(cr, uid, {'module':module, 'model':model_name, 'name':name, 'res_id':is_db_id}) + db_id = is_db_id + if is_db_id and int(db_id) != int(is_db_id): + warning += ("Id is not the same than existing one: " + str(is_db_id) + " !\n") + logger.notifyChannel("import", netsvc.LOG_ERROR, + "Id is not the same than existing one: " + str(is_db_id) + ' !\n') + continue + + if field[len(prefix)] == "db_id": + # Database ID + try: + line[i]= int(line[i]) + except Exception, e: + warning += (str(e) + "!\n") + logger.notifyChannel("import", netsvc.LOG_ERROR, + str(e) + '!\n') + continue + is_db_id = line[i] + obj_model = self.pool.get(model_name) + ids = obj_model.search(cr, uid, [('id','=',line[i])]) + if not len(ids): + warning += ("Database ID doesn't exist: " + model_name + ": " + str(line[i]) + " !\n") + logger.notifyChannel("import", netsvc.LOG_ERROR, + "Database ID doesn't exist: " + model_name + ": " + str(line[i]) + ' !\n') + continue + else: + data_res_id = ids[0] + data_ids = ir_model_data_obj.search(cr, uid, [('model','=',model_name),('res_id','=',line[i])]) + if len(data_ids): + d = ir_model_data_obj.read(cr, uid, data_ids, ['name','module'])[0] + data_id = d['name'] + if d['module']: + data_id = '%s.%s'%(d['module'],d['name']) + else: + data_id = d['name'] + if is_xml_id and not data_id: + data_id = is_xml_id + if is_xml_id and is_xml_id!=data_id: + warning += ("Id is not the same than existing one: " + str(line[i]) + " !\n") + logger.notifyChannel("import", netsvc.LOG_ERROR, + "Id is not the same than existing one: " + str(line[i]) + ' !\n') + + continue if fields_def[field[len(prefix)]]['type'] == 'integer': res = line[i] and int(line[i]) elif fields_def[field[len(prefix)]]['type'] == 'boolean': @@ -618,19 +710,20 @@ class orm_template(object): if field[0] not in todo: todo.append(field[len(prefix)]) # - # Import one2many fields + # Import one2many, many2many fields # nbrmax = 1 for field in todo: - newfd = self.pool.get(fields_def[field]['relation']).fields_get( + relation_obj = self.pool.get(fields_def[field]['relation']) + newfd = relation_obj.fields_get( cr, uid, context=context) - res = process_liness(self, datas, prefix + [field], newfd, position) - (newrow, max2, w2, translate2, data_id2) = res + res = process_liness(self, datas, prefix + [field], current_module, relation_obj._name, newfd, position) + (newrow, max2, w2, translate2, data_id2, data_res_id2) = res nbrmax = max(nbrmax, max2) - warning = warning + w2 - reduce(lambda x, y: x and y, newrow) + warning = warning + w2 + reduce(lambda x, y: x and y, newrow) row[field] = (reduce(lambda x, y: x or y, newrow.values()) and \ - [(0, 0, newrow)]) or [] + [(0, 0, newrow)]) or [] i = max2 while (position+i) Date: Tue, 14 Jul 2009 11:12:37 +0530 Subject: [PATCH 02/11] [FIX] export window : use context for import compatable option in pass argument instend of added new argemenent bzr revid: hmo@tinyerp.com-20090714054237-u1sd3j9dnamvv962 --- bin/osv/orm.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 1331beec681..b4be8a4021b 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -447,7 +447,7 @@ class orm_template(object): data = map(lambda x: '', range(len(fields))) done = [] for fpos in range(len(fields)): - f = fields[fpos] + f = fields[fpos] if f: r = row i = 0 @@ -466,7 +466,7 @@ class orm_template(object): else: break else: - r = r[f[i]] + r = r[f[i]] if not r: if f[i] in self._columns: r = check_type(self._columns[f[i]]._type) @@ -480,18 +480,26 @@ class orm_template(object): or [], fields) if fields2 in done: break - done.append(fields2) + done.append(fields2) for row2 in r: lines2 = self.__export_row(cr, uid, row2, fields2, - context) + context) if first: for fpos2 in range(len(fields)): if lines2 and lines2[0][fpos2]: data[fpos2] = lines2[0][fpos2] + if not data[fpos]: + dt = '' + for rr in r : + if isinstance(rr.name, browse_record): + rr = rr.name + dt+=rr.name+',' + data[fpos] = dt[:-1] + break lines += lines2[1:] first = False else: - lines += lines2 + lines += lines2 break i += 1 if i == len(f): @@ -500,9 +508,10 @@ class orm_template(object): data[fpos] = tools.ustr(r or '') return [data] + lines - def export_data(self, cr, uid, ids, fields_to_export, context=None, imp_comp= False): + def export_data(self, cr, uid, ids, fields_to_export, context=None): if not context: context = {} + imp_comp = context.get('import_comp',False) cols = self._columns.copy() for f in self._inherit_fields: cols.update({f: self._inherit_fields[f][2]}) From 64ffe9c6801181ede11dc388610990930d1a0160 Mon Sep 17 00:00:00 2001 From: Quentin De Paoli Date: Tue, 14 Jul 2009 11:15:39 +0200 Subject: [PATCH 03/11] [FIX] security on wokflows bugfixed. The security has to be checked using the current uid, not the one that created the workflow instance! bzr revid: qdp@cyan-20090714091539-xrwqzndzibc6fxy5 --- bin/workflow/wkf_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/workflow/wkf_service.py b/bin/workflow/wkf_service.py index fdc54910c33..dabedad050c 100644 --- a/bin/workflow/wkf_service.py +++ b/bin/workflow/wkf_service.py @@ -52,7 +52,7 @@ class workflow_service(netsvc.Service): cr.execute('select instance_id from wkf_triggers where res_id=%s and model=%s', (res_id,res_type)) res = cr.fetchall() for (instance_id,) in res: - cr.execute('select uid,res_type,res_id from wkf_instance where id=%s', (instance_id,)) + cr.execute('select %s,res_type,res_id from wkf_instance where id=%s', (uid, instance_id,)) ident = cr.fetchone() instance.update(cr, instance_id, ident) From 9148c7fcdf3fa9a98d8f763bdc5b9083ee2be274 Mon Sep 17 00:00:00 2001 From: "JVO,HDA" <> Date: Wed, 15 Jul 2009 19:15:30 +0530 Subject: [PATCH 04/11] [FIX] Added sql_constraint on adding field having size<1 lp bug: https://launchpad.net/bugs/399685 fixed bzr revid: hda@hda-20090715134530-4aj0hth1olefcpdn --- bin/addons/base/ir/ir_model.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/addons/base/ir/ir_model.py b/bin/addons/base/ir/ir_model.py index de1b2f0c53f..7fc27f6cc78 100644 --- a/bin/addons/base/ir/ir_model.py +++ b/bin/addons/base/ir/ir_model.py @@ -229,6 +229,9 @@ class ir_model_fields(osv.osv): 'field_description': lambda *a: '', } _order = "id" + _sql_constraints = [ + ('size_gt_zero', 'CHECK (size>0)', 'Size of the field can never be less than 1 !'), + ] def unlink(self, cr, user, ids, context=None): for field in self.browse(cr, user, ids, context): if field.state <> 'manual': @@ -244,17 +247,18 @@ class ir_model_fields(osv.osv): vals['model'] = model_data.model if context and context.get('manual',False): vals['state'] = 'manual' - res = super(ir_model_fields,self).create(cr, user, vals, context) + res = super(ir_model_fields,self).create(cr, user, vals, context) if vals.get('state','base') == 'manual': if not vals['name'].startswith('x_'): raise except_orm(_('Error'), _("Custom fields must have a name that starts with 'x_' !")) if 'relation' in vals and not self.pool.get('ir.model').search(cr, user, [('model','=',vals['relation'])]): raise except_orm(_('Error'), _("Model %s Does not Exist !" % vals['relation'])) - + if self.pool.get(vals['model']): self.pool.get(vals['model']).__init__(self.pool, cr) self.pool.get(vals['model'])._auto_init(cr, {}) + return res ir_model_fields() From 0eb74074e166d74be45a14750dd61755509bcdc4 Mon Sep 17 00:00:00 2001 From: NCH <> Date: Thu, 16 Jul 2009 14:16:58 +0530 Subject: [PATCH 05/11] [FIX] removed report etree warning of len bzr revid: hda@hda-20090716084658-juwelp201n1xkufd --- bin/report/report_sxw.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/report/report_sxw.py b/bin/report/report_sxw.py index a4fe32a94a0..cc39269b44b 100644 --- a/bin/report/report_sxw.py +++ b/bin/report/report_sxw.py @@ -305,7 +305,7 @@ class rml_parse(object): head_dom = etree.XML(rml_head) for tag in head_dom.getchildren(): found = rml_dom.find('.//'+tag.tag) - if found and len(found): + if found is not None and len(found): if tag.get('position'): found.append(tag) else : From 32c0fdceeacd0e4fc23bca9599021099c449a67b Mon Sep 17 00:00:00 2001 From: "dsh (Open ERP)" Date: Thu, 16 Jul 2009 14:41:10 +0530 Subject: [PATCH 06/11] [FIX] size miss match for page and frame bzr revid: dsh@tinyerp.com-20090716091110-76642lxq3kp7snwn --- bin/addons/base/report/custom_default.xsl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/addons/base/report/custom_default.xsl b/bin/addons/base/report/custom_default.xsl index f08078fcde4..2074bd2f7fb 100644 --- a/bin/addons/base/report/custom_default.xsl +++ b/bin/addons/base/report/custom_default.xsl @@ -7,8 +7,10 @@ 1cm 1cm 1cm - 29.7cm,21cm - + + + + a4_letter From 2bb32450ab1f0606cc2c5a592d2d2fb43ff42b42 Mon Sep 17 00:00:00 2001 From: "Christophe Chauvet (Syleam)" <> Date: Thu, 16 Jul 2009 18:20:41 +0530 Subject: [PATCH 07/11] [FIX] Import : context provided for language translation lp bug: https://launchpad.net/bugs/394876 fixed bzr revid: jvo@tinyerp.com-20090716125041-72iaz586utt2j1mq --- bin/osv/orm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index b4be8a4021b..ca5dbf471eb 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -685,7 +685,7 @@ class orm_template(object): if line[i]: relation = fields_def[field[len(prefix)]]['relation'] res2 = self.pool.get(relation).name_search(cr, uid, - line[i], [], operator='=') + line[i], [], operator='=', context=context) res = (res2 and res2[0][0]) or False if not res: warning += ('Relation not found: ' + line[i] + \ @@ -699,7 +699,7 @@ class orm_template(object): relation = fields_def[field[len(prefix)]]['relation'] for word in line[i].split(config.get('csv_internal_sep')): res2 = self.pool.get(relation).name_search(cr, - uid, word, [], operator='=') + uid, word, [], operator='=', context=context) res3 = (res2 and res2[0][0]) or False if not res3: warning += ('Relation not found: ' + \ From 43b66e1a1d039a8330f3c4ebda124773702eff16 Mon Sep 17 00:00:00 2001 From: "VRA(OpenERP)" <> Date: Fri, 17 Jul 2009 20:21:24 +0530 Subject: [PATCH 08/11] [FIX] Print screen reports will behave acc. to locale for date,datetime lp bug: https://launchpad.net/bugs/399811 fixed bzr revid: jvo@tinyerp.com-20090717145124-0kkb1b7dvp9qu5od --- bin/report/printscreen/ps_list.py | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/bin/report/printscreen/ps_list.py b/bin/report/printscreen/ps_list.py index c3dd6b341bd..b78a98a98a5 100644 --- a/bin/report/printscreen/ps_list.py +++ b/bin/report/printscreen/ps_list.py @@ -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) From 22ac7ba66eae2d53ded9a1dc46d9e1078db313d2 Mon Sep 17 00:00:00 2001 From: Olivier Laurent Date: Sat, 18 Jul 2009 13:21:10 +0200 Subject: [PATCH 09/11] [FIX] RuntimeError in the cache system lp bug: https://launchpad.net/bugs/310918 fixed bzr revid: olt@tinyerp.com-20090718112110-0p29jjruvhiwjrp0 --- bin/tools/misc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/tools/misc.py b/bin/tools/misc.py index a2712ee006e..9d4ea4d66cd 100644 --- a/bin/tools/misc.py +++ b/bin/tools/misc.py @@ -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] Date: Mon, 20 Jul 2009 11:32:28 +0200 Subject: [PATCH 10/11] [FIX] tools.amount_to_text_en: now displays cents bzr revid: olt@tinyerp.com-20090720093228-qqdqetrt2kg08coe --- bin/tools/amount_to_text_en.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/tools/amount_to_text_en.py b/bin/tools/amount_to_text_en.py index 3fcf5b20b4c..45168bb2d9f 100644 --- a/bin/tools/amount_to_text_en.py +++ b/bin/tools/amount_to_text_en.py @@ -98,7 +98,9 @@ def amount_to_text(number, currency): cents_number = int(number * 100) % 100 cents_name = (cents_number > 1) and 'cents' or 'cent' cents = _100_to_text(cents_number) - cents = cents_number and '%s %s' % (cents, cents_name) or '' + cents = cents_number and '%s %s' % (cents.lower(), cents_name) or '' + if cents: + lacs += ' and %s' % (cents, ) return lacs From e2852ed13e5df22c11361e2e1cff2eb21cd076d9 Mon Sep 17 00:00:00 2001 From: NCH <> Date: Wed, 22 Jul 2009 16:16:16 +0530 Subject: [PATCH 11/11] [FIX] place tag bzr revid: hda@hda-20090722104616-z497bh35iwfh6a7g --- bin/report/render/rml2pdf/trml2pdf.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/report/render/rml2pdf/trml2pdf.py b/bin/report/render/rml2pdf/trml2pdf.py index 5d4c93b67fd..ee34befcd58 100644 --- a/bin/report/render/rml2pdf/trml2pdf.py +++ b/bin/report/render/rml2pdf/trml2pdf.py @@ -203,7 +203,7 @@ class _rml_doc(object): self.canvas.save() class _rml_canvas(object): - def __init__(self, canvas,localcontext, doc_tmpl=None, doc=None, images={}, path='.', title=None): + def __init__(self, canvas, localcontext, doc_tmpl=None, doc=None, images={}, path='.', title=None): self.localcontext = localcontext self.canvas = canvas self.styles = doc.styles @@ -295,7 +295,7 @@ class _rml_canvas(object): self.canvas.circle(x_cen=utils.unit_get(node.get('x')), y_cen=utils.unit_get(node.get('y')), r=utils.unit_get(node.get('radius')), **utils.attr_get(node, [], {'fill':'bool','stroke':'bool'})) def _place(self, node): - flows = _rml_flowable(self.doc, images=self.images, path=self.path, title=self.title).render(node) + flows = _rml_flowable(self.doc, self.localcontext, images=self.images, path=self.path, title=self.title).render(node) infos = utils.attr_get(node, ['x','y','width','height']) infos['y']+=infos['height'] @@ -433,12 +433,12 @@ class _rml_draw(object): def render(self, canvas, doc): canvas.saveState() - cnv = _rml_canvas(canvas,self.localcontext, doc, self.styles, images=self.images, path=self.path, title=self.canvas_title) + cnv = _rml_canvas(canvas, self.localcontext, doc, self.styles, images=self.images, path=self.path, title=self.canvas_title) cnv.render(self.node) canvas.restoreState() class _rml_flowable(object): - def __init__(self,doc,localcontext, images={}, path='.', title=None): + def __init__(self, doc, localcontext, images={}, path='.', title=None): self.localcontext = localcontext self.doc = doc self.styles = doc.styles @@ -454,7 +454,7 @@ class _rml_flowable(object): if key in ('rml_except', 'rml_loop', 'rml_tag'): del txt_n.attrib[key] if True or not self._textual(n).isspace(): - txt_n.text = self._textual(n) + txt_n.text = utils.xml2str(self._textual(n)) txt_n.tail = '' rc1 += etree.tostring(txt_n) #rc1 += utils._process_text(self, node.tail or '')