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.

123 lines
4.0 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
  2. :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
  3. :alt: License: AGPL-3
  4. =========================
  5. Web widget boolean switch
  6. =========================
  7. This module add a widget ``boolean_switch`` to render boolean fields. One
  8. of it's main features is to quick edit that field without enter in edit mode.
  9. Configuration
  10. =============
  11. In the view (test on tree view and form view), you can declare any boolean
  12. field using this widget.
  13. Example
  14. -------
  15. ```
  16. <field name="active"
  17. widget="boolean_switch"
  18. attrs="{'readonly': [('login', '=', 'admin')]}"
  19. context="{'fake_parameter': 'foo'}"
  20. options="{'quick_edit': True, 'extra': {'onText': 'Yes', 'offText': 'No' }}"/>
  21. ```
  22. Options
  23. -------
  24. quick_edit
  25. ~~~~~~~~~~
  26. extra
  27. ~~~~~
  28. ``extra`` is used to set
  29. `bootstrap-switch <http://www.bootstrap-switch.org/options.html>`_ options.
  30. *Available options*:
  31. * **size**: The checkbox size - default: `null` - values: null, 'mini', 'small', 'normal', 'large'
  32. * **animate**: Animate the switch - default: `true`
  33. * **indeterminate**: Indeterminate state - default: `false`
  34. * **inverse**: Inverse switch direction - default: `false`
  35. * **onColor**: Color of the left side of the switch - default: `"primary"` - values: 'primary', 'info', 'success', 'warning', 'danger', 'default'
  36. * **offColor**: Color of the right side of the switch - default: `default` - values: 'primary', 'info', 'success', 'warning', 'danger', 'default'
  37. * **onText**: Text of the left side of the switch - default: `"ON"`
  38. * **offText**: Text of the right side of the switch - default: `"OFF"`,
  39. * **labelText**: Text of the center handle of the switch - default: `"&nbsp;"`,
  40. * **handleWidth**: Width of the left and right sides in pixels - default: `"auto"`,
  41. * **labelWidth**: Width of the center handle in pixels - default: `"auto"`,
  42. * **baseClass**: Global class prefix - default: `"bootstrap-switch"`,
  43. * **wrapperClass**: Container element class(es) - default: `"wrapper"`,
  44. .. warning::
  45. Those parameters are overwritten by this module or highly discouraged:
  46. * **radioAllOff**: Allow this radio button to be unchecked by the user - default: `false`
  47. * **state**: The checkbox state - default: `true`
  48. * **disabled**: Disable state - default: `false`
  49. * **readonly**: Readonly state - default: `false`
  50. * **onInit**: Callback function to execute on initialization - default: `function() {}`,
  51. * **onSwitchChange**: Callback function to execute on switch state change - default: `function() {}`
  52. attrs
  53. -----
  54. This attribute is supported as expected!
  55. context
  56. -------
  57. ``context`` is sent to the ``write`` method of the field model in case of
  58. special needs with the quick edition.
  59. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
  60. :alt: Try me on Runbot
  61. :target: https://runbot.odoo-community.org/runbot/162/7.0
  62. Known issues / Roadmap
  63. ======================
  64. * Manage Null values
  65. *
  66. Bug Tracker
  67. ===========
  68. Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
  69. In case of trouble, please check there if your issue has already been reported.
  70. If you spotted it first, help us smashing it by providing a detailed and
  71. welcomed feedback `here <https://github.com/OCA/web/issues/new?body=module:%20
  72. web_widget_boolean_switch%0Aversion:%207.0%0A%0A**Steps%20to%20reproduce**%0A-
  73. %20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
  74. Credits
  75. =======
  76. Contributors
  77. ------------
  78. * Pierre Verkest <pverkest@anybox.fr>
  79. Maintainer
  80. ----------
  81. .. image:: https://odoo-community.org/logo.png
  82. :alt: Odoo Community Association
  83. :target: https://odoo-community.org
  84. This module is maintained by the OCA.
  85. OCA, or the Odoo Community Association, is a nonprofit organization whose
  86. mission is to support the collaborative development of Odoo features and
  87. promote its widespread use.
  88. To contribute to this module, please visit http://odoo-community.org.