[IMP] Add file='...' on <field> tags + [FIX] forced noupdate

bzr revid: fp@openerp.com-20130922093113-80p3pig45qbm7lsn
This commit is contained in:
Fabien Pinckaers 2013-09-22 11:31:13 +02:00
parent cc187b884b
commit 29326cd993
3 changed files with 15 additions and 1 deletions

View File

@ -44,6 +44,7 @@ class ir_attachment(osv.osv):
The default implementation is the file:dirname location that stores files
on the local filesystem using name based on their sha1 hash
"""
_order = 'id desc'
def _name_get_resname(self, cr, uid, ids, object, method, context):
data = {}
for attachment in self.browse(cr, uid, ids, context=context):

View File

@ -167,6 +167,10 @@
<rng:ref name="any"/>
</rng:oneOrMore>
</rng:group>
<rng:group>
<rng:attribute name="file"/>
<rng:empty/>
</rng:group>
<rng:group>
<rng:attribute name="ref"/>
<rng:empty/>

View File

@ -175,6 +175,13 @@ def _eval_xml(self, node, pool, cr, uid, idref, context=None):
if t == 'html':
return _process("".join([etree.tostring(n, encoding='utf-8')
for n in node]), idref)
if node.get('file'):
import openerp.tools
import base64
fp = openerp.tools.file_open(node.get('file'))
result = base64.b64encode(fp.read())
return result
if t == 'file':
from ..modules import module
path = node.text.strip()
@ -241,7 +248,9 @@ class xml_import(object):
return val.lower() not in ('0', 'false', 'off')
def isnoupdate(self, data_node=None):
return self.noupdate or (len(data_node) and self.nodeattr2bool(data_node, 'noupdate', False))
if data_node and data_node.get('noupdate'):
return len(data_node) and self.nodeattr2bool(data_node, 'noupdate', False)
return self.noupdate
def get_context(self, data_node, node, eval_dict):
data_node_context = (len(data_node) and data_node.get('context','').encode('utf8'))