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