mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-26 10:28:40 -06:00
Polymorphic inherit for ir.attachment
This commit is contained in:
parent
4ddfa79ecd
commit
f2d71fc405
@ -23,8 +23,8 @@
|
|||||||
from openerp import models, fields
|
from openerp import models, fields
|
||||||
|
|
||||||
|
|
||||||
class IrAttachment(models.Model):
|
class IrAttachmentMetadata(models.Model):
|
||||||
_inherit = 'ir.attachment'
|
_inherit = 'ir.attachment.metadata'
|
||||||
|
|
||||||
sync_date = fields.Datetime()
|
sync_date = fields.Datetime()
|
||||||
state = fields.Selection([
|
state = fields.Selection([
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
<data>
|
<data>
|
||||||
|
|
||||||
<record id="view_attachment_improved_form" model="ir.ui.view">
|
<record id="view_attachment_improved_form" model="ir.ui.view">
|
||||||
<field name="model">ir.attachment</field>
|
<field name="model">ir.attachment.metadata</field>
|
||||||
<field name="inherit_id" ref="base.view_attachment_form" />
|
<field name="inherit_id" ref="ir_attachment_metadata.view_attachment_improved_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="url" position="after">
|
<field name="url" position="after">
|
||||||
<field name="sync_date"/>
|
<field name="sync_date"/>
|
||||||
@ -17,7 +17,7 @@
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="view_external_attachment_tree" model="ir.ui.view">
|
<record id="view_external_attachment_tree" model="ir.ui.view">
|
||||||
<field name="model">ir.attachment</field>
|
<field name="model">ir.attachment.metadata</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Attachments" >
|
<tree string="Attachments" >
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
@ -32,7 +32,7 @@
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="view_external_attachment_search" model="ir.ui.view">
|
<record id="view_external_attachment_search" model="ir.ui.view">
|
||||||
<field name="model">ir.attachment</field>
|
<field name="model">ir.attachment.metadata</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<search string="Attachments">
|
<search string="Attachments">
|
||||||
<field name="name" filter_domain="['|', ('name','ilike',self), ('datas_fname','ilike',self)]" string="Attachment"/>
|
<field name="name" filter_domain="['|', ('name','ilike',self), ('datas_fname','ilike',self)]" string="Attachment"/>
|
||||||
@ -68,7 +68,7 @@
|
|||||||
<record id="action_attachment" model="ir.actions.act_window">
|
<record id="action_attachment" model="ir.actions.act_window">
|
||||||
<field name="name">Attachments</field>
|
<field name="name">Attachments</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">ir.attachment</field>
|
<field name="res_model">ir.attachment.metadata</field>
|
||||||
<field name="view_type">form</field>
|
<field name="view_type">form</field>
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="view_id" eval="False"/>
|
<field name="view_id" eval="False"/>
|
||||||
@ -83,6 +83,13 @@
|
|||||||
<field name="act_window_id" ref="action_attachment"/>
|
<field name="act_window_id" ref="action_attachment"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="ir_attachment_view3" model="ir.actions.act_window.view">
|
||||||
|
<field eval="10" name="sequence"/>
|
||||||
|
<field name="view_mode">form</field>
|
||||||
|
<field name="view_id" ref="view_attachment_improved_form"/>
|
||||||
|
<field name="act_window_id" ref="action_attachment"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
<menuitem id="menu_ir_attachment"
|
<menuitem id="menu_ir_attachment"
|
||||||
parent="menu_file_exchange"
|
parent="menu_file_exchange"
|
||||||
sequence="20"
|
sequence="20"
|
||||||
|
@ -37,7 +37,7 @@ class Task(models.Model):
|
|||||||
filepath = fields.Char(help='Path to imported file')
|
filepath = fields.Char(help='Path to imported file')
|
||||||
location_id = fields.Many2one('external.file.location', string='Location',
|
location_id = fields.Many2one('external.file.location', string='Location',
|
||||||
required=True)
|
required=True)
|
||||||
attachment_ids = fields.One2many('ir.attachment', 'task_id',
|
attachment_ids = fields.One2many('ir.attachment.metadata', 'task_id',
|
||||||
string='Attachment')
|
string='Attachment')
|
||||||
move_path = fields.Char(string='Move path',
|
move_path = fields.Char(string='Move path',
|
||||||
help='Imported File will be moved to this path')
|
help='Imported File will be moved to this path')
|
||||||
|
@ -28,11 +28,14 @@ import hashlib
|
|||||||
from base64 import b64decode
|
from base64 import b64decode
|
||||||
|
|
||||||
|
|
||||||
class IrAttachment(models.Model):
|
class IrAttachmentMetadata(models.Model):
|
||||||
_inherit = 'ir.attachment'
|
_name = 'ir.attachment.metadata'
|
||||||
|
_inherits = {'ir.attachment': 'attachment_id'}
|
||||||
|
|
||||||
internal_hash = fields.Char(store=True, compute='_compute_hash')
|
internal_hash = fields.Char(store=True, compute='_compute_hash')
|
||||||
external_hash = fields.Char()
|
external_hash = fields.Char()
|
||||||
|
attachment_id = fields.Many2one('ir.attachment', required=True,
|
||||||
|
ondelete='cascade')
|
||||||
|
|
||||||
@api.depends('datas', 'external_hash')
|
@api.depends('datas', 'external_hash')
|
||||||
def _compute_hash(self):
|
def _compute_hash(self):
|
||||||
|
@ -3,14 +3,13 @@
|
|||||||
<data>
|
<data>
|
||||||
|
|
||||||
<record id="view_attachment_improved_form" model="ir.ui.view">
|
<record id="view_attachment_improved_form" model="ir.ui.view">
|
||||||
<field name="model">ir.attachment</field>
|
<field name="model">ir.attachment.metadata</field>
|
||||||
<field name="inherit_id" ref="base.view_attachment_form" />
|
<field name="inherit_id" ref="base.view_attachment_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="url" position="after">
|
<field name="url" position="after">
|
||||||
<field name="internal_hash"/>
|
<field name="internal_hash"/>
|
||||||
<field name="external_hash"/>
|
<field name="external_hash"/>
|
||||||
</field>
|
</field>
|
||||||
|
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user