Mathias Markl 6 years ago
parent
commit
19e992ecdd
  1. 4
      muk_web_preview_attachment/README.md
  2. 2
      muk_web_preview_attachment/__init__.py
  3. 13
      muk_web_preview_attachment/__manifest__.py
  4. 6
      muk_web_preview_attachment/doc/changelog.rst
  5. 48
      muk_web_preview_attachment/doc/index.rst
  6. 2
      muk_web_preview_attachment/models/__init__.py
  7. 5
      muk_web_preview_attachment/models/ir_attachment.py
  8. BIN
      muk_web_preview_attachment/static/description/demo.gif
  9. 36
      muk_web_preview_attachment/static/description/index.html
  10. BIN
      muk_web_preview_attachment/static/description/screenshot_chatter.png
  11. BIN
      muk_web_preview_attachment/static/description/screenshot_sidebar.png
  12. 48
      muk_web_preview_attachment/static/src/js/widget_preview.js
  13. 6
      muk_web_preview_attachment/static/src/less/sidebar_preview.less
  14. 33
      muk_web_preview_attachment/static/src/less/widget_preview.less
  15. 35
      muk_web_preview_attachment/static/src/xml/widget_preview.xml
  16. 2
      muk_web_preview_attachment/template/assets.xml
  17. 3
      muk_web_preview_attachment/tests/__init__.py
  18. 18
      muk_web_preview_attachment/tests/test_attachment_extension.py

4
muk_web_preview_attachment/README.md

@ -1,4 +0,0 @@
# MuK Preview Attachment
Adds a button to the Attachment Sidebar to preview the content directly in the browser.
The module also enables the possibility to preview attachment in the Odoo Chat Widgets.

2
muk_web_preview_attachment/__init__.py

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
###################################################################################
#
# Copyright (C) 2017 MuK IT GmbH

13
muk_web_preview_attachment/__manifest__.py

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
###################################################################################
#
# Copyright (C) 2017 MuK IT GmbH
@ -22,16 +20,11 @@
{
"name": "MuK Preview Attachment",
"summary": """Attachment Preview Dialog""",
"description": """
Adds a button to the Attachment Sidebar to
preview the content directly in the browser.
The module also enables the possibility to
preview attachment in the Odoo Chat Widgets.
""",
"version": "11.0.1.0.6",
"version": "11.0.2.0.0",
"category": "Extra Tools",
"license": "AGPL-3",
"website": "http://www.mukit.at",
"live_test_url": "https://demo.mukit.at/web/login",
"author": "MuK IT",
"contributors": [
"Mathias Markl <mathias.markl@mukit.at>",
@ -45,8 +38,6 @@
"template/assets.xml",
"views/ir_attachment_view.xml",
],
"demo": [
],
"qweb": [
"static/src/xml/*.xml",
],

6
muk_web_preview_attachment/doc/changelog.rst

@ -1,3 +1,9 @@
`2.0.0`
-------
- Migrated to Python 3
- Support for FieldMany2ManyBinaryMultiFiles Widget
`1.0.0`
-------

48
muk_web_preview_attachment/doc/index.rst

@ -0,0 +1,48 @@
======================
MuK Preview Attachment
======================
Adds a button to the Attachment Sidebar to preview the content directly in the
browser. The module also enables the possibility to preview attachment in the
Odoo Chat Widgets.
Installation
============
To install this module, you need to:
Download the module and add it to your Odoo addons folder. Afterward, log on to
your Odoo server and go to the Apps menu. Trigger the debug modus and update the
list by clicking on the "Update Apps List" link. Now install the module by
clicking on the install button.
Configuration
=============
No additional configuration is needed to use this module.
Usage
=============
Attachment views as well as attachments in the chatter widgets can be previewed
using the Preview dialog.
Credits
=======
Contributors
------------
* Mathias Markl <mathias.markl@mukit.at>
Author & Maintainer
-------------------
This module is maintained by the `MuK IT GmbH <https://www.mukit.at/>`_.
MuK IT is an Austrian company specialized in customizing and extending Odoo.
We develop custom solutions for your individual needs to help you focus on
your strength and expertise to grow your business.
If you want to get in touch please contact us via mail
(sale@mukit.at) or visit our website (https://mukit.at).

2
muk_web_preview_attachment/models/__init__.py

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
###################################################################################
#
# Copyright (C) 2017 MuK IT GmbH

5
muk_web_preview_attachment/models/ir_attachment.py

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
###################################################################################
#
# Copyright (C) 2017 MuK IT GmbH
@ -19,13 +17,10 @@
#
###################################################################################
import base64
import collections
import logging
import mimetypes
import os.path
from odoo import _
from odoo import models, api, fields
_logger = logging.getLogger(__name__)

BIN
muk_web_preview_attachment/static/description/demo.gif

Before

Width: 1422  |  Height: 703  |  Size: 842 KiB

After

Width: 1200  |  Height: 675  |  Size: 632 KiB

36
muk_web_preview_attachment/static/description/index.html

@ -4,7 +4,7 @@
<h3 class="oe_slogan">Preview your attachments directly in Odoo.</h3>
<h4 class="oe_slogan" style="font-size: 23px;">MuK IT GmbH -
www.mukit.at</h4>
<div class="oe_demo oe_screenshot">
<div class="oe_demo oe_screenshot" style="max-width: 84%; margin: 16px 8%;">
<img src="demo.gif">
</div>
</div>
@ -12,7 +12,7 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_picture">
<div style="max-width: 84%; margin: 16px 8%;">
<h3 class="oe_slogan">Overview</h3>
<p class="oe_mt32">Adds a button to the Attachment Sidebar to
preview the content directly in the browser. The module also enables
@ -49,14 +49,46 @@
</div>
</section>
<section class="oe_container oe_dark"
style="margin-bottom: 20px; border-top: 5px solid #797979; border-bottom: 5px solid #797979;">
<h3 class="oe_slogan" style="margin-bottom: 10px;">Demo</h3>
<div class="row" style="margin: auto; max-width: 200px;">
<div class="col-xs-6">
<h5 class="oe_slogan" style="font-size: 20px; margin: 2px;">User:</h5>
</div>
<div class="col-xs-6">
<h5 class="oe_slogan" style="font-size: 20px; margin: 2px;">apps</h5>
</div>
<div class="col-xs-6">
<h5 class="oe_slogan" style="font-size: 20px; margin: 2px;">Password:</h5>
</div>
<div class="col-xs-6">
<h5 class="oe_slogan" style="font-size: 20px; margin: 2px;">demo</h5>
</div>
</div>
<div class="oe_slogan" style="margin-top: 5px;">
<a class="btn btn-primary btn-lg mt8"
href="https://demo.mukit.at/web/login"
style="position: relative; overflow: hidden;"><span
class="o_ripple"
style="height: 138px; width: 138px; top: -35.2969px; left: -8.17188px;"></span>
<i class="fa fa-video-camera"></i> Live Preview </a>
</div>
</section>
<section class="oe_container oe_dark">
<h3 class="oe_slogan">Help and Support</h3>
<h5 class="oe_slogan" style="font-size: 20px;">Feel free to
contact us, if you need any help with your Odoo integration or
addiontal features.</h5>
<div class="oe_slogan">
<a class="btn btn-primary btn-lg mt8" href="mailto:sale@mukit.at">
<i class="fa fa-envelope"></i> Email
</a> <a class="btn btn-primary btn-lg mt8"
href="https://mukit.at/page/contactus"> <i class="fa fa-phone"></i>
Contact
</a> <a class="btn btn-primary btn-lg mt8" href="mailto:support@mukit.at">
<i class="fa fa-life-ring"></i> Support
</a>
</div>
<img src="logo.png" style="width: 200px; margin-bottom: 20px;"

BIN
muk_web_preview_attachment/static/description/screenshot_chatter.png

Before

Width: 1920  |  Height: 948  |  Size: 46 KiB

After

Width: 1425  |  Height: 802  |  Size: 98 KiB

BIN
muk_web_preview_attachment/static/description/screenshot_sidebar.png

Before

Width: 1920  |  Height: 949  |  Size: 89 KiB

After

Width: 1425  |  Height: 802  |  Size: 150 KiB

48
muk_web_preview_attachment/static/src/js/widget_preview.js

@ -0,0 +1,48 @@
/**********************************************************************************
*
* 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.define('muk_preview_attachment.WidgetPreview', function (require) {
"use strict";
var core = require('web.core');
var session = require('web.session');
var fields = require('web.relational_fields');
var PreviewHelper = require('muk_preview_attachment.PreviewHelper');
var QWeb = core.qweb;
var _t = core._t;
fields.FieldMany2ManyBinaryMultiFiles.include({
init: function() {
this._super.apply(this, arguments);
this.events = _.extend(this.events, {
'click .oe_attachment .o_image': '_preview',
'click .o_attachment_preview': '_preview',
});
},
_preview: function(e) {
e.preventDefault();
e.stopPropagation();
PreviewHelper.createAttachmentPreview(
$(e.currentTarget).data('id'), this);
},
});
});

6
muk_web_preview_attachment/static/src/less/sidebar_preview.less

@ -19,15 +19,11 @@
.o_cp_sidebar {
.o_sidebar_preview_attachment {
right: -12px;
right: -18px;
position: relative;
}
.open .dropdown-menu > li > a {
display: inline-block;
}
.o_sidebar_delete_attachment {
top: 3px;
}
}

33
muk_web_preview_attachment/static/src/less/widget_preview.less

@ -0,0 +1,33 @@
/**********************************************************************************
*
* 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/>.
*
**********************************************************************************/
.o_attachment_preview {
border: 0;
cursor: pointer;
padding: 0;
background: transparent;
-webkit-appearance: none;
opacity: 0.9;
filter: alpha(opacity=90);
&:hover , &:focus {
opacity: 1;
filter: alpha(opacity=100);
}
}

35
muk_web_preview_attachment/static/src/xml/widget_preview.xml

@ -0,0 +1,35 @@
<?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/>.
-->
<templates>
<t t-extend="FieldBinaryFileUploader.files">
<t t-jquery="a[target='_blank']" t-operation="before">
<t t-if="widget.mode === 'readonly'">
<button type="button" class="o_attachment_preview" aria-hidden="true" t-att-data-id="file.data.id">
<i class="fa fa-file-text-o" t-att-data-id="file.data.id"></i>
</button>
</t>
</t>
<t t-jquery=".o_image" t-operation="attributes">
<attribute name="t-att-data-id">widget.metadata[file.id] ? file.data.id : false</attribute>
</t>
</t>
</templates>

2
muk_web_preview_attachment/template/assets.xml

@ -22,12 +22,14 @@
<xpath expr="//link[last()]" position="after">
<link rel="stylesheet" href="/muk_web_preview_attachment/static/src/less/attachment_preview.less" />
<link rel="stylesheet" href="/muk_web_preview_attachment/static/src/less/sidebar_preview.less" />
<link rel="stylesheet" href="/muk_web_preview_attachment/static/src/less/widget_preview.less" />
</xpath>
<xpath expr="//script[last()]" position="after">
<script type="text/javascript" src="/muk_web_preview_attachment/static/src/js/preview_helper.js"/>
<script type="text/javascript" src="/muk_web_preview_attachment/static/src/js/attachment_preview.js"/>
<script type="text/javascript" src="/muk_web_preview_attachment/static/src/js/chatter_preview.js"/>
<script type="text/javascript" src="/muk_web_preview_attachment/static/src/js/sidebar_preview.js"/>
<script type="text/javascript" src="/muk_web_preview_attachment/static/src/js/widget_preview.js"/>
</xpath>
</template>
</odoo>

3
muk_web_preview_attachment/tests/__init__.py

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
###################################################################################
#
# Copyright (C) 2017 MuK IT GmbH
@ -20,4 +18,3 @@
###################################################################################
from . import test_attachment_extension

18
muk_web_preview_attachment/tests/test_attachment_extension.py

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
###################################################################################
#
# Copyright (C) 2017 MuK IT GmbH
@ -21,11 +19,7 @@
import os
import base64
import unittest
from contextlib import closing
from odoo import _
from odoo.tests import common
_path = os.path.dirname(os.path.dirname(__file__))
@ -43,22 +37,22 @@ class AttachmentExtensionTestCase(common.TransactionCase):
super(AttachmentExtensionTestCase, self).tearDown()
def test_attachment_extension_filename(self):
with closing(open(os.path.join(_path, 'tests/data/sample.png'), 'rb')) as file:
self.sample = self.attachment_model.create({
with open(os.path.join(_path, 'tests/data/sample.png'), 'rb') as file:
sample = self.attachment_model.create({
'name': "test",
'datas_fname': "sample.png",
'datas': base64.b64encode(file.read()),
})
self.assertEqual(self.sample.extension, ".png")
self.assertEqual(sample.extension, ".png")
def test_attachment_extension_mimetype(self):
with closing(open(os.path.join(_path, 'tests/data/sample.png'), 'rb')) as file:
self.sample = self.attachment_model.create({
with open(os.path.join(_path, 'tests/data/sample.png'), 'rb') as file:
sample = self.attachment_model.create({
'name': "test",
'mimetype': "image/png",
'datas': base64.b64encode(file.read()),
})
self.assertEqual(self.sample.extension, ".png")
self.assertEqual(sample.extension, ".png")
Loading…
Cancel
Save