commit
f598229714
|
@ -485,14 +485,37 @@
|
|||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Attachments">
|
||||
<field colspan="4" name="name" select="1"/>
|
||||
<field colspan="4" name="datas"/>
|
||||
<field name="datas_fname"/>
|
||||
<newline/>
|
||||
<field name="res_model" select="1"/>
|
||||
<field name="res_id"/>
|
||||
<separator colspan="4" string="Description"/>
|
||||
<field colspan="4" name="description" nolabel="1"/>
|
||||
<group colspan="4" col="6">
|
||||
<field name="name" select="1" />
|
||||
<field name="create_uid" select="1"/>
|
||||
<field name="create_date" select="1"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Attachment">
|
||||
<group col="2" colspan="2">
|
||||
<separator string="Data" colspan="2"/>
|
||||
<field name="datas" filename="datas_fname"/>
|
||||
<field name="datas_fname" select="1"/>
|
||||
</group>
|
||||
<group col="2" colspan="2">
|
||||
<separator string="Attached To" colspan="2"/>
|
||||
<field name="res_model" select="1"/>
|
||||
<field name="res_id"/>
|
||||
</group>
|
||||
<separator string="Preview" colspan="4"/>
|
||||
<field
|
||||
name="preview"
|
||||
widget="image"
|
||||
readonly="1"
|
||||
nolabel="1"
|
||||
colspan="4"
|
||||
img_height="400"
|
||||
img_width="800"/>
|
||||
</page>
|
||||
<page string="Notes">
|
||||
<field colspan="4" name="description" nolabel="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -503,8 +526,9 @@
|
|||
<field name="arch" type="xml">
|
||||
<tree string="Attachments">
|
||||
<field name="name"/>
|
||||
<field name="res_model"/>
|
||||
<field name="res_id"/>
|
||||
<field name="datas_fname"/>
|
||||
<field name="create_uid"/>
|
||||
<field name="create_date"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -514,7 +538,7 @@
|
|||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">ir.attachment</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="view_attachment_tree"/>
|
||||
<field name="view_id" eval="False"/>
|
||||
</record>
|
||||
<menuitem action="action_attachment" id="menu_action_attachment" parent="base.next_id_4"/>
|
||||
|
||||
|
|
|
@ -96,16 +96,29 @@ class ir_attachment(osv.osv):
|
|||
self.pool.get('ir.model.access').unregister_cache_clearing_method(self._name, 'clear_cache')
|
||||
return super(ir_attachment, self).__del__()
|
||||
|
||||
def _get_preview(self, cr, uid, ids, name, arg, context=None):
|
||||
result = {}
|
||||
for i in self.browse(cr, uid, ids, context=context or {}):
|
||||
result[i.id] = False
|
||||
for format in ('png','PNG','jpg','JPG'):
|
||||
if (i.datas_fname or '').endswith(format):
|
||||
result[i.id]= i.datas
|
||||
return result
|
||||
|
||||
_name = 'ir.attachment'
|
||||
_columns = {
|
||||
'name': fields.char('Attachment Name',size=64, required=True),
|
||||
'datas': fields.binary('Data'),
|
||||
'datas_fname': fields.char('Data Filename',size=64),
|
||||
'preview': fields.function(_get_preview, type='binary', string='Image Preview', method=True),
|
||||
'datas_fname': fields.char('Filename',size=64),
|
||||
'description': fields.text('Description'),
|
||||
# Not required due to the document module !
|
||||
'res_model': fields.char('Resource Object',size=64, readonly=True),
|
||||
'res_id': fields.integer('Resource ID', readonly=True),
|
||||
'link': fields.char('Link', size=256)
|
||||
'link': fields.char('Link', size=256),
|
||||
|
||||
'create_date': fields.datetime('Date Created', readonly=True),
|
||||
'create_uid': fields.many2one('res.users', 'Creator', readonly=True),
|
||||
}
|
||||
ir_attachment()
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
<para style="Standard">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<blockTable colWidths="139.0,220.0,152.0" repeatRows="1" style="Table1">
|
||||
<blockTable colWidths="139.0,220.0,152.0" style="Table1">
|
||||
<tr>
|
||||
<td>
|
||||
<para style="Table Contents">
|
||||
|
@ -102,14 +102,14 @@
|
|||
</para>
|
||||
<section>
|
||||
<para style="Text body">[[ repeatIn(objects, 'module') ]]</para>
|
||||
<blockTable colWidths="510.0" repeatRows="1" style="Tableau1">
|
||||
<blockTable colWidths="510.0" style="Tableau1">
|
||||
<tr>
|
||||
<td>
|
||||
<para style="P5">Module: [[ module.name ]]</para>
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
<blockTable colWidths="276.0,234.0" repeatRows="1" style="Tableau2">
|
||||
<blockTable colWidths="276.0,234.0" style="Tableau2">
|
||||
<tr>
|
||||
<td>
|
||||
<pre style="Standard">Name: [[ objdoc(module.shortdesc) ]]</pre>
|
||||
|
@ -130,7 +130,7 @@
|
|||
<pre style="P6">[[ module.description ]]</pre>
|
||||
<section>
|
||||
<para style="Standard">[[ repeatIn(findobj(module.name) ,'object') ]]</para>
|
||||
<blockTable colWidths="510.0" repeatRows="1" style="Tableau3">
|
||||
<blockTable colWidths="510.0" style="Tableau3">
|
||||
<tr>
|
||||
<td>
|
||||
<para style="P7">Object: [[ object.name ]]</para>
|
||||
|
@ -138,7 +138,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
<blockTable colWidths="113.0,397.0" repeatRows="1" style="Tableau4">
|
||||
<blockTable colWidths="113.0,397.0" style="Tableau4">
|
||||
<tr>
|
||||
<td>
|
||||
<para style="P9"><font face="Times-Roman">[[ repeatIn(findflds(object.model), 'field') ]]</font> [[ field[0] ]]</para>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
|
@ -359,7 +359,7 @@ class orm_template(object):
|
|||
view_load=%s, select_level=%s, readonly=%s ,required=%s
|
||||
WHERE
|
||||
model=%s AND name=%s""", (
|
||||
vals['model_id'], vals['field_description'], vals['ttype'],
|
||||
vals['model_id'], vals['field_description'], vals['ttype'],
|
||||
vals['relation'], bool(vals['view_load']),
|
||||
vals['select_level'], bool(vals['readonly']),bool(vals['required']), vals['model'], vals['name']
|
||||
))
|
||||
|
@ -724,7 +724,7 @@ class orm_template(object):
|
|||
if val:
|
||||
val2 = translation_obj._get_source(cr, user,
|
||||
self._name + ',' + f, 'selection',
|
||||
context.get('lang', False) or 'en_US', val)
|
||||
context.get('lang', False) or 'en_US', val)
|
||||
sel2.append((key, val2 or val))
|
||||
sel = sel2
|
||||
res[f]['selection'] = sel
|
||||
|
@ -838,7 +838,7 @@ class orm_template(object):
|
|||
continue
|
||||
|
||||
ok = True
|
||||
|
||||
|
||||
if user != 1: # admin user has all roles
|
||||
serv = netsvc.LocalService('object_proxy')
|
||||
user_roles = serv.execute_cr(cr, user, 'res.users', 'read', [user], ['roles_id'])[0]['roles_id']
|
||||
|
@ -2365,13 +2365,12 @@ class orm(orm_template):
|
|||
# records unless they were explicitely asked for
|
||||
if 'active' in self._columns and (active_test and context.get('active_test', True)):
|
||||
if args:
|
||||
args.insert(0, ('active', '=', 1))
|
||||
active_in_args = False
|
||||
for a in args:
|
||||
if a[0] == 'active':
|
||||
active_in_args = True
|
||||
if not active_in_args:
|
||||
args.insert(0, ('active', '=', 1))
|
||||
args.insert(0, ('active', '=', 1))
|
||||
else:
|
||||
args = [('active', '=', 1)]
|
||||
|
||||
|
|
Loading…
Reference in New Issue