Merge lp:~unifield-team/unifield-server/uf3.1 into lp:unifield-server/uf3

Proposed by jftempo
Status: Merged
Merged at revision: 4132
Proposed branch: lp:~unifield-team/unifield-server/uf3.1
Merge into: lp:unifield-server/uf3
Diff against target: 110 lines (+33/-19)
1 file modified
bin/tools/convert.py (+33/-19)
To merge this branch: bzr merge lp:~unifield-team/unifield-server/uf3.1
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+315451@code.launchpad.net

Description of the change

Issue with relative path in xml file on Windows system.

Liked to US-1135 and this kind of directive in account/wizard/account_report_common_view.xml:
 <!ENTITY wizard_template SYSTEM "../../resource/wizard_template_view.xml">
On Win, path is relative to config['addons_path']/account
it should be config['addons_path']/account/wizard

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/tools/convert.py'
--- bin/tools/convert.py 2013-11-07 16:50:06 +0000
+++ bin/tools/convert.py 2017-01-24 11:17:59 +0000
@@ -47,7 +47,6 @@
47import pooler47import pooler
48from config import config48from config import config
49from tools.translate import _49from tools.translate import _
50from yaml_import import convert_yaml_import
5150
52# List of etree._Element subclasses that we choose to ignore when parsing XML.51# List of etree._Element subclasses that we choose to ignore when parsing XML.
53from tools import SKIPPED_ELEMENT_TYPES, cache52from tools import SKIPPED_ELEMENT_TYPES, cache
@@ -551,8 +550,8 @@
551 uid = self.get_uid(cr, self.uid, data_node, rec)550 uid = self.get_uid(cr, self.uid, data_node, rec)
552 wf_service = netsvc.LocalService("workflow")551 wf_service = netsvc.LocalService("workflow")
553 wf_service.trg_validate(uid, model,552 wf_service.trg_validate(uid, model,
554 id,553 id,
555 str(rec.get('action','')), cr)554 str(rec.get('action','')), cr)
556555
557 #556 #
558 # Support two types of notation:557 # Support two types of notation:
@@ -794,7 +793,7 @@
794 return None793 return None
795 res = {}794 res = {}
796 for field in rec.findall('./field'):795 for field in rec.findall('./field'):
797#TODO: most of this code is duplicated above (in _eval_xml)...796 #TODO: most of this code is duplicated above (in _eval_xml)...
798 f_name = field.get("name",'').encode('utf-8')797 f_name = field.get("name",'').encode('utf-8')
799 f_ref = field.get("ref",'').encode('utf-8')798 f_ref = field.get("ref",'').encode('utf-8')
800 f_search = field.get("search",'').encode('utf-8')799 f_search = field.get("search",'').encode('utf-8')
@@ -825,7 +824,7 @@
825 f_val = False824 f_val = False
826 else:825 else:
827 if f_name in model._columns \826 if f_name in model._columns \
828 and model._columns[f_name]._type == 'reference':827 and model._columns[f_name]._type == 'reference':
829 val = self.model_id_get(cr, f_ref)828 val = self.model_id_get(cr, f_ref)
830 f_val = val[0] + ',' + str(val[1])829 f_val = val[0] + ',' + str(val[1])
831 else:830 else:
@@ -868,17 +867,17 @@
868867
869 for n in de.findall('./data'):868 for n in de.findall('./data'):
870 for rec in n:869 for rec in n:
871 if rec.tag in self._tags:870 if rec.tag in self._tags:
872 try:871 try:
873 self._tags[rec.tag](self.cr, rec, n)872 self._tags[rec.tag](self.cr, rec, n)
874 except:873 except:
875 self.__logger.error('Parse error in %s:%d: \n%s',874 self.__logger.error('Parse error in %s:%d: \n%s',
876 rec.getroottree().docinfo.URL,875 rec.getroottree().docinfo.URL,
877 rec.sourceline,876 rec.sourceline,
878 etree.tostring(rec).strip(), exc_info=True)877 etree.tostring(rec).strip(), exc_info=True)
879 self.cr.rollback()878 self.cr.rollback()
880 cache.clean_caches_for_db(self.cr.dbname)879 cache.clean_caches_for_db(self.cr.dbname)
881 raise880 raise
882 return True881 return True
883882
884 def __init__(self, cr, module, idref, mode, report=None, noupdate=False):883 def __init__(self, cr, module, idref, mode, report=None, noupdate=False):
@@ -909,7 +908,7 @@
909 }908 }
910909
911def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init',910def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init',
912 noupdate=False):911 noupdate=False):
913 '''Import csv file :912 '''Import csv file :
914 quote: "913 quote: "
915 delimiter: ,914 delimiter: ,
@@ -978,14 +977,29 @@
978 if os.path.exists(filepath):977 if os.path.exists(filepath):
979 fp = open(filepath, 'rb')978 fp = open(filepath, 'rb')
980 return self.resolve_file(fp, context)979 return self.resolve_file(fp, context)
981 except IOError, e:980 except IOError:
982 pass981 pass
983#982#
984# xml import/export983# xml import/export
985#984#
986def convert_xml_import(cr, module, xmlfile, idref=None, mode='init', noupdate=False, report=None):985def convert_xml_import(cr, module, xmlfile, idref=None, mode='init', noupdate=False, report=None):
987 parser = etree.XMLParser()986 parser = etree.XMLParser()
988 parser.resolvers.add(ModuleEntityResolver([config['addons_path']], module))987
988
989 # if xmlfile is in a subdir (i.e: module/wizard/view.xml)
990 # path set in ENTITY ... SYSTEM should relate to addons_path/module/wizard
991 # on Win wizard dir was missing
992 module_path = os.path.join(config['addons_path'], module)
993 sub_dir = module
994 if isinstance(xmlfile, file):
995 xmlfile_name = xmlfile.name
996 common_prefix = os.path.commonprefix([module_path, xmlfile_name])
997 xmlfile_dir = os.path.dirname(xmlfile_name)
998 extra_dir = os.path.relpath(xmlfile_dir, common_prefix)
999 if extra_dir:
1000 sub_dir = os.path.join(extra_dir, module)
1001
1002 parser.resolvers.add(ModuleEntityResolver([config['addons_path']], sub_dir))
989 doc = etree.parse(xmlfile, parser)1003 doc = etree.parse(xmlfile, parser)
990 relaxng = etree.RelaxNG(1004 relaxng = etree.RelaxNG(
991 etree.parse(os.path.join(config['root_path'],'import_xml.rng' )))1005 etree.parse(os.path.join(config['root_path'],'import_xml.rng' )))

Subscribers

People subscribed via source and target branches

to all changes: