You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
3.1 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. ===========
  2. MuK Preview
  3. ===========
  4. MuK Preview enables support to preview binary files directly in Odoo. It adds a
  5. button to the binary field, which opens a file preview dialog. The preview can
  6. be easily extended by adding new Handlers to the Preview Generator.
  7. Installation
  8. ============
  9. To install this module, you need to:
  10. Download the module and add it to your Odoo addons folder. Afterward, log on to
  11. your Odoo server and go to the Apps menu. Trigger the debug modus and update the
  12. list by clicking on the "Update Apps List" link. Now install the module by
  13. clicking on the install button.
  14. Configuration
  15. =============
  16. No additional configuration is needed to use this module.
  17. Usage
  18. =============
  19. To each Binary Field Widget a button is added, which opens the Preview Dialog.
  20. Framework
  21. =============
  22. To extend the preview a new "PreviewHandler" has to be created and subsequently added to the "PreviewGenerator".
  23. The following steps show the implementation of the image preview.
  24. PreviewHandler
  25. --------------
  26. .. code-block:: javascript
  27. odoo.define('muk_preview_image.PreviewHandler', function (require) {
  28. "use strict";
  29. var core = require('web.core');
  30. var PreviewHandler = require('muk_preview.PreviewHandler');
  31. var QWeb = core.qweb;
  32. var _t = core._t;
  33. var ImageHandler = PreviewHandler.BaseHandler.extend({
  34. checkExtension: function(extension) {
  35. return ['.cod', '.ras', '.fif', '.gif', ...].includes(extension);
  36. },
  37. checkType: function(mimetype) {
  38. return ['image/cis-cod', 'image/fif', ...].includes(mimetype);
  39. },
  40. createHtml: function(url, mimetype, extension, title) {
  41. var result = $.Deferred();
  42. var $content = $(QWeb.render('ImageHTMLContent', {url: url, alt: title}));
  43. $content.find('img').click(function (e) {
  44. ImageViewer().show(this.src, this.src);
  45. });
  46. result.resolve($content);
  47. return $.when(result);
  48. },
  49. });
  50. return {
  51. ImageHandler: ImageHandler,
  52. }
  53. });
  54. PreviewGenerator
  55. ----------------
  56. .. code-block:: javascript
  57. odoo.define('muk_preview_image.PreviewGenerator', function (require) {
  58. "use strict";
  59. var core = require('web.core');
  60. var PreviewGenerator = require('muk_preview.PreviewGenerator');
  61. var PreviewHandler = require('muk_preview_image.PreviewHandler');
  62. var QWeb = core.qweb;
  63. var _t = core._t;
  64. PreviewGenerator.include({
  65. init: function(widget, additional_handler) {
  66. this._super(widget, additional_handler);
  67. this.handler = _.extend(this.handler, {
  68. "ImageHandler": new PreviewHandler.ImageHandler(widget),
  69. });
  70. },
  71. });
  72. });
  73. Credits
  74. =======
  75. Contributors
  76. ------------
  77. * Mathias Markl <mathias.markl@mukit.at>
  78. Author & Maintainer
  79. -------------------
  80. This module is maintained by the `MuK IT GmbH <https://www.mukit.at/>`_.
  81. MuK IT is an Austrian company specialized in customizing and extending Odoo.
  82. We develop custom solutions for your individual needs to help you focus on
  83. your strength and expertise to grow your business.
  84. If you want to get in touch please contact us via mail
  85. (sale@mukit.at) or visit our website (https://mukit.at).