Mathias Markl
7 years ago
10 changed files with 208 additions and 7 deletions
-
5muk_web_export_attachment/__init__.py
-
3muk_web_export_attachment/__manifest__.py
-
20muk_web_export_attachment/controllers/__init__.py
-
34muk_web_export_attachment/controllers/main.py
-
5muk_web_export_attachment/doc/changelog.rst
-
15muk_web_export_attachment/static/src/js/sidebar_export.js
-
3muk_web_export_attachment/static/src/less/sidebar_export.less
-
40muk_web_export_attachment/views/convert.xml
-
20muk_web_export_attachment/wizards/__init__.py
-
70muk_web_export_attachment/wizards/convert.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 |
@ -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 |
@ -1,3 +1,8 @@ |
|||||
|
`1.1.0` |
||||
|
------- |
||||
|
|
||||
|
- Added "Save as Attachment" Button |
||||
|
|
||||
`1.0.0` |
`1.0.0` |
||||
------- |
------- |
||||
|
|
||||
|
@ -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> |
@ -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 |
@ -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', |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue