From 2f33c8c852255acecb22b2fa3069b0f640ab55ca Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Mon, 27 Apr 2009 20:17:49 +0200 Subject: [PATCH 1/7] merge bzr revid: fp@tinyerp.com-20090427181749-fgvyzm9096idvob6 --- addons/account/account.py | 2 +- addons/account/test/test_parent_structure.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/account/account.py b/addons/account/account.py index 3ca1b53b91b..c330bbd0e6d 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -380,7 +380,7 @@ class account_account(osv.osv): if not default: default = {} default = default.copy() - default['parent_id'] = False + default['code'] = (account['code'] or '') + '(copy)' if not local: done_list = [] if account.id in done_list: diff --git a/addons/account/test/test_parent_structure.py b/addons/account/test/test_parent_structure.py index e21424afa56..a6e8e108c0d 100644 --- a/addons/account/test/test_parent_structure.py +++ b/addons/account/test/test_parent_structure.py @@ -42,6 +42,8 @@ for a in account_lists: assert not ((a2['parent_right']>a['parent_left']) and (a2['parent_left']a['parent_left']) and (a2['parent_right'] Date: Wed, 29 Apr 2009 19:36:17 +0200 Subject: [PATCH 2/7] merge bzr revid: fp@tinyerp.com-20090429173617-44uf762027pjlzq6 --- addons/purchase/wizard/wizard_group.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/purchase/wizard/wizard_group.py b/addons/purchase/wizard/wizard_group.py index a538a80bc23..8c0bc2dd319 100644 --- a/addons/purchase/wizard/wizard_group.py +++ b/addons/purchase/wizard/wizard_group.py @@ -62,7 +62,7 @@ def _mergeOrders(self, cr, uid, data, context): list_key.append((field, field_val)) list_key.sort() return tuple(list_key) - + # compute what the new orders should contain new_orders = {} for porder in [order for order in order_obj.browse(cr, uid, data['ids']) if order.state == 'draft']: @@ -120,7 +120,6 @@ def _mergeOrders(self, cr, uid, data, context): del value['uom_factor'] value.update(dict(key)) order_data['order_line'] = [(0, 0, value) for value in order_data['order_line'].itervalues()] - # create the new order neworder_id = order_obj.create(cr, uid, order_data) allorders.append(neworder_id) From e0ccd7abee1041cd14ae6e8da355653bd808863c Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 5 May 2009 08:44:05 +0200 Subject: [PATCH 3/7] bugifx_rng bzr revid: fp@tinyerp.com-20090505064405-s9a0aq08c55pxmo6 --- bin/addons/base/rng/view.rng | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/bin/addons/base/rng/view.rng b/bin/addons/base/rng/view.rng index f7ab0fe9477..d87a4cd8ffa 100644 --- a/bin/addons/base/rng/view.rng +++ b/bin/addons/base/rng/view.rng @@ -199,6 +199,28 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -365,6 +387,7 @@ + From 983c03b4237c5c22860ae0775d53c231660ace77 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 5 May 2009 10:36:51 +0200 Subject: [PATCH 4/7] [FIX] maintenance: avoid a crash when the creditential to access the migration server aren't correct bzr revid: christophe@tinyerp.com-20090505083651-xmzmyhho68q5me2t --- bin/tools/maintenance.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/tools/maintenance.py b/bin/tools/maintenance.py index 369282b902a..1469eacd5a3 100644 --- a/bin/tools/maintenance.py +++ b/bin/tools/maintenance.py @@ -37,6 +37,9 @@ class remote_contract(object): except: raise RemoteContractException("Unable to contact the migration server") + if not self.__userid: + raise RemoteContractException("Unable to contact the migration server") + self.__rpc = xmlrpclib.ServerProxy(self.__server + 'object') From 3d818a0f1a6e16f44dee3555c6eec4379e0a976d Mon Sep 17 00:00:00 2001 From: "dsh (Open ERP)" Date: Tue, 5 May 2009 17:08:39 +0530 Subject: [PATCH 5/7] small change for the server action - python code bzr revid: dsh@tinyerp.com-20090505113839-32acl57cuky3b1s2 --- bin/addons/base/ir/ir_actions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index c6cc2344b09..c31288b019e 100644 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -120,6 +120,7 @@ class report_xml(osv.osv): ('raw', 'raw'), ('sxw', 'sxw'), ('odt', 'odt'), + ('html2html','Html from html'), ], string='Type', required=True), 'groups_id': fields.many2many('res.groups', 'res_groups_report_rel', 'uid', 'gid', 'Groups'), 'attachment': fields.char('Save As Attachment Prefix', size=128, help='This is the filename of the attachment used to store the printing result. Keep empty to not save the printed reports. You can use a python expression with the object and time variables.'), @@ -525,7 +526,8 @@ class actions_server(osv.osv): 'time': time, 'ids': ids, 'cr': cr, - 'uid': uid + 'uid': uid, + 'obj':obj } exec action.code in localdict if 'action' in localdict: From 5c828843a9edd501ca4c80499f15f1ec02263c2a Mon Sep 17 00:00:00 2001 From: "dsh (Open ERP)" Date: Tue, 5 May 2009 17:12:27 +0530 Subject: [PATCH 6/7] changes in report engine for html2html bzr revid: dsh@tinyerp.com-20090505114227-mp9ndr3rkbkycfl7 --- bin/report/interface.py | 6 +++ bin/report/preprocess.py | 3 ++ bin/report/render/__init__.py | 3 +- bin/report/render/html2html/__init__.py | 26 ++++++++++ bin/report/render/html2html/html2html.py | 62 ++++++++++++++++++++++++ bin/report/render/rml.py | 11 +++++ bin/report/report_sxw.py | 45 ++++++++++++++++- 7 files changed, 153 insertions(+), 3 deletions(-) create mode 100644 bin/report/render/html2html/__init__.py create mode 100644 bin/report/render/html2html/html2html.py diff --git a/bin/report/interface.py b/bin/report/interface.py index 0aaf60889c8..09ea80720ac 100644 --- a/bin/report/interface.py +++ b/bin/report/interface.py @@ -82,6 +82,7 @@ class report_rml(report_int): 'raw': self.create_raw, 'sxw': self.create_sxw, 'odt': self.create_odt, + 'html2html' : self.create_html2html, } def create(self, cr, uid, ids, datas, context): @@ -203,6 +204,11 @@ class report_rml(report_int): obj.render() return obj.get() + def create_html2html(self, rml, localcontext = None, logo=None, title=None): + obj = render.html2html(rml, localcontext, self.bin_datas) + obj.render() + return obj.get() + def create_raw(self,rml, localcontext = None, logo=None, title=None): obj = render.odt2odt(etree.XML(rml),localcontext) obj.render() diff --git a/bin/report/preprocess.py b/bin/report/preprocess.py index fe7f173af53..441df892c1c 100644 --- a/bin/report/preprocess.py +++ b/bin/report/preprocess.py @@ -2,6 +2,7 @@ from lxml import etree import re rml_parents = ['tr','story','section'] +html_parents = ['tr','body','div'] sxw_parents = ['{http://openoffice.org/2000/table}table-row','{http://openoffice.org/2000/office}body','{http://openoffice.org/2000/text}section'] class report(object): @@ -36,6 +37,8 @@ class report(object): match = rml_parents if type in ['odt','sxw']: match = sxw_parents + if type =='html2html': + match = html_parents if txt.group(3): match = [txt.group(3)] n = node diff --git a/bin/report/render/__init__.py b/bin/report/render/__init__.py index ebfa37bfa27..819fa0c1546 100644 --- a/bin/report/render/__init__.py +++ b/bin/report/render/__init__.py @@ -21,8 +21,7 @@ ############################################################################## from simple import simple -from rml import rml, rml2html, odt2odt - +from rml import rml, rml2html, odt2odt , html2html from render import render try: diff --git a/bin/report/render/html2html/__init__.py b/bin/report/render/html2html/__init__.py new file mode 100644 index 00000000000..16385ae50a0 --- /dev/null +++ b/bin/report/render/html2html/__init__.py @@ -0,0 +1,26 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +from html2html import parseString + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/bin/report/render/html2html/html2html.py b/bin/report/render/html2html/html2html.py new file mode 100644 index 00000000000..7894dd78516 --- /dev/null +++ b/bin/report/render/html2html/html2html.py @@ -0,0 +1,62 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +from report.render.rml2pdf import utils +from lxml import etree +import copy +import pooler + + +class html2html(object): + def __init__(self, html, localcontext): + self.localcontext = localcontext + self.etree = html + self._node = None + + + def render(self): + def process_text(node,new_node): + if new_node.tag in ['story','tr','section']: + new_node.attrib.clear() + for child in utils._child_get(node, self): + new_child = copy.deepcopy(child) + new_node.append(new_child) + if len(child): + for n in new_child: + new_child.remove(n) + process_text(child, new_child) + else: + if new_child.tag=='img' and new_child.get('name'): + src = utils._process_text(self, new_child.get('name')) + if src : + new_child.set('src','data:image/gif;base64,%s'%src) + new_child.text = utils._process_text(self, child.text) + self._node = copy.deepcopy(self.etree) + for n in self._node: + self._node.remove(n) + process_text(self.etree, self._node) + return self._node + +def parseString(node, localcontext = {}): + r = html2html(node, localcontext) + return r.render() + diff --git a/bin/report/render/rml.py b/bin/report/render/rml.py index faad2c4c0b1..8bac7e32518 100644 --- a/bin/report/render/rml.py +++ b/bin/report/render/rml.py @@ -24,6 +24,7 @@ import render import rml2pdf import rml2html as htmlizer import odt2odt as odt +import html2html as html class rml(render.render): @@ -60,5 +61,15 @@ class odt2odt(render.render): def _render(self): return odt.parseNode(self.rml_dom,self.localcontext) +class html2html(render.render): + def __init__(self, rml, localcontext = None, datas = {}): + render.render.__init__(self, datas) + self.rml_dom = rml + self.localcontext = localcontext + self.output_type = 'html' + + def _render(self): + return html.parseString(self.rml_dom,self.localcontext) + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/bin/report/report_sxw.py b/bin/report/report_sxw.py index aaa61cac0f0..426b738f338 100644 --- a/bin/report/report_sxw.py +++ b/bin/report/report_sxw.py @@ -61,6 +61,11 @@ sxw_parents = { 'section': 0, } +html_parents = { + 'tr' : 1, + 'body' : 0, + 'div' : 0 + } sxw_tag = "p" rml2sxw = { @@ -166,6 +171,7 @@ class rml_parse(object): 'logo' : user.company_id.logo, 'lang' : user.company_id.partner_id.lang, 'translate' : self._translate, + 'setHtmlImage' : self.set_html_image } self.localcontext.update(context) self.rml_header = user.company_id.rml_header @@ -190,6 +196,17 @@ class rml_parse(object): def removeParentNode(self, tag=None): raise Exception('Skip') + def set_html_image(self,attach_id): + try : + att_id = int(attach_id) + print att_id + attachment = self.pool.get('ir.attachment').browse(self.cr,self.uid,att_id) + print attachment + print attachment.datas + return attachment.datas + except : + return '' + def setLang(self, lang): if not lang or self.default_lang.has_key(lang): if not lang: @@ -342,8 +359,10 @@ class report_sxw(report_rml, preprocess.report): report_type = report_xml.report_type if report_type in ['sxw','odt']: fnct = self.create_source_odt - elif report_type in ['pdf','html','raw']: + elif report_type in ['pdf','raw','html']: fnct = self.create_source_pdf + elif report_type=='html2html': + fnct = self.create_source_html2html else: raise 'Unknown Report Type' return fnct(cr, uid, ids, data, report_xml, context) @@ -351,6 +370,9 @@ class report_sxw(report_rml, preprocess.report): def create_source_odt(self, cr, uid, ids, data, report_xml, context=None): return self.create_single_odt(cr, uid, ids, data, report_xml, context or {}) + def create_source_html2html(self, cr, uid, ids, data, report_xml, context=None): + return self.create_single_html2html(cr, uid, ids, data, report_xml, context or {}) + def create_source_pdf(self, cr, uid, ids, data, report_xml, context=None): if not context: context={} @@ -476,5 +498,26 @@ class report_sxw(report_rml, preprocess.report): final_op = sxw_io.getvalue() sxw_io.close() return (final_op, report_type) + + def create_single_html2html(self, cr, uid, ids, data, report_xml, context={}): + context = context.copy() + report_type = 'html' + context['parents'] = html_parents + + rml = report_xml.report_rml_content + + rml_parser = self.parser(cr, uid, self.name2, context) + rml_parser.parents = html_parents + rml_parser.tag = sxw_tag + objs = self.getObjects(cr, uid, ids, context) + rml_parser.set_context(objs, data, ids, report_type) + + rml_dom = etree.HTML(rml) + rml_dom = self.preprocess_rml(rml_dom,'html2html') + create_doc = self.generators['html2html'] + html = etree.tostring(create_doc(rml_dom, rml_parser.localcontext)) + + return (html, report_type) + From 0bfbee835559db828f99243b31bd871a4ec06475 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 5 May 2009 14:39:15 +0200 Subject: [PATCH 7/7] [FIX] maintenance contract: error when adding a contract without any modules covered bzr revid: christophe@tinyerp.com-20090505123915-cy9zah0mzb75qzm9 --- bin/addons/base/maintenance/maintenance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/addons/base/maintenance/maintenance.py b/bin/addons/base/maintenance/maintenance.py index 18adc1c730b..07c6160a113 100644 --- a/bin/addons/base/maintenance/maintenance.py +++ b/bin/addons/base/maintenance/maintenance.py @@ -178,8 +178,8 @@ class maintenance_contract_wizard(osv.osv_memory): is_ok = contract_info['status'] in ('partial', 'full') if is_ok: + module_ids = [] if contract_info['modules_with_contract']: - module_ids = [] for name, version in contract_info['modules_with_contract']: contract_module = self.pool.get('maintenance.contract.module') res = contract_module.search(cr, uid, [('name', '=', name),('version', '=', version)])