diff --git a/document_multiple_records/document.py b/document_multiple_records/document.py index 11e9e022..2fb2c5df 100644 --- a/document_multiple_records/document.py +++ b/document_multiple_records/document.py @@ -36,6 +36,7 @@ class document_file(orm.Model): context = {} for line in self.browse(cr, uid, ids, context=context): if line.attachmentdocument_ids: + # Get the first document first_id = min(line.attachmentdocument_ids) result = self.write(cr, uid, ids, {'res_id': first_id.res_id, diff --git a/document_multiple_records/static/src/js/document.js b/document_multiple_records/static/src/js/document.js index c485da9a..0f2a7872 100644 --- a/document_multiple_records/static/src/js/document.js +++ b/document_multiple_records/static/src/js/document.js @@ -9,7 +9,6 @@ var _t = instance.web._t, 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) { @@ -23,7 +22,7 @@ var _t = instance.web._t, }; // the action dictionary variable sends data in the "self.do_action" method var action = { - name: _t("Add Document"), + name: _t("Add existing document/attachment"), type: 'ir.actions.act_window', res_model: 'ir.attachment.wizard', view_mode: 'form', diff --git a/document_multiple_records/wizard/document_wizard.py b/document_multiple_records/wizard/document_wizard.py index 83136c83..58d10e83 100644 --- a/document_multiple_records/wizard/document_wizard.py +++ b/document_multiple_records/wizard/document_wizard.py @@ -52,7 +52,12 @@ class document_wizard(orm.Model): 'res_name': name, 'attachment_id': attach.id, } - ir_attach_doc_obj.create(cr, uid, data_attach, context=context) + #Created attachment_document_ids + if attach.res_model: + ir_attach_doc_obj.create(cr, uid, data_attach, context=context) + # Updated attachment line + else: + ir_attach_obj.write(cr, uid, [attach.id], data_attach, context=context) return {'type': 'ir.actions.act_window_close'} # vim:expandtab:smartindent:toabstop=4:softtabstop=4:shiftwidth=4: