Browse Source

1.1.0

pull/64/head
Mathias Markl 7 years ago
parent
commit
9a1697a5e5
  1. 5
      muk_web_export_attachment/__init__.py
  2. 3
      muk_web_export_attachment/__manifest__.py
  3. 20
      muk_web_export_attachment/controllers/__init__.py
  4. 34
      muk_web_export_attachment/controllers/main.py
  5. 5
      muk_web_export_attachment/doc/changelog.rst
  6. 15
      muk_web_export_attachment/static/src/js/sidebar_export.js
  7. 3
      muk_web_export_attachment/static/src/less/sidebar_export.less
  8. 40
      muk_web_export_attachment/views/convert.xml
  9. 20
      muk_web_export_attachment/wizards/__init__.py
  10. 70
      muk_web_export_attachment/wizards/convert.py

5
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 <http://www.gnu.org/licenses/>.
#
###################################################################################
###################################################################################
from . import controllers
from . import wizards

3
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",

20
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 <http://www.gnu.org/licenses/>.
#
###################################################################################
from . import main

34
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 <http://www.gnu.org/licenses/>.
#
###################################################################################
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

5
muk_web_export_attachment/doc/changelog.rst

@ -1,3 +1,8 @@
`1.1.0`
-------
- Added "Save as Attachment" Button
`1.0.0`
-------

15
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();
}
});

3
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;
}

40
muk_web_export_attachment/views/convert.xml

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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 <http://www.gnu.org/licenses/>.
-->
<odoo>
<record id="view_converter_export_form" model="ir.ui.view">
<field name="name">muk_converter_convert.form</field>
<field name="model">muk_converter.convert</field>
<field name="mode">primary</field>
<field name="inherit_id" ref="muk_web_export.view_converter_export_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='format']" position="after">
<field name="res_name" />
<field name="res_model" invisible="1" />
<field name="res_id" invisible="1" />
</xpath>
<xpath expr="//button[@name='convert']" position="after">
<button name="convert_and_save" string="Convert and Save" type="object"
class="btn-primary" attrs="{'invisible':[('res_name', '=', False)]}" />
</xpath>
</field>
</record>
</odoo>

20
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 <http://www.gnu.org/licenses/>.
#
###################################################################################
from . import convert

70
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 <http://www.gnu.org/licenses/>.
#
###################################################################################
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',
}
Loading…
Cancel
Save