Odoo Web – DarkroomJS Widget

LasLabs has released a new Odoo DarkroomJS widget that can be used on any Many2one image field, allowing for easy image manipulation in form views.

The Odoo DarkroomJS widget can be found in the LasLabs repo or on our GitHub mirror.

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

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

Usage

  • 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 options key:

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

An example implementation can be found in the LasLabs repo or on our GitHub mirror.

Options

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 */ }
  },

Download

The web_widget_slick module can be found in the LasLabs Repo or on our Github Mirror.

Example Implementation

An example module has been created in order to illustrate how to implement this widget from scratch. It can be found on our GitHub Mirror or in the LasLabs Repo.

0