Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--dev option for v8 #9

Open
wants to merge 74 commits into
base: 8.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
3874065
[FIX] issue #3272 : don't try to copy translations of not copiable fi…
ccomb Oct 25, 2014
4062c4a
Merge remote-tracking branch 'odoo/8.0' into 8.0
ccomb Nov 11, 2014
2b9e704
[FIX] #3670 Don't override previous value if no journal is found
ccomb Nov 15, 2014
b8f8e2f
Merge remote-tracking branch 'oca/8.0' into 8.0
Nov 16, 2014
2de0d2f
Merge remote-tracking branch 'oca/8.0' into 8.0
Nov 18, 2014
8772ea8
Merge branch '8.0' of https://github.com/OCA/OCB into 8.0
ccomb Nov 20, 2014
0070ff4
Merge branch '8.0' of http://github.com/odoo/odoo into 8.0
ccomb Nov 20, 2014
bdc2d9b
Merge branch '8.0' of github.com:anybox/odoo into 8.0
ccomb Nov 20, 2014
513a1af
Merge remote-tracking branch 'oca/8.0' into 8.0
Nov 29, 2014
a097971
Merge remote-tracking branch 'oca/8.0' into 8.0
Dec 7, 2014
c62c243
Inform users about signup email validity
ccomb Dec 17, 2014
57252c4
Merge branch 'signup_email_validity_v8' into 8.0
ccomb Dec 17, 2014
9ffcd3b
[FIX] #4309 Attachments with res_id=0 should not be considered orphaned
ccomb Dec 18, 2014
f99a85c
Merge branch 'fix_4309_v8' into 8.0
ccomb Dec 18, 2014
7ed25dd
24h validity is only for the reset password
ccomb Dec 19, 2014
6463059
Merge remote-tracking branch 'odoo/8.0' into 8.0
ccomb Dec 19, 2014
b3b4aec
Merge remote-tracking branch 'ocb/8.0' into 8.0
ccomb Dec 19, 2014
0312fab
Merge remote-tracking branch 'oca/8.0' into 8.0
Jan 8, 2015
2b6d55d
Merge remote-tracking branch 'oca/8.0' into 8.0
Jan 12, 2015
304df80
Merge remote-tracking branch 'ocb/8.0' into 8.0
franckbret Jan 27, 2015
36e6abd
Merge remote-tracking branch 'oca/8.0' into 8.0
Feb 3, 2015
8b6d19e
Merge remote-tracking branch 'oca/8.0' into 8.0
Mar 4, 2015
bfab069
Merge remote-tracking branch 'ocb/8.0' into 8.0
franckbret Mar 24, 2015
2de4fa2
Merge branch '8.0' of https://github.com/OCA/OCB into 8.0
ccomb Mar 31, 2015
e3f9901
Merge branch '8.0' of https://github.com/odoo/odoo into 8.0
ccomb Mar 31, 2015
4eec15d
Merge remote-tracking branch 'ocb/8.0' into 8.0
ccomb Apr 21, 2015
6218cfa
Merge remote-tracking branch 'ocb/8.0' into 8.0
ccomb Apr 24, 2015
54714ef
Merge branch '8.0' of github.com:anybox/odoo into 8.0
ccomb May 5, 2015
0b0f798
Merge remote-tracking branch 'ocb/8.0' into 8.0
ccomb May 5, 2015
8136eaa
Merge branch '8.0' of https://github.com/OCA/OCB into 8.0
ccomb May 7, 2015
711571f
Merge branch 'faster_orm_intersect_v8' into 8.0
ccomb May 7, 2015
054c054
Merge remote-tracking branch 'ocb/8.0' into 8.0
franckbret May 28, 2015
efc7190
Merge remote-tracking branch 'oca/8.0' into 8.0
Jun 9, 2015
ba21be0
Merge branch '8.0' of https://github.com/OCA/OCB into 8.0
ccomb Jun 18, 2015
8c26c57
Merge remote-tracking branch 'oca/8.0' into 8.0
Jun 24, 2015
2d19d2b
Merge remote-tracking branch 'ocb/8.0' into 8.0
franckbret Jul 7, 2015
6a207e5
Merge remote-tracking branch 'ocb/8.0' into 8.0
ccomb Jul 14, 2015
2f1a0b3
Avoid reloading unchanged files each time
ccomb Jul 14, 2015
f60e79a
fixed for v8
ccomb Jul 15, 2015
95e65cd
Merge branch '8.0' of https://github.com/OCA/OCB into 8.0
ccomb Jul 15, 2015
cec8987
switch to reportlab 3.1.44 because of install problems with 3.1.8 (Se…
ccomb Jul 16, 2015
5fc1578
Merge branch '8.0' of http://github.com/odoo/odoo into 8.0
ccomb Jul 16, 2015
5d8bb7c
Merge branch '8.0' of https://github.com/OCA/OCB into 8.0
ccomb Jul 16, 2015
8201766
Merge branch 'broken_requirements' into 8.0
ccomb Jul 16, 2015
c855ff8
Merge branch '8.0' of https://github.com/OCA/OCB into 8.0
ccomb Jul 27, 2015
4848e08
Merge branch '8.0' of https://github.com/OCA/OCB into 8.0
ccomb Aug 7, 2015
5c15ab3
Merge branch 'cached_update_8' into 8.0-anybox
ccomb Aug 13, 2015
4fad592
Merge branch '8.0-anybox' of ssh://github.com/anybox/odoo into 8.0
ccomb Aug 13, 2015
3fb901c
Merge pull request #8 from anybox/cached_update_8
ccomb Aug 14, 2015
cfe7956
Merge branch '8.0' of https://github.com/oca/ocb into 8.0
ccomb Aug 18, 2015
982a158
Backported the --dev option from v9
ccomb Aug 20, 2015
2fe7247
missing import
ccomb Aug 20, 2015
038b111
maching seems not reliable
ccomb Aug 29, 2015
f9594f9
Merge remote-tracking branch 'ocb/8.0' into 8.0
franckbret Sep 3, 2015
f6cd597
Merge branch '8.0' of https://github.com/OCA/OCB into 8.0
ccomb Sep 10, 2015
eea6ca0
Merge branch '8.0' of github.com:anybox/odoo into dev_mode_v8
ccomb Sep 13, 2015
5bea37f
Merge branch '8.0' of https://github.com/OCA/OCB into 8.0
ccomb Sep 13, 2015
a8f1d3b
Merge branch '8.0' of github.com:anybox/odoo into dev_mode_v8
ccomb Sep 13, 2015
c663e42
Merge branch '8.0' of https://github.com/OCA/OCB into 8.0
ccomb Sep 24, 2015
bde1098
Merge branch '8.0' of github.com:anybox/odoo into dev_mode_v8
ccomb Sep 24, 2015
d182bc0
don't break if menu id is unicode
ccomb Sep 25, 2015
12591b6
Merge branch 'fix_add_menu' into 8.0
ccomb Sep 25, 2015
0e02fc3
Merge branch '8.0' of https://github.com/OCA/OCB into 8.0
ccomb Sep 25, 2015
369397f
Merge branch '8.0' of github.com:anybox/odoo into dev_mode_v8
ccomb Sep 25, 2015
de9541b
Merge branch '8.0' of https://github.com/OCA/OCB into 8.0
ccomb Oct 4, 2015
b581078
Merge branch '8.0' of https://github.com/odoo/odoo into 8.0
ccomb Oct 4, 2015
d863338
change the same way as upstream (see 249d021)
ccomb Oct 4, 2015
11e8c0c
Merge remote-tracking branch 'oca/8.0' into 8.0
Oct 22, 2015
71de42e
Merge remote-tracking branch 'oca/8.0' into 8.0
Oct 25, 2015
2d36d28
Merge branch '8.0' of https://github.com/OCA/OCB into 8.0
ccomb Nov 18, 2015
f98ec97
Merge remote-tracking branch 'oca/8.0' into 8.0
Nov 20, 2015
c4d1ec1
Merge branch '8.0' of https://github.com/OCA/OCB into 8.0
ccomb Jan 7, 2016
2af965c
Merge branch '8.0' of https://github.com/anybox/odoo into dev_mode_v8
ccomb Jan 14, 2016
033fdab
Merge branch '8.0' of https://github.com/OCA/OCB into dev_mode_v8
ccomb Jan 14, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/auth_signup/auth_signup_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<field name="body_html"><![CDATA[
<p>A password reset was requested for the Odoo account linked to this email.</p>

<p>You may change your password by following <a href="${object.signup_url}">this link</a>.</p>
<p>You may change your password by following <a href="${object.signup_url}">this link</a>, which will remain valid during 24 hours</p>

<p>Note: If you do not expect this, you can safely ignore this email.</p>]]></field>
</record>
Expand Down
2 changes: 1 addition & 1 deletion addons/website/models/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ def replace_id(old_id, new_id):
self.unlink(cr, uid, to_delete, context=context)
for menu in data['data']:
mid = menu['id']
if isinstance(mid, str):
if isinstance(mid, basestring):
new_id = self.create(cr, uid, {'name': menu['name']}, context=context)
replace_id(mid, new_id)
for menu in data['data']:
Expand Down
3 changes: 2 additions & 1 deletion openerp/addons/base/ir/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ def check(self, cr, uid, ids, mode, context=None, values=None):
if create_uid != uid:
require_employee = True
continue
res_ids.setdefault(rmod,set()).add(rid)
if rid:
res_ids.setdefault(rmod,set()).add(rid)
if values:
if values.get('res_model') and values.get('res_id'):
res_ids.setdefault(values['res_model'],set()).add(values['res_id'])
Expand Down
3 changes: 3 additions & 0 deletions openerp/addons/base/ir/ir_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ def _handle_exception(self, exception):
if attach:
return attach

# Don't handle exception but use werkeug debugger if server in --dev mode
if openerp.tools.config['dev_mode']:
raise
# If handle_exception returns something different than None, it will be used as a response
try:
return request._handle_exception(exception)
Expand Down
7 changes: 7 additions & 0 deletions openerp/addons/base/ir/ir_qweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ def render_node(self, element, qwebcontext):
generated_attributes = ""
t_render = None
template_attributes = {}

debugger = element.get('t-debug')
if debugger is not None:
if openerp.tools.config['dev_mode']:
__import__(debugger).set_trace() # pdb, ipdb, pudb, ...
else:
_logger.warning("@t-debug in template '%s' is only available in --dev mode" % qwebcontext['__template__'])
for (attribute_name, attribute_value) in element.attrib.iteritems():
attribute_name = unicode(attribute_name)
if attribute_name == "groups":
Expand Down
119 changes: 108 additions & 11 deletions openerp/addons/base/ir/ir_ui_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@
import openerp
from openerp import tools, api
from openerp.http import request
from openerp.modules.module import get_resource_path, get_resource_from_path
from openerp.osv import fields, osv, orm
from openerp.tools import graph, SKIPPED_ELEMENT_TYPES, SKIPPED_ELEMENTS
from openerp.tools import config
from openerp.tools.parse_version import parse_version
from openerp.tools.safe_eval import safe_eval as eval
from openerp.tools.view_validation import valid_view
from openerp.tools import misc
from openerp.tools.translate import _
from openerp.tools.convert import _fix_multiple_roots

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -105,6 +108,32 @@ def _hasclass(context, *cls):

return node_classes.issuperset(cls)

def get_view_arch_from_file(filename, xmlid):

doc = etree.parse(filename)
node = None
for n in doc.xpath('//*[@id="%s"] | //*[@id="%s"]' % (xmlid, xmlid.split('.')[1])):
if n.tag in ('template', 'record'):
node = n
break
if node is not None:
if node.tag == 'record':
field = node.find('field[@name="arch"]')
_fix_multiple_roots(field)
inner = ''.join([etree.tostring(child) for child in field.iterchildren()])
return field.text + inner
elif node.tag == 'template':
# The following dom operations has been copied from convert.py's _tag_template()
if not node.get('inherit_id'):
node.set('t-name', xmlid)
node.tag = 't'
else:
node.tag = 'data'
node.attrib.pop('id', None)
return etree.tostring(node)
_logger.warning("Could not find view arch definition in file '%s' for xmlid '%s'" % (filename, xmlid))
return None

xpath_utils = etree.FunctionNamespace(None)
xpath_utils['hasclass'] = _hasclass

Expand All @@ -118,6 +147,56 @@ def _get_model_data(self, cr, uid, ids, fname, args, context=None):
result.update(map(itemgetter('res_id', 'id'), data_ids))
return result

def _views_from_model_data(self, cr, uid, ids, context=None):
IMD = self.pool['ir.model.data']
data_ids = IMD.search_read(cr, uid, [('id', 'in', ids), ('model', '=', 'ir.ui.view')], ['res_id'], context=context)
return map(itemgetter('res_id'), data_ids)

def _arch_get(self, cr, uid, ids, name, arg, context=None):
"""backported from v9"""
result = {}
for view in self.browse(cr, uid, ids, context=context):
arch_fs = None
if config['dev_mode'] and view.arch_fs and view.xml_id:
# It is safe to split on / herebelow because arch_fs is explicitely stored with '/'
fullpath = get_resource_path(*view.arch_fs.split('/'))
arch_fs = get_view_arch_from_file(fullpath, view.xml_id)
result[view.id] = arch_fs or view.arch_db
return result

def _arch_set(self, cr, uid, ids, field_name, field_value, args, context=None):
"""backported from v9"""
if not isinstance(ids, list):
ids = [ids]
if field_value:
for view in self.browse(cr, uid, ids, context=context):
data = dict(arch_db=field_value)
key = 'install_mode_data'
if context and key in context:
imd = context[key]
if (self._model._name == imd['model']
and (not view.xml_id
or view.xml_id.split('.')[-1] == imd['xml_id'].split('.')[-1]
or view.xml_id == imd['xml_id'])):
# we store the relative path to the resource instead of the absolute path, if found
# (it will be missing e.g. when importing data-only modules using base_import_module)
path_info = get_resource_from_path(imd['xml_file'])
if path_info:
data['arch_fs'] = '/'.join(path_info[0:2])
self.write(cr, uid, ids, data, context=context)

return True

@api.multi
def _arch_base_get(self, name, arg):
""" Return the field 'arch' without translation. """
return self.with_context(lang=None)._arch_get(name, arg)

@api.multi
def _arch_base_set(self, name, value, arg):
""" Assign the field 'arch' without translation. """
return self.with_context(lang=None)._arch_set(name, value, arg)

_columns = {
'name': fields.char('View Name', required=True),
'model': fields.char('Object', select=True),
Expand All @@ -132,7 +211,10 @@ def _get_model_data(self, cr, uid, ids, fname, args, context=None):
('kanban', 'Kanban'),
('search','Search'),
('qweb', 'QWeb')], string='View Type'),
'arch': fields.text('View Architecture', required=True),
'arch': fields.function(_arch_get, fnct_inv=_arch_set, string='View Architecture', type="text", nodrop=True),
'arch_base': fields.function(_arch_base_get, fnct_inv=_arch_base_set, string='View Architecture', type="text"),
'arch_db': fields.text('Arch Blob', oldname='arch'),
'arch_fs': fields.char('Arch Filename'),
'inherit_id': fields.many2one('ir.ui.view', 'Inherited View', ondelete='restrict', select=True),
'inherit_children_ids': fields.one2many('ir.ui.view','inherit_id', 'Inherit Views'),
'field_parent': fields.char('Child Field'),
Expand Down Expand Up @@ -223,7 +305,7 @@ def _check_xml(self, cr, uid, ids, context=None):
" extend an other view"),
]
_constraints = [
(_check_xml, 'Invalid view definition', ['arch']),
(_check_xml, 'Invalid view definition', ['arch', 'arch_base']),
]

def _auto_init(self, cr, context=None):
Expand Down Expand Up @@ -260,6 +342,11 @@ def write(self, cr, uid, ids, vals, context=None):
if context is None:
context = {}

# If view is modified we remove the arch_fs information thus activating the arch_db
# version. An `init` of the view will restore the arch_fs for the --dev mode
if 'arch' in vals and 'install_mode_data' not in context:
vals['arch_fs'] = False

# drop the corresponding view customizations (used for dashboards for example), otherwise
# not all users would see the updated views
custom_view_ids = self.pool.get('ir.ui.view.custom').search(cr, uid, [('ref_id', 'in', ids)])
Expand Down Expand Up @@ -840,15 +927,11 @@ def postprocess_and_fields(self, cr, user, model, node, view_id, context=None):
#------------------------------------------------------
# QWeb template views
#------------------------------------------------------
@tools.ormcache_context(accepted_keys=('lang','inherit_branding', 'editable', 'translatable'))
def read_template(self, cr, uid, xml_id, context=None):
if isinstance(xml_id, (int, long)):
view_id = xml_id
else:
if '.' not in xml_id:
raise ValueError('Invalid template id: %r' % (xml_id,))
view_id = self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, xml_id, raise_if_not_found=True)

# apply ormcache_context decorator unless in dev mode...
@tools.conditional(not config['dev_mode'],
tools.ormcache_context(accepted_keys=('lang','inherit_branding', 'editable', 'translatable')))
def _read_template(self, cr, uid, view_id, context=None):
arch = self.read_combined(cr, uid, view_id, fields=['arch'], context=context)['arch']
arch_tree = etree.fromstring(arch)

Expand All @@ -861,8 +944,22 @@ def read_template(self, cr, uid, xml_id, context=None):
arch = etree.tostring(root, encoding='utf-8', xml_declaration=True)
return arch

def read_template(self, cr, uid, xml_id, context=None):
if isinstance(xml_id, (int, long)):
view_id = xml_id
else:
if '.' not in xml_id:
raise ValueError('Invalid template id: %r' % (xml_id,))
view_id = self.get_view_id(cr, uid, xml_id, context=context)
return self._read_template(cr, uid, view_id, context=context)

def get_view_id(self, cr, uid, xml_id, context=None):
return self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, xml_id, raise_if_not_found=True)


def clear_cache(self):
self.read_template.clear_cache(self)
if not config['dev_mode']:
self._read_template.clear_cache(self)

def _contains_branded(self, node):
return node.tag == 't'\
Expand Down
3 changes: 2 additions & 1 deletion openerp/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

from openerp.modules.module import get_modules, get_modules_with_version, \
load_information_from_description_file, get_module_resource, get_module_path, \
initialize_sys_path, load_openerp_module, init_module_models, adapt_version
initialize_sys_path, load_openerp_module, init_module_models, adapt_version, \
get_resource_path, get_resource_from_path

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
14 changes: 14 additions & 0 deletions openerp/modules/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import sys
import threading
import time
import md5

import openerp
import openerp.modules.db
Expand Down Expand Up @@ -113,6 +114,19 @@ def _load_data(cr, module_name, idref, mode, kind):
for filename in _get_files_of_kind(kind):
_logger.info("loading %s/%s", module_name, filename)
noupdate = False
if tools.config.options.get('noupdate_if_unchanged'):
pathname = os.path.join(module_name, filename)
cr.execute('select value from ir_values where name=%s and key=%s', (pathname, 'digest'))
olddigest = (cr.fetchone() or (None,))[0]
if olddigest is None:
cr.execute('insert into ir_values (name, model, key, value) values (%s, %s, %s, NULL)',
(pathname, 'ir_module_module', 'digest',))
with tools.file_open(pathname) as fp:
digest = md5.md5(fp.read()).hexdigest()
if digest == olddigest:
noupdate = True
else:
cr.execute('update ir_values set value=%s where name=%s and key=%s', (digest, pathname, 'digest'))
if kind in ('demo', 'demo_xml') or (filename.endswith('.csv') and kind in ('init', 'init_xml')):
noupdate = True
tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
Expand Down
30 changes: 28 additions & 2 deletions openerp/modules/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def get_module_filetree(module, dir='.'):

return tree

def get_module_resource(module, *args):
def get_resource_path(module, *args):
"""Return the full path of a resource of the given module.

:param module: module name
Expand All @@ -167,7 +167,6 @@ def get_module_resource(module, *args):
:rtype: str
:return: absolute path to the resource

TODO name it get_resource_path
TODO make it available inside on osv object (self.get_resource_path)
"""
mod_path = get_module_path(module)
Expand All @@ -179,6 +178,33 @@ def get_module_resource(module, *args):
return resource_path
return False

# backwards compatibility
get_module_resource = get_resource_path

def get_resource_from_path(path):
"""Tries to extract the module name and the resource's relative path
out of an absolute resource path.

If operation is successfull, returns a tuple containing the module name, the relative path
to the resource using '/' as filesystem seperator[1] and the same relative path using
os.path.sep seperators.

[1] same convention as the resource path declaration in manifests

:param path: absolute resource path

:rtype: tuple
:return: tuple(module_name, relative_path, os_relative_path) if possible, else None
"""
resource = [path.replace(adpath, '') for adpath in ad_paths if path.startswith(adpath)]
if resource:
relative = resource[0].split(os.path.sep)
if not relative[0]:
relative.pop(0)
module = relative.pop(0)
return (module, '/'.join(relative), os.path.sep.join(relative))
return None

def get_module_icon(module):
iconpath = ['static', 'description', 'icon.png']
if get_module_resource(module, *iconpath):
Expand Down
2 changes: 2 additions & 0 deletions openerp/tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ def __init__(self, fname=None):
group = optparse.OptionGroup(parser, "Advanced options")
if os.name == 'posix':
group.add_option('--auto-reload', dest='auto_reload', action='store_true', my_default=False, help='enable auto reload')
group.add_option('--dev', dest='dev_mode', action='store_true', my_default=False, help='enable developper mode')
group.add_option('--debug', dest='debug_mode', action='store_true', my_default=False, help='enable debug mode')
group.add_option("--stop-after-init", action="store_true", dest="stop_after_init", my_default=False,
help="stop the server after its initialization")
Expand Down Expand Up @@ -419,6 +420,7 @@ def die(cond, msg):
'xmlrpcs_interface', 'xmlrpcs_port', 'xmlrpcs',
'secure_cert_file', 'secure_pkey_file', 'dbfilter', 'log_level', 'log_db',
'log_db_level', 'geoip_database',
'dev_mode',
]

for arg in keys:
Expand Down
19 changes: 16 additions & 3 deletions openerp/tools/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,17 @@ def _tag_record(self, cr, rec, data_node=None, mode=None):
rec_model = rec.get("model").encode('ascii')
model = self.pool[rec_model]
rec_id = rec.get("id",'').encode('ascii')
rec_context = rec.get("context", None)
rec_context = rec.get("context", {})
if rec_context:
rec_context = unsafe_eval(rec_context)

if self.xml_filename and rec_id:
rec_context['install_mode_data'] = dict(
xml_file=self.xml_filename,
xml_id=rec_id,
model=rec_model,
)

self._test_xml_id(rec_id)
# in update mode, the record won't be updated if the data node explicitely
# opt-out using @noupdate="1". A second check will be performed in
Expand Down Expand Up @@ -857,7 +865,7 @@ def parse(self, de, mode=None):
raise ParseError, (misc.ustr(e), etree.tostring(rec).rstrip(), rec.getroottree().docinfo.URL, rec.sourceline), exc_info[2]
return True

def __init__(self, cr, module, idref, mode, report=None, noupdate=False):
def __init__(self, cr, module, idref, mode, report=None, noupdate=False, xml_filename=None):

self.mode = mode
self.module = module
Expand All @@ -869,6 +877,7 @@ def __init__(self, cr, module, idref, mode, report=None, noupdate=False):
report = assertion_report.assertion_report()
self.assertion_report = report
self.noupdate = noupdate
self.xml_filename = xml_filename
self._tags = {
'record': self._tag_record,
'delete': self._tag_delete,
Expand Down Expand Up @@ -983,7 +992,11 @@ def convert_xml_import(cr, module, xmlfile, idref=None, mode='init', noupdate=Fa

if idref is None:
idref={}
obj = xml_import(cr, module, idref, mode, report=report, noupdate=noupdate)
if isinstance(xmlfile, file):
xml_filename = xmlfile.name
else:
xml_filename = xmlfile
obj = xml_import(cr, module, idref, mode, report=report, noupdate=noupdate, xml_filename=xml_filename)
obj.parse(doc.getroot(), mode=mode)
return True

Expand Down
Loading