← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~savoirfairelinux-openerp/knowledge-addons/add_document_multiple_records into lp:knowledge-addons

 

You have been requested to review the proposed merge of lp:~savoirfairelinux-openerp/knowledge-addons/add_document_multiple_records into lp:knowledge-addons.

For more details, see:
https://code.launchpad.net/~savoirfairelinux-openerp/knowledge-addons/add_document_multiple_records/+merge/205249

Added document_multiple_records module: It allows to manage a document with a multiple records.

-- 
https://code.launchpad.net/~savoirfairelinux-openerp/knowledge-addons/add_document_multiple_records/+merge/205249
Your team OpenERP knowledge addons is requested to review the proposed merge of lp:~savoirfairelinux-openerp/knowledge-addons/add_document_multiple_records into lp:knowledge-addons.
=== added directory 'document_multiple_records'
=== added file 'document_multiple_records/__init__.py'
--- document_multiple_records/__init__.py	1970-01-01 00:00:00 +0000
+++ document_multiple_records/__init__.py	2014-02-06 20:55:15 +0000
@@ -0,0 +1,26 @@
+# -*- 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
+import wizard
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'document_multiple_records/__openerp__.py'
--- document_multiple_records/__openerp__.py	1970-01-01 00:00:00 +0000
+++ document_multiple_records/__openerp__.py	2014-02-06 20:55:15 +0000
@@ -0,0 +1,55 @@
+# -*- 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@xxxxxxxxxxxxxxxxxxxx)
+""",
+    'author': 'Savoir-faire Linux',
+    'website': 'www.savoirfairelinux.com',
+    'license': 'AGPL-3',
+    'depends': [
+        'document',
+    ],
+    'data': [
+        'document_view.xml',
+        'wizard/document_wizard_view.xml',
+    ],
+    'js': ['static/src/js/document.js'],
+    'qweb': ['static/src/xml/document.xml'],
+    'test': [],
+    'demo': [
+    ],
+    'installable': True,
+    'auto_install': False,
+}
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'document_multiple_records/document.py'
--- document_multiple_records/document.py	1970-01-01 00:00:00 +0000
+++ document_multiple_records/document.py	2014-02-06 20:55:15 +0000
@@ -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 orm, fields
+
+
+class document_file(orm.Model):
+    _inherit = 'ir.attachment'
+
+    _columns = {
+        'attachmentdocument_ids': fields.one2many('ir.attachment.document', 'attachment_id', 'Records'),
+    }
+
+    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 = {}
+        for line in self.browse(cr, uid, ids, context=context):
+            if line.attachmentdocument_ids:
+                first_id = min(line.attachmentdocument_ids)
+
+                result = self.write(cr, uid, ids, {'res_id': first_id.res_id,
+                                                   'res_model': first_id.res_model,
+                                                   'res_name': first_id.res_name, }, context=context)
+                ir_attach_doc_obj.unlink(cr, uid, min(line.attachmentdocument_ids).id, context=context)
+            else:
+                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'),
+    }
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'document_multiple_records/document_view.xml'
--- document_multiple_records/document_view.xml	1970-01-01 00:00:00 +0000
+++ document_multiple_records/document_view.xml	2014-02-06 20:55:15 +0000
@@ -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="attachmentdocument_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>
+

=== added directory 'document_multiple_records/i18n'
=== added file 'document_multiple_records/i18n/document_multiple_records.pot'
--- document_multiple_records/i18n/document_multiple_records.pot	1970-01-01 00:00:00 +0000
+++ document_multiple_records/i18n/document_multiple_records.pot	2014-02-06 20:55:15 +0000
@@ -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@xxxxxxxxxxxxxxxxxxxx>\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 ""

=== added directory 'document_multiple_records/static'
=== added directory 'document_multiple_records/static/src'
=== added directory 'document_multiple_records/static/src/js'
=== added file 'document_multiple_records/static/src/js/document.js'
--- document_multiple_records/static/src/js/document.js	1970-01-01 00:00:00 +0000
+++ document_multiple_records/static/src/js/document.js	2014-02-06 20:55:15 +0000
@@ -0,0 +1,39 @@
+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();
+                //this.$('.oe_btn_class_name').on('click', this.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 Document"),
+                type: 'ir.actions.act_window',
+                res_model: 'ir.attachment.wizard',
+                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);
+        }
+    });
+};

=== added directory 'document_multiple_records/static/src/xml'
=== added file 'document_multiple_records/static/src/xml/document.xml'
--- document_multiple_records/static/src/xml/document.xml	1970-01-01 00:00:00 +0000
+++ document_multiple_records/static/src/xml/document.xml	2014-02-06 20:55:15 +0000
@@ -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 Doc...</b></span></li>
+</t>
+
+</templates>

=== added directory 'document_multiple_records/wizard'
=== added file 'document_multiple_records/wizard/__init__.py'
--- document_multiple_records/wizard/__init__.py	1970-01-01 00:00:00 +0000
+++ document_multiple_records/wizard/__init__.py	2014-02-06 20:55:15 +0000
@@ -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_wizard
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'document_multiple_records/wizard/document_wizard.py'
--- document_multiple_records/wizard/document_wizard.py	1970-01-01 00:00:00 +0000
+++ document_multiple_records/wizard/document_wizard.py	2014-02-06 20:55:15 +0000
@@ -0,0 +1,56 @@
+# -*- 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.wizard"
+    _description = "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['model'])
+
+        name = ir_model_obj.browse(cr, uid, context['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['model'],
+                'res_id': context['ids'][0],
+                'res_name': name,
+                'attachment_id': attach.id,
+            }
+            ir_attach_doc_obj.create(cr, uid, data_attach, context=context)
+        return {'type': 'ir.actions.act_window_close'}

=== added file 'document_multiple_records/wizard/document_wizard_view.xml'
--- document_multiple_records/wizard/document_wizard_view.xml	1970-01-01 00:00:00 +0000
+++ document_multiple_records/wizard/document_wizard_view.xml	2014-02-06 20:55:15 +0000
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<openerp>
+<data>
+
+  <record id="document_form_view" model="ir.ui.view">
+    <field name="name">Add Document</field>
+    <field name="model">ir.attachment.wizard</field>
+    <field name="arch" type="xml">
+      <form string="Add Document" 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 Document</field>
+    <field name="res_model">ir.attachment.wizard</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>
+