Merge lp:~savoirfairelinux-openerp/knowledge-addons/document_multiple_records into lp:knowledge-addons/7.0

Status: Rejected
Rejected by: Sandy Carter (http://www.savoirfairelinux.com)
Proposed branch: lp:~savoirfairelinux-openerp/knowledge-addons/document_multiple_records
Merge into: lp:knowledge-addons/7.0
Diff against target: 782 lines (+715/-0)
12 files modified
document_multiple_records/__init__.py (+26/-0)
document_multiple_records/__openerp__.py (+60/-0)
document_multiple_records/document.py (+89/-0)
document_multiple_records/document_view.xml (+30/-0)
document_multiple_records/i18n/document_multiple_records.pot (+140/-0)
document_multiple_records/i18n/fr.po (+151/-0)
document_multiple_records/security/ir.model.access.csv (+3/-0)
document_multiple_records/static/src/js/document.js (+79/-0)
document_multiple_records/static/src/xml/document.xml (+10/-0)
document_multiple_records/wizard/__init__.py (+25/-0)
document_multiple_records/wizard/document_wizard.py (+61/-0)
document_multiple_records/wizard/document_wizard_view.xml (+41/-0)
To merge this branch: bzr merge lp:~savoirfairelinux-openerp/knowledge-addons/document_multiple_records
Reviewer Review Type Date Requested Status
Sandy Carter (http://www.savoirfairelinux.com) Needs Resubmitting
Holger Brunn (Therp) code review Approve
OpenERP Community Reviewer/Maintainer Pending
Review via email: mp+206960@code.launchpad.net

Description of the change

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

To post a comment you must log in.
Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote :

Please fix according to https://code.launchpad.net/~savoirfairelinux-openerp/knowledge-addons/add_document_multiple_records/+merge/205249/comments/481345

Holger Brunn (Therp) (hbrunn) wrote on 2014-02-10:

I think you should follow the rule to put models into the subdir model, with one file per model.

#29 why no local import here?
#135ff could you explain those lines? To me it seems we leave stuff in the database there that we don't want
#363 comment
#377 this text seems quite misleading. How about 'Add existing document/attachment'?
$470 ir.attachment.wizard seems a very generic name, I think you should use something more specific to what you do.

Further I don't see where you do any refcount. How do you take care that if attachment A is linked to records R1, R2 and R3, A stays if I delete R1 and R2, but will be deleted when I delete R3?

And how do you deal with attachments being only visible to people who have read permissions on the document given in res_model/res_id? I think you'll have to override that to also take the other linked records into account.

For usability, I'd also add a function field that combines res_model and res_id to a reference field.

review: Needs Fixing (code review, no test)
Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) :
review: Approve (code review, test)
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

Thanks for taking some of my points into account. A new iteration:

#138 use .copy() for a shallow copy of a dict
#138, #140 'in' applied to dicts checks for keys, no need to create a new keys() list
#154 not all models declare a name property, consider using name_get()
#165 this context keys are very general. Better use some prefix to avoid unintentional clashes
#166ff why the loop?
#171 this yields a warning, better use 'in'
#194 add ondelete='cascade'

And please push your changes over the current branch, otherwise you'll lose all comments as last time

Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

...that should be 'needs fixing'

review: Needs Fixing (code review)
25. By Marc Cassuto (SFL)

[i18n] Added french translations

26. By Marc Cassuto (SFL)

[i18n] Updated french translations

Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote :

@Holger, took your comments into consideration

Taking myself out of the Reviewer list since I have contributed.

review: Abstain
27. By Sandy Carter (http://www.savoirfairelinux.com)

Add missing access rights

28. By Sandy Carter (http://www.savoirfairelinux.com)

Cleanup code and fix possible bugs

create():
    Avoid duplicating data locally
    Fix boolean comparison problem
    Use name_get rather than name field
unlink():
    Use more specific context identifiers
    Remove redundant loop and if statement
model:
    Add ondelete='cascade'

Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

Thanks! I think to make this module great, we still need to delete otherwise orphaned attachments when deleting the last referring record. But that's perfectly fine to do in version 0.2

review: Approve (code review)
Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) :
review: Approve
Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote :

This MP have been moved to MP to https://github.com/OCA/knowledge/pull/5

review: Needs Resubmitting

Unmerged revisions

28. By Sandy Carter (http://www.savoirfairelinux.com)

Cleanup code and fix possible bugs

create():
    Avoid duplicating data locally
    Fix boolean comparison problem
    Use name_get rather than name field
unlink():
    Use more specific context identifiers
    Remove redundant loop and if statement
model:
    Add ondelete='cascade'

27. By Sandy Carter (http://www.savoirfairelinux.com)

Add missing access rights

26. By Marc Cassuto (SFL)

[i18n] Updated french translations

25. By Marc Cassuto (SFL)

[i18n] Added french translations

24. By El Hadji Dem (http://www.savoirfairelinux.com)

[IMP]Change condition to pass test

23. By El Hadji Dem (http://www.savoirfairelinux.com)

[IMP]Change condition to pass test

22. By El Hadji Dem (http://www.savoirfairelinux.com)

[IMP]Fix bug to pass tests

21. By El Hadji Dem (http://www.savoirfairelinux.com)

[IMP] Refresh automatically list of documents in the form view;from knownlege, delete the documents and references; when delete document from form view, juste delete the reference; informations about the model are saved in the attachment_document_ids

20. By Joao Alfredo Gama Batista

[IMP] More clear message for the user

19. By Joao Alfredo Gama Batista

[FIX] Use attachment_document_ids to get list of attachments

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'document_multiple_records'
2=== added file 'document_multiple_records/__init__.py'
3--- document_multiple_records/__init__.py 1970-01-01 00:00:00 +0000
4+++ document_multiple_records/__init__.py 2014-04-17 00:23:10 +0000
5@@ -0,0 +1,26 @@
6+# -*- encoding: utf-8 -*-
7+##############################################################################
8+#
9+# OpenERP, Open Source Management Solution
10+# This module copyright (C) 2014 Savoir-faire Linux
11+# (<http://www.savoirfairelinux.com>).
12+#
13+# This program is free software: you can redistribute it and/or modify
14+# it under the terms of the GNU Affero General Public License as
15+# published by the Free Software Foundation, either version 3 of the
16+# License, or (at your option) any later version.
17+#
18+# This program is distributed in the hope that it will be useful,
19+# but WITHOUT ANY WARRANTY; without even the implied warranty of
20+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+# GNU Affero General Public License for more details.
22+#
23+# You should have received a copy of the GNU Affero General Public License
24+# along with this program. If not, see <http://www.gnu.org/licenses/>.
25+#
26+###############################################################################
27+
28+from . import document
29+from . import wizard
30+
31+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
32
33=== added file 'document_multiple_records/__openerp__.py'
34--- document_multiple_records/__openerp__.py 1970-01-01 00:00:00 +0000
35+++ document_multiple_records/__openerp__.py 2014-04-17 00:23:10 +0000
36@@ -0,0 +1,60 @@
37+# -*- encoding: utf-8 -*-
38+##############################################################################
39+#
40+# OpenERP, Open Source Management Solution
41+# This module copyright (C) 2014 Savoir-faire Linux
42+# (<http://www.savoirfairelinux.com>).
43+#
44+# This program is free software: you can redistribute it and/or modify
45+# it under the terms of the GNU Affero General Public License as
46+# published by the Free Software Foundation, either version 3 of the
47+# License, or (at your option) any later version.
48+#
49+# This program is distributed in the hope that it will be useful,
50+# but WITHOUT ANY WARRANTY; without even the implied warranty of
51+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
52+# GNU Affero General Public License for more details.
53+#
54+# You should have received a copy of the GNU Affero General Public License
55+# along with this program. If not, see <http://www.gnu.org/licenses/>.
56+#
57+##############################################################################
58+
59+{
60+ 'name': 'Document Management System for Multiple Records',
61+ 'version': '0.1',
62+ 'category': 'Knowledge Management',
63+ 'summary': 'Document Management System for Multiple Records',
64+ 'description': """
65+Document Management System for Multiple Records
66+==============================================
67+
68+Contributors
69+------------
70+* El Hadji Dem (elhadji.dem@savoirfairelinux.com)
71+""",
72+ 'author': 'Savoir-faire Linux',
73+ 'website': 'www.savoirfairelinux.com',
74+ 'license': 'AGPL-3',
75+ 'depends': [
76+ 'document',
77+ ],
78+ 'data': [
79+ 'document_view.xml',
80+ 'security/ir.model.access.csv',
81+ 'wizard/document_wizard_view.xml',
82+ ],
83+ 'js': [
84+ 'static/src/js/document.js'
85+ ],
86+ 'qweb': [
87+ 'static/src/xml/document.xml'
88+ ],
89+ 'test': [],
90+ 'demo': [
91+ ],
92+ 'installable': True,
93+ 'auto_install': False,
94+}
95+
96+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
97
98=== added file 'document_multiple_records/document.py'
99--- document_multiple_records/document.py 1970-01-01 00:00:00 +0000
100+++ document_multiple_records/document.py 2014-04-17 00:23:10 +0000
101@@ -0,0 +1,89 @@
102+# -*- encoding: utf-8 -*-
103+##############################################################################
104+#
105+# OpenERP, Open Source Management Solution
106+# This module copyright (C) 2014 Savoir-faire Linux
107+# (<http://www.savoirfairelinux.com>).
108+#
109+# This program is free software: you can redistribute it and/or modify
110+# it under the terms of the GNU Affero General Public License as
111+# published by the Free Software Foundation, either version 3 of the
112+# License, or (at your option) any later version.
113+#
114+# This program is distributed in the hope that it will be useful,
115+# but WITHOUT ANY WARRANTY; without even the implied warranty of
116+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
117+# GNU Affero General Public License for more details.
118+#
119+# You should have received a copy of the GNU Affero General Public License
120+# along with this program. If not, see <http://www.gnu.org/licenses/>.
121+#
122+##############################################################################
123+
124+from openerp.osv import orm, fields
125+
126+
127+class document_file(orm.Model):
128+ _inherit = 'ir.attachment'
129+
130+ _columns = {
131+ 'attachment_document_ids': fields.one2many('ir.attachment.document',
132+ 'attachment_id',
133+ 'Records'),
134+ }
135+
136+ def create(self, cr, uid, data, context=None):
137+ ir_attachment_document_obj = self.pool.get('ir.attachment.document')
138+ res = super(document_file, self).create(cr, uid, data, context=context)
139+ # Create attachment_document_ids with res_model, res_id and res_name
140+ if 'res_model' in data and 'res_id' in data:
141+ ir_attachment_document_obj.create(cr, uid, {
142+ 'attachment_id': res,
143+ 'res_model': data['res_model'],
144+ 'res_id': data['res_id'],
145+ 'res_name': data.get(
146+ 'res_name', self.pool.get(data['res_model']).browse(
147+ cr, uid, data['res_id'],
148+ context=context).name_get()[0][1]),
149+ }, context=context)
150+ return res
151+
152+ def unlink(self, cr, uid, ids, context=None, check=True):
153+ ir_attach_doc_obj = self.pool.get('ir.attachment.document')
154+ if context is None:
155+ context = {}
156+ # Deleting from dropdown list in the form view
157+ res_model = context.get('multiple_records_res_model')
158+ res_id = context.get('multiple_records_res_id')
159+ if res_model and res_id:
160+ query = [
161+ ('res_model', '=', res_model),
162+ ('res_id', '=', res_id),
163+ ('attachment_id', 'in', ids),
164+ ]
165+ ids_to_unlink = ir_attach_doc_obj.search(
166+ cr, uid, query, context=context)
167+ result = ir_attach_doc_obj.unlink(
168+ cr, uid, ids_to_unlink, context=context)
169+ else:
170+ # Normal delete
171+ result = super(document_file, self).unlink(cr, uid, ids, context=context)
172+ return result
173+
174+
175+class ir_attachment_document(orm.Model):
176+ _description = 'Attachment Documents'
177+ _name = 'ir.attachment.document'
178+
179+ _columns = {
180+ 'res_id': fields.integer('Resource ID', readonly=True,
181+ help="The record id this is attached to."),
182+ 'res_model': fields.char('Resource Model', size=64,
183+ readonly=True,
184+ help="The database object this attachment will be attached to"),
185+ 'res_name': fields.char('Resource Name', type='char',
186+ size=128,
187+ readonly=True),
188+ 'attachment_id': fields.many2one(
189+ 'ir.attachment', 'Attachment', ondelete='cascade'),
190+ }
191
192=== added file 'document_multiple_records/document_view.xml'
193--- document_multiple_records/document_view.xml 1970-01-01 00:00:00 +0000
194+++ document_multiple_records/document_view.xml 2014-04-17 00:23:10 +0000
195@@ -0,0 +1,30 @@
196+<?xml version="1.0"?>
197+<openerp>
198+<data>
199+ <!--Add model list field-->
200+ <record model="ir.ui.view" id="view_document_file_multiple_models_form">
201+ <field name="name">ir.attachment.multiple.models</field>
202+ <field name="model">ir.attachment</field>
203+ <field name="inherit_id" ref="document.view_document_file_form"/>
204+ <field name="arch" type="xml">
205+ <group string="Indexed Content" position="after">
206+ <group col="2" colspan="4">
207+ <field name="attachment_document_ids" nolabel="1">
208+ <tree string="AttachmentDocumentTree" create="false" version="7.0">
209+ <field name="res_model"/>
210+ <field name="res_id"/>
211+ <field name="res_name"/>
212+ </tree>
213+ <form string="AttachmentDocumentForm">
214+ <field name="res_model"/>
215+ <field name="res_id"/>
216+ <field name="res_name"/>
217+ </form>
218+ </field>
219+ </group>
220+ </group>
221+ </field>
222+ </record>
223+</data>
224+</openerp>
225+
226
227=== added directory 'document_multiple_records/i18n'
228=== added file 'document_multiple_records/i18n/document_multiple_records.pot'
229--- document_multiple_records/i18n/document_multiple_records.pot 1970-01-01 00:00:00 +0000
230+++ document_multiple_records/i18n/document_multiple_records.pot 2014-04-17 00:23:10 +0000
231@@ -0,0 +1,140 @@
232+# Translation of OpenERP Server.
233+# This file contains the translation of the following modules:
234+# * document_multiple_records
235+#
236+msgid ""
237+msgstr ""
238+"Project-Id-Version: OpenERP Server 7.0\n"
239+"Report-Msgid-Bugs-To: \n"
240+"POT-Creation-Date: 2014-02-06 19:28+0000\n"
241+"PO-Revision-Date: 2014-02-06 14:29-0500\n"
242+"Last-Translator: EL Hadji DEM <elhadji.dem@savoirfairelinux.com>\n"
243+"Language-Team: \n"
244+"MIME-Version: 1.0\n"
245+"Content-Type: text/plain; charset=UTF-8\n"
246+"Content-Transfer-Encoding: 8bit\n"
247+"Plural-Forms: \n"
248+"X-Generator: Poedit 1.5.4\n"
249+
250+#. module: document_multiple_records
251+#: field:ir.attachment.document,res_id:0
252+msgid "Resource ID"
253+msgstr ""
254+
255+#. module: document_multiple_records
256+#: view:ir.attachment.wizard:0
257+msgid "Select document(s)"
258+msgstr ""
259+
260+#. module: document_multiple_records
261+#. openerp-web
262+#: code:addons/document_multiple_records/static/src/xml/document.xml:7
263+#, python-format
264+msgid "Add existing Doc..."
265+msgstr ""
266+
267+#. module: document_multiple_records
268+#: field:ir.attachment.document,attachment_id:0
269+msgid "Attachment"
270+msgstr ""
271+
272+#. module: document_multiple_records
273+#: view:ir.attachment.wizard:0
274+msgid "AttachmentDocumentWizardTree"
275+msgstr ""
276+
277+#. module: document_multiple_records
278+#. openerp-web
279+#: code:addons/document_multiple_records/static/src/js/document.js:26
280+#: model:ir.actions.act_window,name:document_multiple_records.action_view_document
281+#: view:ir.attachment.wizard:0
282+#, python-format
283+msgid "Add Document"
284+msgstr ""
285+
286+#. module: document_multiple_records
287+#: field:ir.attachment.document,res_name:0
288+msgid "Resource Name"
289+msgstr ""
290+
291+#. module: document_multiple_records
292+#: model:ir.model,name:document_multiple_records.model_ir_attachment_document
293+msgid "Attachment Documents"
294+msgstr ""
295+
296+#. module: document_multiple_records
297+#: field:ir.attachment,attachmentdocument_ids:0
298+msgid "Records"
299+msgstr ""
300+
301+#. module: document_multiple_records
302+#: view:ir.attachment:0
303+msgid "AttachmentDocumentTree"
304+msgstr ""
305+
306+#. module: document_multiple_records
307+#: model:ir.model,name:document_multiple_records.model_ir_attachment
308+msgid "ir.attachment"
309+msgstr ""
310+
311+#. module: document_multiple_records
312+#: view:ir.attachment:0
313+msgid "Indexed Content"
314+msgstr ""
315+
316+#. module: document_multiple_records
317+#: model:ir.model,name:document_multiple_records.model_ir_attachment_wizard
318+msgid "Attachment wizard"
319+msgstr ""
320+
321+#. module: document_multiple_records
322+#: view:ir.attachment:0
323+msgid "AttachmentDocumentForm"
324+msgstr ""
325+
326+#. module: document_multiple_records
327+#: code:addons/document_multiple_records/wizard/document_wizard.py:46
328+#, python-format
329+msgid "Error"
330+msgstr ""
331+
332+#. module: document_multiple_records
333+#: help:ir.attachment.document,res_model:0
334+msgid "The database object this attachment will be attached to"
335+msgstr ""
336+
337+#. module: document_multiple_records
338+#: help:ir.attachment.document,res_id:0
339+msgid "The record id this is attached to."
340+msgstr ""
341+
342+#. module: document_multiple_records
343+#: field:ir.attachment.wizard,attachment_ids:0
344+msgid "Attachments"
345+msgstr ""
346+
347+#. module: document_multiple_records
348+#: field:ir.attachment.document,res_model:0
349+msgid "Resource Model"
350+msgstr ""
351+
352+#. module: document_multiple_records
353+#: view:ir.attachment.wizard:0
354+msgid "Cancel"
355+msgstr ""
356+
357+#. module: document_multiple_records
358+#: view:ir.attachment.wizard:0
359+msgid "Apply"
360+msgstr ""
361+
362+#. module: document_multiple_records
363+#: view:ir.attachment.wizard:0
364+msgid "or"
365+msgstr ""
366+
367+#. module: document_multiple_records
368+#: code:addons/document_multiple_records/wizard/document_wizard.py:47
369+#, python-format
370+msgid "You have to select at least 1 Document. And try again"
371+msgstr ""
372
373=== added file 'document_multiple_records/i18n/fr.po'
374--- document_multiple_records/i18n/fr.po 1970-01-01 00:00:00 +0000
375+++ document_multiple_records/i18n/fr.po 2014-04-17 00:23:10 +0000
376@@ -0,0 +1,151 @@
377+# Translation of OpenERP Server.
378+# This file contains the translation of the following modules:
379+# * document_multiple_records
380+#
381+msgid ""
382+msgstr ""
383+"Project-Id-Version: OpenERP Server 7.0\n"
384+"Report-Msgid-Bugs-To: \n"
385+"POT-Creation-Date: 2014-03-25 18:24+0000\n"
386+"PO-Revision-Date: 2014-03-25 14:27-0500\n"
387+"Last-Translator: Marc Cassuto <marc.cassuto@savoirfairelinux.com>\n"
388+"Language-Team: \n"
389+"Language: \n"
390+"MIME-Version: 1.0\n"
391+"Content-Type: text/plain; charset=UTF-8\n"
392+"Content-Transfer-Encoding: 8bit\n"
393+"Plural-Forms: \n"
394+"X-Generator: Poedit 1.5.4\n"
395+
396+#. module: document_multiple_records
397+#: field:ir.attachment.document,res_id:0
398+msgid "Resource ID"
399+msgstr "Identifiant de la ressource"
400+
401+#. module: document_multiple_records
402+#: view:ir.attachment.existing.doc:0
403+msgid "Select document(s)"
404+msgstr "Choisir un(des) document(s)"
405+
406+#. module: document_multiple_records
407+#: field:ir.attachment.document,attachment_id:0
408+msgid "Attachment"
409+msgstr "Document joint"
410+
411+#. module: document_multiple_records
412+#: view:ir.attachment.existing.doc:0
413+msgid "AttachmentDocumentWizardTree"
414+msgstr "AttachmentDocumentWizardTree"
415+
416+#. module: document_multiple_records
417+#. openerp-web
418+#: code:addons/document_multiple_records/static/src/js/document.js:42
419+#, python-format
420+msgid "Uploading Error"
421+msgstr "Erreur lors du transfert"
422+
423+#. module: document_multiple_records
424+#: field:ir.attachment.document,res_name:0
425+msgid "Resource Name"
426+msgstr "Nom de la ressource"
427+
428+#. module: document_multiple_records
429+#: model:ir.model,name:document_multiple_records.model_ir_attachment_document
430+msgid "Attachment Documents"
431+msgstr "Documents joints"
432+
433+#. module: document_multiple_records
434+#: field:ir.attachment,attachment_document_ids:0
435+msgid "Records"
436+msgstr "Enregistrements"
437+
438+#. module: document_multiple_records
439+#: view:ir.attachment:0
440+msgid "AttachmentDocumentTree"
441+msgstr "AttachmentDocumentTree"
442+
443+#. module: document_multiple_records
444+#: model:ir.model,name:document_multiple_records.model_ir_attachment
445+msgid "ir.attachment"
446+msgstr "ir.attachment"
447+
448+#. module: document_multiple_records
449+#: view:ir.attachment:0
450+msgid "Indexed Content"
451+msgstr "Contenu indexé"
452+
453+#. module: document_multiple_records
454+#: view:ir.attachment:0
455+msgid "AttachmentDocumentForm"
456+msgstr "AttachmentDocumentForm"
457+
458+#. module: document_multiple_records
459+#: code:addons/document_multiple_records/wizard/document_wizard.py:48
460+#, python-format
461+msgid "Error"
462+msgstr "Erreur"
463+
464+#. module: document_multiple_records
465+#: help:ir.attachment.document,res_model:0
466+msgid "The database object this attachment will be attached to"
467+msgstr "L'objet de la base de données auquel ce document sera attaché"
468+
469+#. module: document_multiple_records
470+#: help:ir.attachment.document,res_id:0
471+msgid "The record id this is attached to."
472+msgstr "L'identifiant de l'enregistrement auquel est ce document est joint."
473+
474+#. module: document_multiple_records
475+#. openerp-web
476+#: code:addons/document_multiple_records/static/src/js/document.js:25
477+#: model:ir.actions.act_window,name:document_multiple_records.action_view_document
478+#: view:ir.attachment.existing.doc:0
479+#, python-format
480+msgid "Add existing document/attachment"
481+msgstr "Ajouter un document déjà joint dans le système"
482+
483+#. module: document_multiple_records
484+#: model:ir.model,name:document_multiple_records.model_ir_attachment_existing_doc
485+msgid "Add existing document/attachment wizard"
486+msgstr "Assistant pour ajouter un document déjà joint dans le système"
487+
488+#. module: document_multiple_records
489+#: field:ir.attachment.existing.doc,attachment_ids:0
490+msgid "Attachments"
491+msgstr "Documents joints"
492+
493+#. module: document_multiple_records
494+#. openerp-web
495+#: code:addons/document_multiple_records/static/src/xml/document.xml:7
496+#, python-format
497+msgid "Add existing document/attachment..."
498+msgstr "Ajouter un document déjà joint dans le système..."
499+
500+#. module: document_multiple_records
501+#: field:ir.attachment.document,res_model:0
502+msgid "Resource Model"
503+msgstr "Modèle"
504+
505+#. module: document_multiple_records
506+#: view:ir.attachment.existing.doc:0
507+msgid "Cancel"
508+msgstr "Annuler"
509+
510+#. module: document_multiple_records
511+#: view:ir.attachment.existing.doc:0
512+msgid "Apply"
513+msgstr "Appliquer"
514+
515+#. module: document_multiple_records
516+#: view:ir.attachment.existing.doc:0
517+msgid "or"
518+msgstr "ou"
519+
520+#. module: document_multiple_records
521+#: code:addons/document_multiple_records/wizard/document_wizard.py:49
522+#, python-format
523+msgid "You have to select at least 1 Document. And try again"
524+msgstr "Vous devez sélectionner au moins un document et essayer de nouveau."
525+
526+#~ msgid "Add Document"
527+#~ msgstr "Ajouter un document"
528
529=== added directory 'document_multiple_records/security'
530=== added file 'document_multiple_records/security/ir.model.access.csv'
531--- document_multiple_records/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
532+++ document_multiple_records/security/ir.model.access.csv 2014-04-17 00:23:10 +0000
533@@ -0,0 +1,3 @@
534+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
535+access_ir_attachment_document_group_user,ir.attachment.document user,model_ir_attachment_document,base.group_document_user,1,1,1,1
536+access_ir_attachment_existing_doc,access_ir_attachment_existing_doc,model_ir_attachment_existing_doc,base.group_document_user,1,1,1,1
537
538=== added directory 'document_multiple_records/static'
539=== added directory 'document_multiple_records/static/src'
540=== added directory 'document_multiple_records/static/src/js'
541=== added file 'document_multiple_records/static/src/js/document.js'
542--- document_multiple_records/static/src/js/document.js 1970-01-01 00:00:00 +0000
543+++ document_multiple_records/static/src/js/document.js 2014-04-17 00:23:10 +0000
544@@ -0,0 +1,79 @@
545+openerp.document_multiple_records = function(instance, m) {
546+var _t = instance.web._t,
547+ QWeb = instance.web.qweb;
548+
549+ instance.web.Sidebar.include({
550+ redraw: function() {
551+ var self = this;
552+ this._super.apply(this, arguments);
553+ self.$el.find('.oe_sidebar_add_attachment').after(QWeb.render('AddDocfromserver', {widget: self}))
554+ self.$el.find('.open').on('click', function (e) {
555+ self.on_call_new_view_function();
556+ });
557+ },
558+ on_call_new_view_function: function(state) {
559+ var self = this;
560+ var view = self.getParent();
561+ var ids = ( view.fields_view.type != "form" )? view.groups.get_selection().ids : [ view.datarecord.id ];
562+ // you can pass in other data using the context dictionary variable
563+ var context = {
564+ 'model': view.dataset.model,
565+ 'ids': ids,
566+ };
567+ // the action dictionary variable sends data in the "self.do_action" method
568+ var action = {
569+ name: _t("Add existing document"),
570+ type: 'ir.actions.act_window',
571+ res_model: 'ir.attachment.existing.doc',
572+ view_mode: 'form',
573+ view_type: 'form',
574+ views: [[false, 'form']],
575+ target: 'new',
576+ context: context,
577+ };
578+ // self.do_action accepts the action parameter and opens the new view
579+ self.do_action(action, {
580+ // refresh list of documents
581+ on_close: function () {
582+ self.do_attachement_update(self.dataset, self.model_id);
583+ }
584+ });
585+
586+ },
587+ on_attachment_delete: function(e) {
588+ e.preventDefault();
589+ e.stopPropagation();
590+ var self = this;
591+ var view = self.getParent();
592+ self.model_view = view.dataset.model
593+ var ids = ( view.fields_view.type != "form" )? view.groups.get_selection().ids : [ view.datarecord.id ];
594+ // Context dictionary variable
595+ var context = {
596+ 'multiple_records_res_model': self.model_view,
597+ 'multiple_records_res_id': ids[0],
598+ };
599+ var $e = $(e.currentTarget);
600+ if (confirm(_t("Do you really want to delete this attachment ?"))) {
601+ (new instance.web.DataSet(this, 'ir.attachment', context)).unlink([parseInt($e.attr('data-id'), 10)]).done(function() {
602+ self.do_attachement_update(self.dataset, self.model_id);
603+ });
604+ }
605+ },
606+ do_attachement_update: function(dataset, model_id, args) {
607+ var self = this;
608+ this.dataset = dataset;
609+ this.model_id = model_id;
610+ if (args && args[0].error) {
611+ this.do_warn(_t('Uploading Error'), args[0].error);
612+ }
613+ if (!model_id) {
614+ this.on_attachments_loaded([]);
615+ }
616+ else {
617+ var dom = [ ['attachment_document_ids.res_model', '=', dataset.model], ['attachment_document_ids.res_id', '=', model_id], ['type', 'in', ['binary', 'url']] ];
618+ var ds = new instance.web.DataSetSearch(this, 'ir.attachment', dataset.get_context(), dom);
619+ ds.read_slice(['name', 'url', 'type', 'create_uid', 'create_date', 'write_uid', 'write_date'], {}).done(this.on_attachments_loaded);
620+ }
621+ }
622+ });
623+};
624
625=== added directory 'document_multiple_records/static/src/xml'
626=== added file 'document_multiple_records/static/src/xml/document.xml'
627--- document_multiple_records/static/src/xml/document.xml 1970-01-01 00:00:00 +0000
628+++ document_multiple_records/static/src/xml/document.xml 2014-04-17 00:23:10 +0000
629@@ -0,0 +1,10 @@
630+<?xml version="1.0" encoding="UTF-8"?>
631+<!-- vim:fdl=1:
632+-->
633+<templates id="template" xml:space="preserve">
634+
635+<t t-name="AddDocfromserver">
636+ <li class="open"><span><b>Add existing document...</b></span></li>
637+</t>
638+
639+</templates>
640
641=== added directory 'document_multiple_records/wizard'
642=== added file 'document_multiple_records/wizard/__init__.py'
643--- document_multiple_records/wizard/__init__.py 1970-01-01 00:00:00 +0000
644+++ document_multiple_records/wizard/__init__.py 2014-04-17 00:23:10 +0000
645@@ -0,0 +1,25 @@
646+# -*- encoding: utf-8 -*-
647+##############################################################################
648+#
649+# OpenERP, Open Source Management Solution
650+# This module copyright (C) 2014 Savoir-faire Linux
651+# (<http://www.savoirfairelinux.com>).
652+#
653+# This program is free software: you can redistribute it and/or modify
654+# it under the terms of the GNU Affero General Public License as
655+# published by the Free Software Foundation, either version 3 of the
656+# License, or (at your option) any later version.
657+#
658+# This program is distributed in the hope that it will be useful,
659+# but WITHOUT ANY WARRANTY; without even the implied warranty of
660+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
661+# GNU Affero General Public License for more details.
662+#
663+# You should have received a copy of the GNU Affero General Public License
664+# along with this program. If not, see <http://www.gnu.org/licenses/>.
665+#
666+##############################################################################
667+
668+from . import document_wizard
669+
670+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
671
672=== added file 'document_multiple_records/wizard/document_wizard.py'
673--- document_multiple_records/wizard/document_wizard.py 1970-01-01 00:00:00 +0000
674+++ document_multiple_records/wizard/document_wizard.py 2014-04-17 00:23:10 +0000
675@@ -0,0 +1,61 @@
676+# -*- encoding: utf-8 -*-
677+##############################################################################
678+#
679+# OpenERP, Open Source Management Solution
680+# This module copyright (C) 2014 Savoir-faire Linux
681+# (<http://www.savoirfairelinux.com>).
682+#
683+# This program is free software: you can redistribute it and/or modify
684+# it under the terms of the GNU Affero General Public License as
685+# published by the Free Software Foundation, either version 3 of the
686+# License, or (at your option) any later version.
687+#
688+# This program is distributed in the hope that it will be useful,
689+# but WITHOUT ANY WARRANTY; without even the implied warranty of
690+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
691+# GNU Affero General Public License for more details.
692+#
693+# You should have received a copy of the GNU Affero General Public License
694+# along with this program. If not, see <http://www.gnu.org/licenses/>.
695+#
696+##############################################################################
697+
698+from openerp.osv import fields, orm
699+from openerp.tools.translate import _
700+
701+
702+class document_wizard(orm.Model):
703+ _name = "ir.attachment.existing.doc"
704+ _description = "Add existing document/attachment wizard"
705+ _columns = {
706+ 'attachment_ids': fields.many2many('ir.attachment',
707+ 'document_attachment_rel',
708+ 'wizard_id',
709+ 'attachment_id',
710+ 'Attachments'),
711+ }
712+
713+ def action_apply(self, cr, uid, ids, context=None):
714+ if context is None:
715+ context = {}
716+ ir_attach_obj = self.pool.get('ir.attachment')
717+ ir_attach_doc_obj = self.pool.get('ir.attachment.document')
718+ ir_model_obj = self.pool.get(context.get('model') or context.get('active_model'))
719+
720+ name = ir_model_obj.browse(cr, uid, context.get('ids') or context.get('active_ids'), context=context)[0]['name']
721+ data = self.read(cr, uid, ids, [], context=context)[0]
722+ if not data['attachment_ids']:
723+ raise orm.except_orm(_('Error'),
724+ _('You have to select at least 1 Document. And try again'))
725+ for attach in ir_attach_obj.browse(cr, uid, data['attachment_ids'], context=context):
726+ data_attach = {
727+ 'res_model': context.get('model') or context.get('active_model'),
728+ 'res_id': context.get('ids') and context.get('ids')[0] or context.get('active_id'),
729+ 'res_name': name,
730+ 'attachment_id': attach.id,
731+ }
732+ #Created attachment_document_ids
733+ ir_attach_doc_obj.create(cr, uid, data_attach, context=context)
734+ return {'type': 'ir.actions.act_window_close'}
735+
736+# vim:expandtab:smartindent:toabstop=4:softtabstop=4:shiftwidth=4:
737
738=== added file 'document_multiple_records/wizard/document_wizard_view.xml'
739--- document_multiple_records/wizard/document_wizard_view.xml 1970-01-01 00:00:00 +0000
740+++ document_multiple_records/wizard/document_wizard_view.xml 2014-04-17 00:23:10 +0000
741@@ -0,0 +1,41 @@
742+<?xml version="1.0"?>
743+<openerp>
744+<data>
745+
746+ <record id="document_form_view" model="ir.ui.view">
747+ <field name="name">Add existing document/attachment</field>
748+ <field name="model">ir.attachment.existing.doc</field>
749+ <field name="arch" type="xml">
750+ <form string="Add existing document/attachment" version="7.0">
751+ <group string="Select document(s)" colspan="4">
752+ <field name="attachment_ids" nolabel="1">
753+ <tree string="AttachmentDocumentWizardTree">
754+ <field name="name"/>
755+ <field name="create_uid"/>
756+ <field name="create_date"/>
757+ <field name="type"/>
758+ </tree>
759+ </field>
760+ </group>
761+ <footer>
762+ <button string="Apply" name="action_apply" type="object" class="oe_highlight"/>
763+ or
764+ <button string="Cancel" class="oe_link" special="cancel" />
765+ </footer>
766+ </form>
767+ </field>
768+ </record>
769+
770+ <!-- Actions -->
771+ <record model="ir.actions.act_window" id="action_view_document">
772+ <field name="name">Add existing document/attachment</field>
773+ <field name="res_model">ir.attachment.existing.doc</field>
774+ <field name="view_type">form</field>
775+ <field name="view_mode">tree,form</field>
776+ <field name="view_id" ref="document_form_view"/>
777+ <field name="target">new</field>
778+ </record>
779+
780+</data>
781+</openerp>
782+

Subscribers

People subscribed via source and target branches

to status/vote changes: