Sylvain LE GAL
10 years ago
5 changed files with 178 additions and 0 deletions
-
24document_extract_from_database/__init__.py
-
53document_extract_from_database/__openerp__.py
-
59document_extract_from_database/attachment.py
-
42document_extract_from_database/document_view.xml
-
BINdocument_extract_from_database/static/src/img/icon.png
@ -0,0 +1,24 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################# |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# Copyright (C) 2012 Julius Network Solutions SARL <contact@julius.fr> |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU General Public License as published by |
|||
# the Free Software Foundation, either version 3 of the License, or |
|||
# (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################# |
|||
|
|||
import attachment |
|||
|
|||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
@ -0,0 +1,53 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################# |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# Copyright (C) 2012 Julius Network Solutions SARL <contact@julius.fr> |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU General Public License as published by |
|||
# the Free Software Foundation, either version 3 of the License, or |
|||
# (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################# |
|||
|
|||
{ |
|||
"name": "Extract Documents from database", |
|||
"summary": "Extract documents from database to the defined filestore", |
|||
"version": "1.0", |
|||
"author": "Julius Network Solutions", |
|||
"website": "http://julius.fr", |
|||
"category": "Tools", |
|||
"depends": [ |
|||
"document", |
|||
], |
|||
"description": """ |
|||
Button to extract documents from your database |
|||
============================================== |
|||
If you want to extract the document stored in your database this module is for you. |
|||
|
|||
Make sure you've correctly defined the filestore in your database: |
|||
"Settings > Parameters > System Parameters", add for example: |
|||
* "key": "ir_attachment.location" |
|||
* "value": "file:///filestore" |
|||
|
|||
Then go to your document list, select all the documents you want to extract. |
|||
Then, "More > Document Extraction" |
|||
""", |
|||
"demo" : [], |
|||
"data" : [ |
|||
'document_view.xml' |
|||
], |
|||
'installable' : True, |
|||
'active' : False, |
|||
} |
|||
|
|||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
@ -0,0 +1,59 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################### |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# Copyright (C) 2012 Julius Network Solutions SARL <contact@julius.fr> |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU General Public License as published by |
|||
# the Free Software Foundation, either version 3 of the License, or |
|||
# (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################### |
|||
|
|||
from openerp.osv import orm, fields |
|||
import base64 |
|||
|
|||
class document_multiple_action(orm.TransientModel): |
|||
_name = "document.multiple.action" |
|||
_description = "Multiple action on document" |
|||
|
|||
def write_again(self, cr, uid, ids, context=None): |
|||
if context is None: context = {} |
|||
document_obj = self.pool.get('ir.attachment') |
|||
document_ids = context.get('active_ids') |
|||
if document_ids: |
|||
document_obj.write_again(cr, uid, document_ids, context=context) |
|||
return True |
|||
|
|||
class document_file(orm.Model): |
|||
_inherit = 'ir.attachment' |
|||
|
|||
def _write_again(self, cr, uid, id, context=None): |
|||
current_data = self.browse(cr, uid, id, context=context) |
|||
location = self.pool.get('ir.config_parameter').\ |
|||
get_param(cr, uid, 'ir_attachment.location') |
|||
if current_data.db_datas and location: |
|||
vals = { |
|||
'datas': base64.encodestring(current_data.db_datas), |
|||
'db_datas': False, |
|||
} |
|||
self.write(cr, uid, id, vals, context=context) |
|||
return True |
|||
|
|||
def write_again(self, cr, uid, ids, context=None): |
|||
if context==None: |
|||
context = {} |
|||
for document_id in ids: |
|||
self._write_again(cr, uid, document_id, context=context) |
|||
return True |
|||
|
|||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
@ -0,0 +1,42 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
<record id="view_document_multiple_action_form" model="ir.ui.view"> |
|||
<field name="name">Document multiple action</field> |
|||
<field name="model">document.multiple.action</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Document Extraction" version="7.0"> |
|||
<div> |
|||
<p> |
|||
<label string="If you click on 'Write again', the selected document which are stored in the database will be extracted into the filestore location."/> |
|||
</p> |
|||
</div> |
|||
<footer> |
|||
<button name="write_again" string="Extract documents" class="oe_highlight" type="object"/> or |
|||
<button string="Cancel" class="oe_link" special="cancel"/> |
|||
</footer> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
<record id="action_view_document_multiple_action_form" model="ir.actions.act_window"> |
|||
<field name="name">Document Extraction</field> |
|||
<field name="res_model">document.multiple.action</field> |
|||
<field name="type">ir.actions.act_window</field> |
|||
<field name="view_type">form</field> |
|||
<field name="view_mode">form</field> |
|||
<field name="view_id" ref="view_document_multiple_action_form"/> |
|||
<field name="target">new</field> |
|||
<field name="multi">True</field> |
|||
</record> |
|||
<record model="ir.values" id="document_multiple_action"> |
|||
<field name="model_id" ref="base.model_ir_attachment" /> |
|||
<field name="name">Document Extraction</field> |
|||
<field name="key2">client_action_multi</field> |
|||
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_view_document_multiple_action_form'))" /> |
|||
<field name="key">action</field> |
|||
<field name="model">ir.attachment</field> |
|||
</record> |
|||
|
|||
</data> |
|||
</openerp> |
After Width: 169 | Height: 169 | Size: 12 KiB |
Write
Preview
Loading…
Cancel
Save
Reference in new issue