Odoo DarkroomJS Widget
5 March, 2021 by
Odoo DarkroomJS Widget
| No comments yet

This module provides a DarkroomJS web widget for use with images fields.

This widget will allow you to perform the following actions on images:

  • Zoom
  • Rotate
  • Crop
  • Step back in history client-side (before save)


To use this module, you need to:

  • Install web_widget_darkroom

  • Add the to any One2many image relation by using the darkroom widget. Options can be passed through to Darkroom using the optionskey:

    <field name="image_id" widget="darkroom"
                           options="{'minWidth': 100}" />

The Odoo DarkroomJS widget passes options directly through to Darkroom, which are copied from the source below:

// Default options
defaults: {
  // Canvas properties (dimension, ratio, color)
  minWidth: null,
  minHeight: null,
  maxWidth: null,
  maxHeight: null,
  ratio: null,
  backgroundColor: '#fff',

  // Plugins options
  plugins: {},

  // Post-initialisation callback
  initialize: function() { /* noop */ }

An example implementation can be found [[https://repo.laslabs.com/projects/ODOO/repos/web/browse/web_widget_darkroom_example|in the LasLabs repo]] or [[https://github.com/laslabs/odoo-web/tree/release/9.0/web_widget_darkroom_example|on our GitHub mirror]].

Known Issues/Roadmap

  • Plugins are not able to be added without inheriting, then redefining the widget in the registry due to JS inheritance. ** This is not scalable because there would need to be an explicit dependency chain in order to avoid registry overwrite.


Sign in to leave a comment