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.

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