bzr revid: fp@tinyerp.com-20081110175828-fjcxla4ygbwgru2v
This commit is contained in:
Fabien Pinckaers 2008-11-10 18:58:28 +01:00
parent 74af540f43
commit b4ae45eb70
3 changed files with 55 additions and 18 deletions

View File

@ -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"/>

View File

@ -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()

View File

@ -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>