Friday, October 11, 2019
1 change · master
New functionality added to Odoo
Adds a non-production sample module that documents recommended practices for handling records across multiple companies. It helps teams understand how to reduce data consistency issues in multi-company setups, but is intended as reference material rather than a user-facing feature.
Original PR description
Purpose ====== This multi-company sample module illustrates several coding principles that should be respected so that errors are minimized when users work in a multi-company environment. It show…
Purpose ====== This multi-company sample module illustrates several coding principles that should be respected so that errors are minimized when users work in a multi-company environment. It show several principles that should be shared accross most business flows: - sanity checks for consistency regarding relationnal fields that belong to other companies are done at every step of the business flow (and not through constraints) - models have coherent multi-company ir.rules - m2o fields towards company records are used as the master information holder when setting domains on relational fields that target models that may be company-restricted; they have sensible defaults depending on the expected usage of the model - line-type models whose company field is related on their parent should always store the related field to allow correct filtering - models should prevent changing the company on a record if it could break business flows for other users of the system - the 'force_company' context key is always set during company-sensitive CRUD operations since company-dependent fields must be read with the correct context to avoid faulty values These are guidelines and designed to brought attention to recurring problems when dealing with multi-company and that may get worse starting with Odoo 13 since multi-company has gotten a lot more permissive. These are not *laws* and you should obviously think intensely about how this applies to your module/flow. NOTE: this PR is not meant to be merged at any point, but should be used as a reference for the future doc and for the internal discussion regarding these guidelines. External comments are somewhat welcome if you find this, however please do not expect a lengthy discussion and debate - more like explanations, corrections of stuff that I may have gotten wrong and discussion of possible edge cases. Thx. Quid? ===== Interesting suggestions/questions raised during internal discussions - should we batch all multi methods per company? (sle) - should we raise if the context does not contain `force_company` when reading an `ìr.property`? (rim) Task 2041512