Provides a base for adding multi-company support to models.
Project description
Multi Company Base
This module provides an abstract model to be inherited by models that need to implement multi-company functionality.
No direct functionality is provided by this module.
Implementation
Multi Company Abstract
The multi.company.abstract model is meant to be inherited by any model that wants to implement multi-company functionality. The logic does not require a pre-existing company field on the inheriting model, but will not be affected if one does exist.
When inheriting the multi.company.abstract model, you must take care that it is the first model listed in the _inherit array
class ProductTemplate(models.Model):
_inherit = ["multi.company.abstract", "product.template"]
_name = "product.template"
_description = "Product Template (Multi-Company)"
The following fields are provided by multi.company.abstract:
company_ids - All of the companies that this record belongs to. This is a special res.company.assignment view, which allows for the circumvention of standard cross-company security policies. These policies would normally restrict a user from seeing another company unless it is currently operating under that company. Be aware of apples to oranges issues when comparing the records from this field against actual company records.
company_id - Passes through a singleton company based on the current user, and the allowed companies for the record.
Hooks
A generic post_init_hook and uninstall_hook is provided, which will alter a pre-existing single-company security rule to be multi-company aware.
These hooks will unfortunately not work in every circumstance, but they cut out significant boilerplate when relevant.
import logging
_logger = logging.getLogger(__name__)
try:
from odoo.addons.base_multi_company import hooks
except ImportError:
_logger.info('Cannot find `base_multi_company` module in addons path.')
def post_init_hook(cr, registry):
hooks.post_init_hook(
cr,
'product.product_comp_rule',
'product.template',
)
def uninstall_hook(cr, registry):
hooks.uninstall_hook(
cr,
'product.product_comp_rule',
)
A module implementing these hooks would need to first identify the proper rule for the record (product.product_comp_rule in the above example).
Bug Tracker
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smash it by providing detailed and welcomed feedback.
Credits
Images
Odoo Community Association: Icon.
Contributors
Dave Lasley <dave@laslabs.com>
Pedro M. Baeza <pedro.baeza@tecnativa.com>
Laurent Mignon <laurent.mignon@acsone.eu>
Cédric Pigeon <cedric.pigeon@acsone.eu>
Rodrigo Ferreira <rodrigosferreira91@gmail.com>
Maintainer
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
To contribute to this module, please visit http://odoo-community.org.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file odoo11_addon_base_multi_company-11.0.1.0.0.99.dev3-py2.py3-none-any.whl
.
File metadata
- Download URL: odoo11_addon_base_multi_company-11.0.1.0.0.99.dev3-py2.py3-none-any.whl
- Upload date:
- Size: 28.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/30.4.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.5.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91c4ae9421b0b8e3b6b7fca16126dd83dd9f9c73855df81ed42576a5cd3422d0 |
|
MD5 | 2955c14768e19be4a41a92a3f941011c |
|
BLAKE2b-256 | 0d87cb1599cc1c8f588d4fa225600ddf6f3bbddbedff73abd47336284f83736c |