[MERGE] attachment: add type: url, binary into ir.attachment
bzr revid: hmo@tinyerp.com-20100629110320-axfcr3nrckv2pr21
This commit is contained in:
commit
505bbd1dcc
|
@ -655,27 +655,37 @@
|
|||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Attachments">
|
||||
<group colspan="4" col="6">
|
||||
<group colspan="4" col="2">
|
||||
<field name="name" select="1" />
|
||||
<field name="create_uid" select="2"/>
|
||||
<field name="create_date" select="2"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Attachment">
|
||||
<group col="2" colspan="2">
|
||||
<separator string="Data" colspan="2"/>
|
||||
<group col="4" colspan="4">
|
||||
<separator string="Data" colspan="2"/>
|
||||
<field name="type"/>
|
||||
<newline />
|
||||
<group col="2" colspan="4" attrs="{'invisible':[('type','=','url')]}">
|
||||
<field name="datas" filename="datas_fname"/>
|
||||
<field name="datas_fname" select="1"/>
|
||||
</group>
|
||||
<group col="2" colspan="4" attrs="{'invisible':[('type','=','binary')]}">
|
||||
<field name="url" widget="url"/>
|
||||
</group>
|
||||
</group>
|
||||
<group col="2" colspan="2">
|
||||
<separator string="Attached To" colspan="2"/>
|
||||
<field name="res_model" select="2"/>
|
||||
<field name="res_id"/>
|
||||
<field name="res_name"/>
|
||||
</group>
|
||||
<group col="2" groups="base.group_extended">
|
||||
<separator string="Created" colspan="2"/>
|
||||
<field name="create_uid" select="2"/>
|
||||
<field name="create_date" select="2"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Notes">
|
||||
<field colspan="4" name="description" nolabel="1"/>
|
||||
<field name="description" nolabel="1" colspan="4"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
|
|
|
@ -94,25 +94,42 @@ class ir_attachment(osv.osv):
|
|||
if model_object and res_id:
|
||||
model_pool = self.pool.get(model_object)
|
||||
res = model_pool.name_get(cr,uid,[res_id],context)
|
||||
data[attachment.id] = res[0][1]
|
||||
data[attachment.id] = (res and res[0][1]) or False
|
||||
else:
|
||||
data[attachment.id] = False
|
||||
return data
|
||||
|
||||
_name = 'ir.attachment'
|
||||
_columns = {
|
||||
'name': fields.char('Attachment Name',size=64, required=True),
|
||||
'name': fields.char('Attachment Name',size=256, required=True),
|
||||
'datas': fields.binary('Data'),
|
||||
'datas_fname': fields.char('Filename',size=64),
|
||||
'datas_fname': fields.char('Filename',size=256),
|
||||
'description': fields.text('Description'),
|
||||
# Not required due to the document module !
|
||||
'res_name': fields.function(_name_get_resname, type='char', string='Resource Name', method=True),
|
||||
'res_model': fields.char('Resource Object',size=64, readonly=True),
|
||||
'res_id': fields.integer('Resource ID', readonly=True),
|
||||
'link': fields.char('Link', size=256),
|
||||
'res_name': fields.function(_name_get_resname, type='char',
|
||||
string='Resource Name', method=True),
|
||||
'res_model': fields.char('Resource Object',size=64, readonly=True,
|
||||
help="The database object this attachment will be attached to"),
|
||||
'res_id': fields.integer('Resource ID', readonly=True,
|
||||
help="The record id this is attached to"),
|
||||
'url': fields.char('Url', size=512, oldname="link"),
|
||||
'type': fields.selection(
|
||||
[ ('url','URL'), ('binary','Binary'), ],
|
||||
'Type', help="Binary File or external URL", required=True),
|
||||
|
||||
'create_date': fields.datetime('Date Created', readonly=True),
|
||||
'create_uid': fields.many2one('res.users', 'Creator', readonly=True),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'type': 'binary',
|
||||
}
|
||||
|
||||
def _auto_init(self, cr, context=None):
|
||||
super(ir_attachment, self)._auto_init(cr, context)
|
||||
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = %s', ('ir_attachment_res_idx',))
|
||||
if not cr.fetchone():
|
||||
cr.execute('CREATE INDEX ir_attachment_res_idx ON ir_attachment (res_model, res_id)')
|
||||
cr.commit()
|
||||
|
||||
ir_attachment()
|
||||
|
||||
|
|
|
@ -285,11 +285,11 @@ class OerpAuthProxy(AuthProxy):
|
|||
self.provider.log("Failing authorization after 5 requests w/o password")
|
||||
raise AuthRejectedExc("Authorization failed.")
|
||||
self.auth_tries += 1
|
||||
raise AuthRequiredExc(atype = 'Basic', realm=self.provider.realm)
|
||||
raise AuthRequiredExc(atype='Basic', realm=self.provider.realm)
|
||||
|
||||
import security
|
||||
class OpenERPAuthProvider(AuthProvider):
|
||||
def __init__(self,realm = 'OpenERP User'):
|
||||
def __init__(self,realm='OpenERP User'):
|
||||
self.realm = realm
|
||||
|
||||
def setupAuth(self, multi, handler):
|
||||
|
|
Loading…
Reference in New Issue