[FIX] in <record> tag, "forcecreate" attribute is now implicit
bzr revid: christophe@tinyerp.com-20090120181433-z1gne7bm93esjfos
This commit is contained in:
parent
f16cf978ff
commit
03fa514309
|
@ -203,8 +203,17 @@ class assertion_report(object):
|
|||
|
||||
class xml_import(object):
|
||||
|
||||
def isnoupdate(self, data_node = None):
|
||||
return self.noupdate or (data_node and data_node.getAttribute('noupdate').strip() not in ('', '0', 'False'))
|
||||
@staticmethod
|
||||
def nodeattr2bool(node, attr, default=False):
|
||||
if not node.hasAttribute(attr):
|
||||
return default
|
||||
val = node.getAttribute(attr).strip()
|
||||
if not val:
|
||||
return default
|
||||
return val.lower() not in ('0', 'false', 'off')
|
||||
|
||||
def isnoupdate(self, data_node=None):
|
||||
return self.noupdate or (data_node and self.nodeattr2bool(data_node, 'noupdate', False))
|
||||
|
||||
def get_context(self, data_node, node, eval_dict):
|
||||
data_node_context = (data_node and data_node.getAttribute('context').encode('utf8'))
|
||||
|
@ -677,12 +686,11 @@ form: module.record_id""" % (xml_id,)
|
|||
return None
|
||||
else:
|
||||
# if the resource didn't exist
|
||||
if rec.getAttribute("forcecreate"):
|
||||
# we want to create it, so we let the normal "update" behavior happen
|
||||
pass
|
||||
else:
|
||||
# otherwise do nothing
|
||||
if not self.nodeattr2bool(rec, 'forcecreate', True):
|
||||
# we don't want to create it, so we skip it
|
||||
return None
|
||||
# else, we let the record to be created
|
||||
|
||||
else:
|
||||
# otherwise it is skipped
|
||||
return None
|
||||
|
|
Loading…
Reference in New Issue