diff --git a/muk_web_export_attachment/__init__.py b/muk_web_export_attachment/__init__.py
index fd42c44..5e1b868 100644
--- a/muk_web_export_attachment/__init__.py
+++ b/muk_web_export_attachment/__init__.py
@@ -15,4 +15,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
-###################################################################################
\ No newline at end of file
+###################################################################################
+
+from . import controllers
+from . import wizards
\ No newline at end of file
diff --git a/muk_web_export_attachment/__manifest__.py b/muk_web_export_attachment/__manifest__.py
index 7565512..5a00029 100644
--- a/muk_web_export_attachment/__manifest__.py
+++ b/muk_web_export_attachment/__manifest__.py
@@ -20,7 +20,7 @@
{
"name": "MuK Export Attachment",
"summary": """Export Odoo Attachments""",
- "version": "11.0.1.0.0",
+ "version": "11.0.1.1 .0",
"category": "Extra Tools",
"license": "AGPL-3",
"website": "http://www.mukit.at",
@@ -35,6 +35,7 @@
],
"data": [
"template/assets.xml",
+ "views/convert.xml",
],
"qweb": [
"static/src/xml/*.xml",
diff --git a/muk_web_export_attachment/controllers/__init__.py b/muk_web_export_attachment/controllers/__init__.py
new file mode 100644
index 0000000..4b71c01
--- /dev/null
+++ b/muk_web_export_attachment/controllers/__init__.py
@@ -0,0 +1,20 @@
+###################################################################################
+#
+# Copyright (C) 2017 MuK IT GmbH
+#
+# 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 .
+#
+###################################################################################
+
+from . import main
\ No newline at end of file
diff --git a/muk_web_export_attachment/controllers/main.py b/muk_web_export_attachment/controllers/main.py
new file mode 100644
index 0000000..51703f5
--- /dev/null
+++ b/muk_web_export_attachment/controllers/main.py
@@ -0,0 +1,34 @@
+###################################################################################
+#
+# Copyright (C) 2017 MuK IT GmbH
+#
+# 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 .
+#
+###################################################################################
+
+import os
+import logging
+
+from odoo import http
+from odoo.http import request
+
+from odoo.addons.muk_converter.tools import converter
+
+_logger = logging.getLogger(__name__)
+
+class ExportController(http.Controller):
+
+ @http.route('/web/attachment/export_action', type='json', auth="user")
+ def export_action(self, **kw):
+ return request.env.ref("muk_web_export_attachment.view_converter_export_form").id
\ No newline at end of file
diff --git a/muk_web_export_attachment/doc/changelog.rst b/muk_web_export_attachment/doc/changelog.rst
index 9ee2b48..f4ce83a 100644
--- a/muk_web_export_attachment/doc/changelog.rst
+++ b/muk_web_export_attachment/doc/changelog.rst
@@ -1,3 +1,8 @@
+`1.1.0`
+-------
+
+- Added "Save as Attachment" Button
+
`1.0.0`
-------
diff --git a/muk_web_export_attachment/static/src/js/sidebar_export.js b/muk_web_export_attachment/static/src/js/sidebar_export.js
index b449a1e..cbabbca 100644
--- a/muk_web_export_attachment/static/src/js/sidebar_export.js
+++ b/muk_web_export_attachment/static/src/js/sidebar_export.js
@@ -30,7 +30,13 @@ var _t = core._t;
Sidebar.include({
willStart: function() {
var self = this;
- var export_formats = this._rpc({
+ var export_action = this._rpc({
+ route: '/web/attachment/export_action',
+ }).then(function (result) {
+ console.log(result);
+ self.export_action = result;
+ });
+ var export_formats = this._rpc({
route: '/web/export_formats',
}).then(function (result) {
self.export_formats = result;
@@ -62,8 +68,7 @@ Sidebar.include({
.click(this._on_attachment_export.bind(this));
},
_on_attachment_export: function(e) {
- e.preventDefault();
- e.stopPropagation();
+ var self = this;
var $target = $(e.currentTarget);
this.do_action({
'type': 'ir.actions.act_window',
@@ -74,11 +79,15 @@ Sidebar.include({
'view_mode': 'form',
'target': 'new',
'context': {
+ 'default_res_id': self.env.activeIds[0],
+ 'default_res_model': self.env.model,
'default_type': "url",
'default_input_url': $target.data("url"),
'default_input_name': $target.data("name"),
},
});
+ e.preventDefault();
+ e.stopPropagation();
}
});
diff --git a/muk_web_export_attachment/static/src/less/sidebar_export.less b/muk_web_export_attachment/static/src/less/sidebar_export.less
index fcacbcf..2e1b4f0 100644
--- a/muk_web_export_attachment/static/src/less/sidebar_export.less
+++ b/muk_web_export_attachment/static/src/less/sidebar_export.less
@@ -19,8 +19,7 @@
.o_cp_sidebar {
.o_sidebar_export_attachment {
- right: -15px;
- top: 2px;
+ right: -18px;
position: relative;
font-size: 15px;
}
diff --git a/muk_web_export_attachment/views/convert.xml b/muk_web_export_attachment/views/convert.xml
new file mode 100644
index 0000000..1687ce2
--- /dev/null
+++ b/muk_web_export_attachment/views/convert.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+ muk_converter_convert.form
+ muk_converter.convert
+ primary
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/muk_web_export_attachment/wizards/__init__.py b/muk_web_export_attachment/wizards/__init__.py
new file mode 100644
index 0000000..545046e
--- /dev/null
+++ b/muk_web_export_attachment/wizards/__init__.py
@@ -0,0 +1,20 @@
+###################################################################################
+#
+# Copyright (C) 2018 MuK IT GmbH
+#
+# 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 .
+#
+###################################################################################
+
+from . import convert
\ No newline at end of file
diff --git a/muk_web_export_attachment/wizards/convert.py b/muk_web_export_attachment/wizards/convert.py
new file mode 100644
index 0000000..0302d2c
--- /dev/null
+++ b/muk_web_export_attachment/wizards/convert.py
@@ -0,0 +1,70 @@
+###################################################################################
+#
+# Copyright (C) 2017 MuK IT GmbH
+#
+# 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 .
+#
+###################################################################################
+
+import os
+import base64
+import uuid
+import logging
+import mimetypes
+
+from odoo import _, api, fields, models
+
+from odoo.addons.muk_utils.http import get_response
+from odoo.addons.muk_converter.tools import converter
+
+_logger = logging.getLogger(__name__)
+
+class ConverterWizard(models.TransientModel):
+
+ _inherit = "muk_converter.convert"
+
+ res_model = fields.Char(
+ string="Model")
+
+ res_id = fields.Integer(
+ string="ID")
+
+ res_name = fields.Char(
+ compute='_compute_res_name',
+ string='Record',
+ store=True)
+
+ @api.depends('res_model', 'res_id')
+ def _compute_res_name(self):
+ for record in self:
+ if record.res_model and record.res_id:
+ rec = self.env[record.res_model].browse(record.res_id)
+ record.res_name = rec.display_name
+
+ @api.multi
+ def convert_and_save(self):
+ self.convert()
+ for record in self:
+ if record.res_model and record.res_id:
+ self.env['ir.attachment'].create({
+ 'type': "binary",
+ 'name': record.output_name,
+ 'datas_fname': record.output_name,
+ 'datas': record.output_binary})
+ else:
+ raise ValueError("To save the converted file, a record has to be set.")
+ return {
+ 'type': 'ir.actions.client',
+ 'tag': 'reload',
+ }
\ No newline at end of file