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.

237 lines
7.3 KiB

9 years ago
  1. .. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
  2. :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
  3. :alt: License: LGPL-3
  4. ================
  5. Base Custom Info
  6. ================
  7. This module allows you to attach custom information to records without the need
  8. to alter the database structure too much.
  9. Definitions
  10. ===========
  11. This module defines several concepts that you have to understand.
  12. Templates
  13. ---------
  14. A *template* is a collection of *properties* that a record should have.
  15. *Templates* always apply to a given model, and then you can choose among the
  16. current templates for the model you are using when you edit a record of that
  17. model.
  18. I.e., This addon includes a demo template called "Smart partners", that applies
  19. to the model ``res.partner``, so if you edit any partner, you can choose that
  20. template and get its properties autofilled.
  21. Properties
  22. ----------
  23. A *property* is the "name" of the field. *Templates* can have any amount of
  24. *properties*, and when you apply a *template* to a record, it automatically
  25. gets all of its *properties* filled, empty (unless they have a *Default
  26. value*), ready to assign *values*.
  27. You can set a property to as *required* to force it have a value, although you
  28. should keep in mind that for yes/no properties, this would mean that only *yes*
  29. can be selected, and for numeric properties, zero would be forbidden.
  30. Also you can set *Minimum* and *Maximum* limits for every *property*, but those
  31. limits are only used when the data type is text (to constrain its length) or
  32. number. To skip this constraint, just set a maximum smaller than the minimum.
  33. *Properties* always belong to a template, and as such, to a model.
  34. *Properties* define the data type (text, number, yes/no...), and when the type
  35. is "Selection", then you can define what *options* are available.
  36. I.e., the "Smart partners" *template* has the following *properties*:
  37. - Name of his/her teacher
  38. - Amount of people that hates him/her for being so smart
  39. - Average note on all subjects
  40. - Does he/she believe he/she is the smartest person on earth?
  41. - What weaknesses does he/she have?
  42. When you set that template to any partner, you will then be able to fill these
  43. *properties* with *values*.
  44. Categories
  45. ----------
  46. *Properties* can also belong to a *category*, which allows you to sort them in
  47. a logical way, and makes further development easier.
  48. For example, the ``website_sale_custom_info`` addon uses these to display a
  49. technical datasheet per product in your online shop, sorted and separated by
  50. category.
  51. You are not required to give a *category* to every *property*.
  52. Options
  53. -------
  54. When a *property*'s type is "Selection", then you define the *options*
  55. available, so the *value* must be one of these *options*.
  56. I.e., the "What weaknesses does he/she have?" *property* has some options:
  57. - Loves junk food
  58. - Needs videogames
  59. - Huge glasses
  60. The *value* will always be one of these.
  61. Value
  62. -----
  63. When you assign a *template* to a partner, and then you get the *properties* it
  64. should have, you still have to set a *value* for each property.
  65. *Values* can be of different types (whole numbers, constrained selection,
  66. booleans...), depending on how the *property* was defined. However, there is
  67. always the ``value`` field, that is a text string, and converts automatically
  68. to/from the correct type.
  69. Why would I need this?
  70. ~~~~~~~~~~~~~~~~~~~~~~
  71. Imagine you have some partners that are foreign, and that for those partners
  72. you need some extra information that is not needed for others, and you do not
  73. want to fill the partners model with a lot of fields that will be empty most of
  74. the time.
  75. In this case, you could define a *template* called "Foreign partners", which
  76. will be applied to ``res.partner`` objects, and defines some *properties* that
  77. these are expected to have.
  78. Then you could assign that *template* to a partner, and automatically you will
  79. get a subtable of all the properties it should have, with tools to fill their
  80. *values* correctly.
  81. Does this work with any model?
  82. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  83. Yes and no.
  84. Yes, because this is a base module that provides the tools to make this work
  85. with any model.
  86. No, because, although the tools are provided, they are only applied to the
  87. ``res.partner`` model. This is by design, because different models can have
  88. different needs, and we don't want to depend on every possible model.
  89. So, if you want to apply this to other models, you will have to develop a
  90. little additional addon that depends on this one. If you are a developer, refer
  91. to the *Development* section below.
  92. Installation
  93. ============
  94. This module serves as a base for other modules that implement this behavior in
  95. concrete models.
  96. This module is a technical dependency and is to be installed in parallel to
  97. other modules.
  98. Configuration
  99. =============
  100. To enable the main *Custom Info* menu:
  101. #. Enable *Settings > General Settings > Manage custom information*.
  102. To enable partner's custom info tab:
  103. #. Enable *Settings > General Settings > Edit custom information in partners*.
  104. Usage
  105. =====
  106. This module defines *Custom Info Templates* that define what properties are
  107. expected for a given record.
  108. To define a template, you need to:
  109. * Go to *Custom Info > Templates*.
  110. * Create one.
  111. * Add some *Properties* to it.
  112. All database records with that template enabled will automatically fill those
  113. properties.
  114. To manage the properties, you need to:
  115. * Go to *Custom Info > Properties*.
  116. To manage the property categories, you need to:
  117. * Go to *Custom Info > Categories*.
  118. Some properties can have a number of options to choose, to manage them:
  119. * Go to *Custom Info > Options*.
  120. To manage their values, you need to:
  121. * Go to *Custom Info > Values*.
  122. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
  123. :alt: Try me on Runbot
  124. :target: https://runbot.odoo-community.org/runbot/135/9.0
  125. Development
  126. ===========
  127. To create a module that supports custom information, just depend on this module
  128. and inherit from the ``custom.info`` model.
  129. See an example in the ``product_custom_info`` addon.
  130. Known issues / Roadmap
  131. ======================
  132. * Custom properties cannot be shared among templates.
  133. * You get an error if you press *Save & New* when setting property values in
  134. partner form.
  135. * `There seems to be a bug in the web client that makes subviews appear empty
  136. after an onchange
  137. <https://github.com/OCA/server-tools/pull/492#issuecomment-237594285>`_.
  138. This module includes a workaround for that, but the bug should be fixed and
  139. the workaround removed.
  140. Bug Tracker
  141. ===========
  142. Bugs are tracked on `GitHub Issues
  143. <https://github.com/OCA/product-attribute/issues>`_. In case of trouble, please
  144. check there if your issue has already been reported. If you spotted it first,
  145. help us smashing it by providing a detailed and welcomed feedback.
  146. Credits
  147. =======
  148. Contributors
  149. ------------
  150. * Rafael Blasco <rafabn@antiun.com>
  151. * Carlos Dauden <carlos@incaser.es>
  152. * Sergio Teruel <sergio@incaser.es>
  153. * Jairo Llopis <yajo.sk8@gmail.com>
  154. Maintainer
  155. ----------
  156. .. image:: https://odoo-community.org/logo.png
  157. :alt: Odoo Community Association
  158. :target: https://odoo-community.org
  159. This module is maintained by the OCA.
  160. OCA, or the Odoo Community Association, is a nonprofit organization whose
  161. mission is to support the collaborative development of Odoo features and
  162. promote its widespread use.
  163. To contribute to this module, please visit https://odoo-community.org.