mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-14 09:51:27 -06:00
Merge pull request #13 from pedrobaeza/8.0-copy_from_7.0
[MIG] Translated changes from 7.0 branch
This commit is contained in:
commit
8e221e3a61
25
__unported__/document_multiple_records/__init__.py
Normal file
25
__unported__/document_multiple_records/__init__.py
Normal file
@ -0,0 +1,25 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# This module copyright (C) 2014 Savoir-faire Linux
|
||||
# (<http://www.savoirfairelinux.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
from . import document
|
||||
from . import wizard
|
||||
|
59
__unported__/document_multiple_records/__openerp__.py
Normal file
59
__unported__/document_multiple_records/__openerp__.py
Normal file
@ -0,0 +1,59 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# This module copyright (C) 2014 Savoir-faire Linux
|
||||
# (<http://www.savoirfairelinux.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
{
|
||||
'name': 'Document Management System for Multiple Records',
|
||||
'version': '0.1',
|
||||
'category': 'Knowledge Management',
|
||||
'summary': 'Document Management System for Multiple Records',
|
||||
'description': """
|
||||
Document Management System for Multiple Records
|
||||
==============================================
|
||||
|
||||
Contributors
|
||||
------------
|
||||
* El Hadji Dem (elhadji.dem@savoirfairelinux.com)
|
||||
""",
|
||||
'author': 'Savoir-faire Linux',
|
||||
'website': 'www.savoirfairelinux.com',
|
||||
'license': 'AGPL-3',
|
||||
'depends': [
|
||||
'document',
|
||||
],
|
||||
'data': [
|
||||
'document_view.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/document_wizard_view.xml',
|
||||
],
|
||||
'js': [
|
||||
'static/src/js/document.js'
|
||||
],
|
||||
'qweb': [
|
||||
'static/src/xml/document.xml'
|
||||
],
|
||||
'test': [],
|
||||
'demo': [
|
||||
],
|
||||
'installable': False,
|
||||
'auto_install': False,
|
||||
}
|
||||
|
90
__unported__/document_multiple_records/document.py
Normal file
90
__unported__/document_multiple_records/document.py
Normal file
@ -0,0 +1,90 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# This module copyright (C) 2014 Savoir-faire Linux
|
||||
# (<http://www.savoirfairelinux.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm, fields
|
||||
|
||||
|
||||
class document_file(orm.Model):
|
||||
_inherit = 'ir.attachment'
|
||||
|
||||
_columns = {
|
||||
'attachment_document_ids': fields.one2many('ir.attachment.document',
|
||||
'attachment_id',
|
||||
'Records'),
|
||||
}
|
||||
|
||||
def create(self, cr, uid, data, context=None):
|
||||
ir_attachment_document_obj = self.pool.get('ir.attachment.document')
|
||||
res = super(document_file, self).create(cr, uid, data, context=context)
|
||||
# Create attachment_document_ids with res_model, res_id and res_name
|
||||
if 'res_model' in data and 'res_id' in data:
|
||||
ir_attachment_document_obj.create(cr, uid, {
|
||||
'attachment_id': res,
|
||||
'res_model': data['res_model'],
|
||||
'res_id': data['res_id'],
|
||||
'res_name': data.get(
|
||||
'res_name', self.pool.get(data['res_model']).browse(
|
||||
cr, uid, data['res_id'],
|
||||
context=context).name_get()[0][1]),
|
||||
}, context=context)
|
||||
return res
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None, check=True):
|
||||
ir_attach_doc_obj = self.pool.get('ir.attachment.document')
|
||||
if context is None:
|
||||
context = {}
|
||||
# Deleting from dropdown list in the form view
|
||||
res_model = context.get('multiple_records_res_model')
|
||||
res_id = context.get('multiple_records_res_id')
|
||||
if res_model and res_id:
|
||||
query = [
|
||||
('res_model', '=', res_model),
|
||||
('res_id', '=', res_id),
|
||||
('attachment_id', 'in', ids),
|
||||
]
|
||||
ids_to_unlink = ir_attach_doc_obj.search(
|
||||
cr, uid, query, context=context)
|
||||
result = ir_attach_doc_obj.unlink(
|
||||
cr, uid, ids_to_unlink, context=context)
|
||||
else:
|
||||
# Normal delete
|
||||
result = super(document_file, self).unlink(
|
||||
cr, uid, ids, context=context)
|
||||
return result
|
||||
|
||||
|
||||
class ir_attachment_document(orm.Model):
|
||||
_description = 'Attachment Documents'
|
||||
_name = 'ir.attachment.document'
|
||||
|
||||
_columns = {
|
||||
'res_id': fields.integer('Resource ID', readonly=True,
|
||||
help="The record id this is attached to."),
|
||||
'res_model': fields.char(
|
||||
'Resource Model', size=64, readonly=True,
|
||||
help="The database object this attachment will be attached to"),
|
||||
'res_name': fields.char('Resource Name', type='char',
|
||||
size=128,
|
||||
readonly=True),
|
||||
'attachment_id': fields.many2one(
|
||||
'ir.attachment', 'Attachment', ondelete='cascade'),
|
||||
}
|
30
__unported__/document_multiple_records/document_view.xml
Normal file
30
__unported__/document_multiple_records/document_view.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!--Add model list field-->
|
||||
<record model="ir.ui.view" id="view_document_file_multiple_models_form">
|
||||
<field name="name">ir.attachment.multiple.models</field>
|
||||
<field name="model">ir.attachment</field>
|
||||
<field name="inherit_id" ref="document.view_document_file_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<group string="Indexed Content" position="after">
|
||||
<group col="2" colspan="4">
|
||||
<field name="attachment_document_ids" nolabel="1">
|
||||
<tree string="AttachmentDocumentTree" create="false" version="7.0">
|
||||
<field name="res_model"/>
|
||||
<field name="res_id"/>
|
||||
<field name="res_name"/>
|
||||
</tree>
|
||||
<form string="AttachmentDocumentForm">
|
||||
<field name="res_model"/>
|
||||
<field name="res_id"/>
|
||||
<field name="res_name"/>
|
||||
</form>
|
||||
</field>
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
@ -0,0 +1,140 @@
|
||||
# Translation of OpenERP Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * document_multiple_records
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: OpenERP Server 7.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-02-06 19:28+0000\n"
|
||||
"PO-Revision-Date: 2014-02-06 14:29-0500\n"
|
||||
"Last-Translator: EL Hadji DEM <elhadji.dem@savoirfairelinux.com>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: \n"
|
||||
"X-Generator: Poedit 1.5.4\n"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: field:ir.attachment.document,res_id:0
|
||||
msgid "Resource ID"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: view:ir.attachment.wizard:0
|
||||
msgid "Select document(s)"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#. openerp-web
|
||||
#: code:addons/document_multiple_records/static/src/xml/document.xml:7
|
||||
#, python-format
|
||||
msgid "Add existing Doc..."
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: field:ir.attachment.document,attachment_id:0
|
||||
msgid "Attachment"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: view:ir.attachment.wizard:0
|
||||
msgid "AttachmentDocumentWizardTree"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#. openerp-web
|
||||
#: code:addons/document_multiple_records/static/src/js/document.js:26
|
||||
#: model:ir.actions.act_window,name:document_multiple_records.action_view_document
|
||||
#: view:ir.attachment.wizard:0
|
||||
#, python-format
|
||||
msgid "Add Document"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: field:ir.attachment.document,res_name:0
|
||||
msgid "Resource Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: model:ir.model,name:document_multiple_records.model_ir_attachment_document
|
||||
msgid "Attachment Documents"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: field:ir.attachment,attachmentdocument_ids:0
|
||||
msgid "Records"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: view:ir.attachment:0
|
||||
msgid "AttachmentDocumentTree"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: model:ir.model,name:document_multiple_records.model_ir_attachment
|
||||
msgid "ir.attachment"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: view:ir.attachment:0
|
||||
msgid "Indexed Content"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: model:ir.model,name:document_multiple_records.model_ir_attachment_wizard
|
||||
msgid "Attachment wizard"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: view:ir.attachment:0
|
||||
msgid "AttachmentDocumentForm"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: code:addons/document_multiple_records/wizard/document_wizard.py:46
|
||||
#, python-format
|
||||
msgid "Error"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: help:ir.attachment.document,res_model:0
|
||||
msgid "The database object this attachment will be attached to"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: help:ir.attachment.document,res_id:0
|
||||
msgid "The record id this is attached to."
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: field:ir.attachment.wizard,attachment_ids:0
|
||||
msgid "Attachments"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: field:ir.attachment.document,res_model:0
|
||||
msgid "Resource Model"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: view:ir.attachment.wizard:0
|
||||
msgid "Cancel"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: view:ir.attachment.wizard:0
|
||||
msgid "Apply"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: view:ir.attachment.wizard:0
|
||||
msgid "or"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: code:addons/document_multiple_records/wizard/document_wizard.py:47
|
||||
#, python-format
|
||||
msgid "You have to select at least 1 Document. And try again"
|
||||
msgstr ""
|
151
__unported__/document_multiple_records/i18n/fr.po
Normal file
151
__unported__/document_multiple_records/i18n/fr.po
Normal file
@ -0,0 +1,151 @@
|
||||
# Translation of OpenERP Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * document_multiple_records
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: OpenERP Server 7.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-03-25 18:24+0000\n"
|
||||
"PO-Revision-Date: 2014-03-25 14:27-0500\n"
|
||||
"Last-Translator: Marc Cassuto <marc.cassuto@savoirfairelinux.com>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: \n"
|
||||
"X-Generator: Poedit 1.5.4\n"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: field:ir.attachment.document,res_id:0
|
||||
msgid "Resource ID"
|
||||
msgstr "Identifiant de la ressource"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: view:ir.attachment.existing.doc:0
|
||||
msgid "Select document(s)"
|
||||
msgstr "Choisir un(des) document(s)"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: field:ir.attachment.document,attachment_id:0
|
||||
msgid "Attachment"
|
||||
msgstr "Document joint"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: view:ir.attachment.existing.doc:0
|
||||
msgid "AttachmentDocumentWizardTree"
|
||||
msgstr "AttachmentDocumentWizardTree"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#. openerp-web
|
||||
#: code:addons/document_multiple_records/static/src/js/document.js:42
|
||||
#, python-format
|
||||
msgid "Uploading Error"
|
||||
msgstr "Erreur lors du transfert"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: field:ir.attachment.document,res_name:0
|
||||
msgid "Resource Name"
|
||||
msgstr "Nom de la ressource"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: model:ir.model,name:document_multiple_records.model_ir_attachment_document
|
||||
msgid "Attachment Documents"
|
||||
msgstr "Documents joints"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: field:ir.attachment,attachment_document_ids:0
|
||||
msgid "Records"
|
||||
msgstr "Enregistrements"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: view:ir.attachment:0
|
||||
msgid "AttachmentDocumentTree"
|
||||
msgstr "AttachmentDocumentTree"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: model:ir.model,name:document_multiple_records.model_ir_attachment
|
||||
msgid "ir.attachment"
|
||||
msgstr "ir.attachment"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: view:ir.attachment:0
|
||||
msgid "Indexed Content"
|
||||
msgstr "Contenu indexé"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: view:ir.attachment:0
|
||||
msgid "AttachmentDocumentForm"
|
||||
msgstr "AttachmentDocumentForm"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: code:addons/document_multiple_records/wizard/document_wizard.py:48
|
||||
#, python-format
|
||||
msgid "Error"
|
||||
msgstr "Erreur"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: help:ir.attachment.document,res_model:0
|
||||
msgid "The database object this attachment will be attached to"
|
||||
msgstr "L'objet de la base de données auquel ce document sera attaché"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: help:ir.attachment.document,res_id:0
|
||||
msgid "The record id this is attached to."
|
||||
msgstr "L'identifiant de l'enregistrement auquel est ce document est joint."
|
||||
|
||||
#. module: document_multiple_records
|
||||
#. openerp-web
|
||||
#: code:addons/document_multiple_records/static/src/js/document.js:25
|
||||
#: model:ir.actions.act_window,name:document_multiple_records.action_view_document
|
||||
#: view:ir.attachment.existing.doc:0
|
||||
#, python-format
|
||||
msgid "Add existing document/attachment"
|
||||
msgstr "Ajouter un document déjà joint dans le système"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: model:ir.model,name:document_multiple_records.model_ir_attachment_existing_doc
|
||||
msgid "Add existing document/attachment wizard"
|
||||
msgstr "Assistant pour ajouter un document déjà joint dans le système"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: field:ir.attachment.existing.doc,attachment_ids:0
|
||||
msgid "Attachments"
|
||||
msgstr "Documents joints"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#. openerp-web
|
||||
#: code:addons/document_multiple_records/static/src/xml/document.xml:7
|
||||
#, python-format
|
||||
msgid "Add existing document/attachment..."
|
||||
msgstr "Ajouter un document déjà joint dans le système..."
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: field:ir.attachment.document,res_model:0
|
||||
msgid "Resource Model"
|
||||
msgstr "Modèle"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: view:ir.attachment.existing.doc:0
|
||||
msgid "Cancel"
|
||||
msgstr "Annuler"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: view:ir.attachment.existing.doc:0
|
||||
msgid "Apply"
|
||||
msgstr "Appliquer"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: view:ir.attachment.existing.doc:0
|
||||
msgid "or"
|
||||
msgstr "ou"
|
||||
|
||||
#. module: document_multiple_records
|
||||
#: code:addons/document_multiple_records/wizard/document_wizard.py:49
|
||||
#, python-format
|
||||
msgid "You have to select at least 1 Document. And try again"
|
||||
msgstr "Vous devez sélectionner au moins un document et essayer de nouveau."
|
||||
|
||||
#~ msgid "Add Document"
|
||||
#~ msgstr "Ajouter un document"
|
@ -0,0 +1,3 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_ir_attachment_document_group_user,ir.attachment.document user,model_ir_attachment_document,base.group_document_user,1,1,1,1
|
||||
access_ir_attachment_existing_doc,access_ir_attachment_existing_doc,model_ir_attachment_existing_doc,base.group_document_user,1,1,1,1
|
|
@ -0,0 +1,79 @@
|
||||
openerp.document_multiple_records = function(instance, m) {
|
||||
var _t = instance.web._t,
|
||||
QWeb = instance.web.qweb;
|
||||
|
||||
instance.web.Sidebar.include({
|
||||
redraw: function() {
|
||||
var self = this;
|
||||
this._super.apply(this, arguments);
|
||||
self.$el.find('.oe_sidebar_add_attachment').after(QWeb.render('AddDocfromserver', {widget: self}))
|
||||
self.$el.find('.open').on('click', function (e) {
|
||||
self.on_call_new_view_function();
|
||||
});
|
||||
},
|
||||
on_call_new_view_function: function(state) {
|
||||
var self = this;
|
||||
var view = self.getParent();
|
||||
var ids = ( view.fields_view.type != "form" )? view.groups.get_selection().ids : [ view.datarecord.id ];
|
||||
// you can pass in other data using the context dictionary variable
|
||||
var context = {
|
||||
'model': view.dataset.model,
|
||||
'ids': ids,
|
||||
};
|
||||
// the action dictionary variable sends data in the "self.do_action" method
|
||||
var action = {
|
||||
name: _t("Add existing document"),
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: 'ir.attachment.existing.doc',
|
||||
view_mode: 'form',
|
||||
view_type: 'form',
|
||||
views: [[false, 'form']],
|
||||
target: 'new',
|
||||
context: context,
|
||||
};
|
||||
// self.do_action accepts the action parameter and opens the new view
|
||||
self.do_action(action, {
|
||||
// refresh list of documents
|
||||
on_close: function () {
|
||||
self.do_attachement_update(self.dataset, self.model_id);
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
on_attachment_delete: function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
var self = this;
|
||||
var view = self.getParent();
|
||||
self.model_view = view.dataset.model
|
||||
var ids = ( view.fields_view.type != "form" )? view.groups.get_selection().ids : [ view.datarecord.id ];
|
||||
// Context dictionary variable
|
||||
var context = {
|
||||
'multiple_records_res_model': self.model_view,
|
||||
'multiple_records_res_id': ids[0],
|
||||
};
|
||||
var $e = $(e.currentTarget);
|
||||
if (confirm(_t("Do you really want to delete this attachment ?"))) {
|
||||
(new instance.web.DataSet(this, 'ir.attachment', context)).unlink([parseInt($e.attr('data-id'), 10)]).done(function() {
|
||||
self.do_attachement_update(self.dataset, self.model_id);
|
||||
});
|
||||
}
|
||||
},
|
||||
do_attachement_update: function(dataset, model_id, args) {
|
||||
var self = this;
|
||||
this.dataset = dataset;
|
||||
this.model_id = model_id;
|
||||
if (args && args[0].error) {
|
||||
this.do_warn(_t('Uploading Error'), args[0].error);
|
||||
}
|
||||
if (!model_id) {
|
||||
this.on_attachments_loaded([]);
|
||||
}
|
||||
else {
|
||||
var dom = [ ['attachment_document_ids.res_model', '=', dataset.model], ['attachment_document_ids.res_id', '=', model_id], ['type', 'in', ['binary', 'url']] ];
|
||||
var ds = new instance.web.DataSetSearch(this, 'ir.attachment', dataset.get_context(), dom);
|
||||
ds.read_slice(['name', 'url', 'type', 'create_uid', 'create_date', 'write_uid', 'write_date'], {}).done(this.on_attachments_loaded);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- vim:fdl=1:
|
||||
-->
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-name="AddDocfromserver">
|
||||
<li class="open"><span><b>Add existing document...</b></span></li>
|
||||
</t>
|
||||
|
||||
</templates>
|
24
__unported__/document_multiple_records/wizard/__init__.py
Normal file
24
__unported__/document_multiple_records/wizard/__init__.py
Normal file
@ -0,0 +1,24 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# This module copyright (C) 2014 Savoir-faire Linux
|
||||
# (<http://www.savoirfairelinux.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from . import document_wizard
|
||||
|
@ -0,0 +1,66 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# This module copyright (C) 2014 Savoir-faire Linux
|
||||
# (<http://www.savoirfairelinux.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import fields, orm
|
||||
from openerp.tools.translate import _
|
||||
|
||||
|
||||
class document_wizard(orm.Model):
|
||||
_name = "ir.attachment.existing.doc"
|
||||
_description = "Add existing document/attachment wizard"
|
||||
_columns = {
|
||||
'attachment_ids': fields.many2many('ir.attachment',
|
||||
'document_attachment_rel',
|
||||
'wizard_id',
|
||||
'attachment_id',
|
||||
'Attachments'),
|
||||
}
|
||||
|
||||
def action_apply(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
ir_attach_obj = self.pool.get('ir.attachment')
|
||||
ir_attach_doc_obj = self.pool.get('ir.attachment.document')
|
||||
ir_model_obj = self.pool.get(
|
||||
context.get('model') or context.get('active_model'))
|
||||
|
||||
name = ir_model_obj.browse(
|
||||
cr, uid, context.get('ids') or context.get('active_ids'),
|
||||
context=context)[0]['name']
|
||||
data = self.read(cr, uid, ids, [], context=context)[0]
|
||||
if not data['attachment_ids']:
|
||||
raise orm.except_orm(
|
||||
_('Error'),
|
||||
_('You have to select at least 1 Document. And try again'))
|
||||
for attach in ir_attach_obj.browse(cr, uid, data['attachment_ids'],
|
||||
context=context):
|
||||
data_attach = {
|
||||
'res_model': context.get('model') or
|
||||
context.get('active_model'),
|
||||
'res_id': context.get('ids') and context.get('ids')[0] or
|
||||
context.get('active_id'),
|
||||
'res_name': name,
|
||||
'attachment_id': attach.id,
|
||||
}
|
||||
# Created attachment_document_ids
|
||||
ir_attach_doc_obj.create(cr, uid, data_attach, context=context)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="document_form_view" model="ir.ui.view">
|
||||
<field name="name">Add existing document/attachment</field>
|
||||
<field name="model">ir.attachment.existing.doc</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Add existing document/attachment" version="7.0">
|
||||
<group string="Select document(s)" colspan="4">
|
||||
<field name="attachment_ids" nolabel="1">
|
||||
<tree string="AttachmentDocumentWizardTree">
|
||||
<field name="name"/>
|
||||
<field name="create_uid"/>
|
||||
<field name="create_date"/>
|
||||
<field name="type"/>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
<footer>
|
||||
<button string="Apply" name="action_apply" type="object" class="oe_highlight"/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Actions -->
|
||||
<record model="ir.actions.act_window" id="action_view_document">
|
||||
<field name="name">Add existing document/attachment</field>
|
||||
<field name="res_model">ir.attachment.existing.doc</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="document_form_view"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
@ -27,16 +27,18 @@
|
||||
"license": "AGPL-3",
|
||||
'category': 'Knowledge Management',
|
||||
'description': """
|
||||
This module adds a workflow to approve page modification and show the approved version by default.
|
||||
This module adds a workflow to approve page modification and show the approved
|
||||
version by default.
|
||||
|
||||
Scenario
|
||||
========
|
||||
|
||||
* Set a valid email address on the company settings.
|
||||
* Create a new page category and set an approver group. Make sure users belonging to that group
|
||||
have valid email addresses.
|
||||
* Create a new page category and set an approver group. Make sure users
|
||||
belonging to that group have valid email addresses.
|
||||
* Create a new page and choose the previously created category.
|
||||
* A notification is sent to the group with a link to the page history to review.
|
||||
* A notification is sent to the group with a link to the page history to
|
||||
review.
|
||||
* Depending on the review, the page history is approved or not.
|
||||
* Users reading the page see the last approved version.
|
||||
""",
|
||||
@ -52,5 +54,9 @@ Scenario
|
||||
],
|
||||
'installable': False,
|
||||
'auto_install': False,
|
||||
'images': ['images/category.png', 'images/page_history_list.png', 'images/page_history.png'],
|
||||
'images': [
|
||||
'images/category.png',
|
||||
'images/page_history_list.png',
|
||||
'images/page_history.png',
|
||||
],
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ class document_page_history_wkfl(orm.Model):
|
||||
|
||||
template_id = self.pool.get('ir.model.data').get_object_reference(
|
||||
cr, uid,
|
||||
'document_page_approval', 'email_template_new_draft_need_approval')[1]
|
||||
'document_page_approval',
|
||||
'email_template_new_draft_need_approval')[1]
|
||||
for page in self.browse(cr, uid, ids, context=context):
|
||||
if page.is_parent_approval_required:
|
||||
self.pool.get('email.template').send_mail(
|
||||
@ -44,7 +45,8 @@ class document_page_history_wkfl(orm.Model):
|
||||
def page_approval_approved(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids, {
|
||||
'state': 'approved',
|
||||
'approved_date': datetime.now().strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
'approved_date': datetime.now().strftime(
|
||||
DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
'approved_uid': uid
|
||||
}, context=context)
|
||||
return True
|
||||
@ -89,9 +91,12 @@ class document_page_history_wkfl(orm.Model):
|
||||
res = {}
|
||||
for id in ids:
|
||||
emails = ''
|
||||
guids = self.get_approvers_guids(cr, uid, ids, name, args, context=context)
|
||||
uids = self.pool.get('res.users').search(cr, uid, [('groups_id', 'in', guids[id])])
|
||||
users = self.pool.get('res.users').browse(cr, uid, uids, context=context)
|
||||
guids = self.get_approvers_guids(
|
||||
cr, uid, ids, name, args, context=context)
|
||||
uids = self.pool.get('res.users').search(
|
||||
cr, uid, [('groups_id', 'in', guids[id])])
|
||||
users = self.pool.get('res.users').browse(
|
||||
cr, uid, uids, context=context)
|
||||
|
||||
for user in users:
|
||||
if user.email:
|
||||
@ -100,7 +105,8 @@ class document_page_history_wkfl(orm.Model):
|
||||
else:
|
||||
empl_id = self.pool.get('hr.employee').search(
|
||||
cr, uid, [('login', '=', user.login)])[0]
|
||||
empl = self.pool.get('hr.employee').browse(cr, uid, empl_id, context=context)
|
||||
empl = self.pool.get('hr.employee').browse(
|
||||
cr, uid, empl_id, context=context)
|
||||
if empl.work_email:
|
||||
emails += empl.work_email
|
||||
emails += ','
|
||||
@ -113,9 +119,12 @@ class document_page_history_wkfl(orm.Model):
|
||||
res = {}
|
||||
for id in ids:
|
||||
base_url = self.pool.get('ir.config_parameter').get_param(
|
||||
cr, uid, 'web.base.url', default='http://localhost:8069', context=context)
|
||||
cr, uid, 'web.base.url', default='http://localhost:8069',
|
||||
context=context)
|
||||
|
||||
res[id] = base_url + '/#db=%s&id=%s&view_type=form&model=document.page.history' % (cr.dbname, id)
|
||||
res[id] = base_url + (
|
||||
'/#db=%s&id=%s&view_type=form&model=document.page.history' %
|
||||
(cr.dbname, id))
|
||||
|
||||
return res
|
||||
|
||||
@ -129,10 +138,13 @@ class document_page_history_wkfl(orm.Model):
|
||||
'page_id', 'is_parent_approval_required',
|
||||
string="parent approval", type='boolean', store=False),
|
||||
'can_user_approve_page': fields.function(
|
||||
can_user_approve_page, string="can user approve this page", type='boolean', store=False),
|
||||
can_user_approve_page, string="can user approve this page",
|
||||
type='boolean', store=False),
|
||||
'get_approvers_email': fields.function(
|
||||
get_approvers_email, string="get all approvers email", type='text', store=False),
|
||||
'get_page_url': fields.function(get_page_url, string="URL", type='text', store=False),
|
||||
get_approvers_email, string="get all approvers email",
|
||||
type='text', store=False),
|
||||
'get_page_url': fields.function(get_page_url, string="URL",
|
||||
type='text', store=False),
|
||||
}
|
||||
|
||||
|
||||
@ -153,7 +165,8 @@ class document_page_approval(orm.Model):
|
||||
('page_id', '=', page.id),
|
||||
('state', '=', 'approved')
|
||||
], limit=1, order='create_date DESC')
|
||||
for h in history.browse(cr, uid, history_ids, context=context):
|
||||
for h in history.browse(cr, uid, history_ids,
|
||||
context=context):
|
||||
content = h.content
|
||||
else:
|
||||
content = page.content
|
||||
@ -186,7 +199,8 @@ class document_page_approval(orm.Model):
|
||||
history = self.pool.get('document.page.history')
|
||||
history_ids = history.search(cr, uid, [
|
||||
('page_id', '=', page.id),
|
||||
('state', '=', 'approved')], limit=1, order='create_date DESC')
|
||||
('state', '=', 'approved')], limit=1,
|
||||
order='create_date DESC')
|
||||
approved_uid = False
|
||||
for h in history.browse(cr, uid, history_ids):
|
||||
approved_uid = h.approved_uid.id
|
||||
@ -196,7 +210,8 @@ class document_page_approval(orm.Model):
|
||||
|
||||
return res
|
||||
|
||||
def _is_parent_approval_required(self, cr, uid, ids, name, args, context=None):
|
||||
def _is_parent_approval_required(self, cr, uid, ids, name, args,
|
||||
context=None):
|
||||
res = {}
|
||||
for page in self.browse(cr, uid, ids, context=context):
|
||||
res[page.id] = self.is_approval_required(page)
|
||||
@ -213,11 +228,16 @@ class document_page_approval(orm.Model):
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'display_content': fields.function(_get_display_content, string='Displayed Content', type='text'),
|
||||
'approved_date': fields.function(_get_approved_date, string="Approved Date", type='datetime'),
|
||||
'approved_uid': fields.function(_get_approved_uid, string="Approved By", type='many2one', obj='res.users'),
|
||||
'display_content': fields.function(
|
||||
_get_display_content, string='Displayed Content', type='text'),
|
||||
'approved_date': fields.function(
|
||||
_get_approved_date, string="Approved Date", type='datetime'),
|
||||
'approved_uid': fields.function(
|
||||
_get_approved_uid, string="Approved By", type='many2one',
|
||||
obj='res.users'),
|
||||
'approval_required': fields.boolean("Require approval"),
|
||||
'is_parent_approval_required': fields.function(
|
||||
_is_parent_approval_required, string="parent approval", type='boolean'),
|
||||
_is_parent_approval_required, string="parent approval",
|
||||
type='boolean'),
|
||||
'approver_gid': fields.many2one("res.groups", "Approver group"),
|
||||
}
|
||||
|
@ -21,4 +21,3 @@
|
||||
|
||||
from . import document_page_multi_company
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
@ -40,3 +40,4 @@ This module adds a company field to document page and the multi-company rule.
|
||||
'auto_install': False,
|
||||
'images': [],
|
||||
}
|
||||
|
||||
|
@ -45,4 +45,3 @@ class document_page(orm.Model):
|
||||
._company_default_get(cr, uid, 'document_page', context=c)
|
||||
}
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
Loading…
Reference in New Issue
Block a user