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.

279 lines
9.5 KiB

  1. ================
  2. Base Custom Info
  3. ================
  4. .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  5. !! This file is generated by oca-gen-addon-readme !!
  6. !! changes will be overwritten. !!
  7. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  8. .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
  9. :target: https://odoo-community.org/page/development-status
  10. :alt: Beta
  11. .. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
  12. :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
  13. :alt: License: LGPL-3
  14. .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
  15. :target: https://github.com/OCA/server-tools/tree/12.0/base_custom_info
  16. :alt: OCA/server-tools
  17. .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
  18. :target: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-base_custom_info
  19. :alt: Translate me on Weblate
  20. .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
  21. :target: https://runbot.odoo-community.org/runbot/149/12.0
  22. :alt: Try me on Runbot
  23. |badge1| |badge2| |badge3| |badge4| |badge5|
  24. This module allows you to attach custom information to records without the need
  25. to alter the database structure too much.
  26. This module defines several concepts that you have to understand.
  27. Templates
  28. ---------
  29. A *template* is a collection of *properties* that a record should have.
  30. *Templates* always apply to a given model, and then you can choose among the
  31. current templates for the model you are using when you edit a record of that
  32. model.
  33. I.e., This addon includes a demo template called "Smart partners", that applies
  34. to the model ``res.partner``, so if you edit any partner, you can choose that
  35. template and get its properties autofilled.
  36. Properties
  37. ----------
  38. A *property* is the "name" of the field. *Templates* can have any amount of
  39. *properties*, and when you apply a *template* to a record, it automatically
  40. gets all of its *properties* filled, empty (unless they have a *Default
  41. value*), ready to assign *values*.
  42. You can set a property to as *required* to force it have a value, although you
  43. should keep in mind that for yes/no properties, this would mean that only *yes*
  44. can be selected, and for numeric properties, zero would be forbidden.
  45. Also you can set *Minimum* and *Maximum* limits for every *property*, but those
  46. limits are only used when the data type is text (to constrain its length) or
  47. number. To skip this constraint, just set a maximum smaller than the minimum.
  48. *Properties* always belong to a template, and as such, to a model.
  49. *Properties* define the data type (text, number, yes/no...), and when the type
  50. is "Selection", then you can define what *options* are available.
  51. I.e., the "Smart partners" *template* has the following *properties*:
  52. - Name of his/her teacher
  53. - Amount of people that hates him/her for being so smart
  54. - Average note on all subjects
  55. - Does he/she believe he/she is the smartest person on earth?
  56. - What weaknesses does he/she have?
  57. When you set that template to any partner, you will then be able to fill these
  58. *properties* with *values*.
  59. Categories
  60. ----------
  61. *Properties* can also belong to a *category*, which allows you to sort them in
  62. a logical way, and makes further development easier.
  63. For example, the ``website_sale_custom_info`` addon uses these to display a
  64. technical datasheet per product in your online shop, sorted and separated by
  65. category.
  66. You are not required to give a *category* to every *property*.
  67. Options
  68. -------
  69. When a *property*'s type is "Selection", then you define the *options*
  70. available, so the *value* must be one of these *options*.
  71. I.e., the "What weaknesses does he/she have?" *property* has some options:
  72. - Loves junk food
  73. - Needs videogames
  74. - Huge glasses
  75. The *value* will always be one of these.
  76. Value
  77. -----
  78. When you assign a *template* to a partner, and then you get the *properties* it
  79. should have, you still have to set a *value* for each property.
  80. *Values* can be of different types (whole numbers, constrained selection,
  81. booleans...), depending on how the *property* was defined. However, there is
  82. always the ``value`` field, that is a text string, and converts automatically
  83. to/from the correct type.
  84. Why would I need this?
  85. ~~~~~~~~~~~~~~~~~~~~~~
  86. Imagine you have some partners that are foreign, and that for those partners
  87. you need some extra information that is not needed for others, and you do not
  88. want to fill the partners model with a lot of fields that will be empty most of
  89. the time.
  90. In this case, you could define a *template* called "Foreign partners", which
  91. will be applied to ``res.partner`` objects, and defines some *properties* that
  92. these are expected to have.
  93. Then you could assign that *template* to a partner, and automatically you will
  94. get a subtable of all the properties it should have, with tools to fill their
  95. *values* correctly.
  96. Does this work with any model?
  97. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  98. Yes and no.
  99. Yes, because this is a base module that provides the tools to make this work
  100. with any model.
  101. No, because, although the tools are provided, they are only applied to the
  102. ``res.partner`` model. This is by design, because different models can have
  103. different needs, and we don't want to depend on every possible model.
  104. So, if you want to apply this to other models, you will have to develop a
  105. little additional addon that depends on this one. If you are a developer, refer
  106. to the *Development* section below.
  107. **Table of contents**
  108. .. contents::
  109. :local:
  110. Installation
  111. ============
  112. This module serves as a base for other modules that implement this behavior in
  113. concrete models.
  114. This module is a technical dependency and is to be installed in parallel to
  115. other modules.
  116. Configuration
  117. =============
  118. To enable the main *Custom Info* menu:
  119. #. Enable *Settings > General Settings > Manage custom information*.
  120. To enable partner's custom info tab:
  121. #. Enable *Settings > General Settings > Edit custom information in partners*.
  122. Usage
  123. =====
  124. This module defines *Custom Info Templates* that define what properties are
  125. expected for a given record.
  126. To define a template, you need to:
  127. * Go to *Custom Info > Templates*.
  128. * Create one.
  129. * Add some *Properties* to it.
  130. All database records with that template enabled will automatically fill those
  131. properties.
  132. To manage the properties, you need to:
  133. * Go to *Custom Info > Properties*.
  134. To manage the property categories, you need to:
  135. * Go to *Custom Info > Categories*.
  136. Some properties can have a number of options to choose, to manage them:
  137. * Go to *Custom Info > Options*.
  138. To manage their values, you need to:
  139. * Go to *Custom Info > Values*.
  140. Development
  141. ===========
  142. To create a module that supports custom information, just depend on this module
  143. and inherit from the ``custom.info`` model.
  144. See an example in the ``product_custom_info`` addon.
  145. Known issues / Roadmap
  146. ======================
  147. * Custom properties cannot be shared among templates.
  148. * Required attributes are for now only set in the UI, not in the ORM itself.
  149. * Support recursive templates using options
  150. .. figure:: https://raw.githubusercontent.com/base_custom_info/static/description/customizations-everywhere.jpg
  151. :alt: Customizations Everywhere
  152. If you assign an *additional template* to an option, and while using the owner
  153. form you choose that option, you can then press *reload custom information
  154. templates* to make the owner update itself to include all the properties in all
  155. the involved templates. If you do not press the button, anyway the reloading
  156. will be performed when saving the owner record.
  157. .. figure:: https://raw.githubusercontent.com/base_custom_info/static/description/templateception.jpg
  158. :alt: Templateception
  159. I.e., if you select the option "Needs videogames" for the property "What
  160. weaknesses does he/she have?" of a smart partner and press *reload custom
  161. information templates*, you will get 2 new properties to fill: "Favourite
  162. videogames genre" and "Favourite videogame".
  163. Bug Tracker
  164. ===========
  165. Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
  166. In case of trouble, please check there if your issue has already been reported.
  167. If you spotted it first, help us smashing it by providing a detailed and welcomed
  168. `feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20base_custom_info%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
  169. Do not contact contributors directly about support or help with technical issues.
  170. Credits
  171. =======
  172. Authors
  173. ~~~~~~~
  174. * Tecnativa
  175. Contributors
  176. ~~~~~~~~~~~~
  177. * `Tecnativa <https://www.tecnativa.com>`__:
  178. * Rafael Blasco <rafael.blasco@tecnativa.com>
  179. * Carlos Dauden <carlos.dauden@tecnativa.com>
  180. * Sergio Teruel <sergio.teruel@tecnativa.com>
  181. * Jairo Llopis <jairo.llopis@tecnativa.com>
  182. * Pedro M. Baeza <pedro.baeza@tecnativa.com>
  183. * Alexandre Díaz <alexandre.diaz@tecnativa.com>
  184. Maintainers
  185. ~~~~~~~~~~~
  186. This module is maintained by the OCA.
  187. .. image:: https://odoo-community.org/logo.png
  188. :alt: Odoo Community Association
  189. :target: https://odoo-community.org
  190. OCA, or the Odoo Community Association, is a nonprofit organization whose
  191. mission is to support the collaborative development of Odoo features and
  192. promote its widespread use.
  193. This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/12.0/base_custom_info>`_ project on GitHub.
  194. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.