Search 1.9 billion lines of Odoo code on GitHub

base_multi_company

Author: LasLabs, Tecnativa, Odoo Community Association (OCA)
License: LGPL-3
Branch: master
Repository: sematicshood/flectra
Languages: PO File (193, 43.5%), and Python (251, 56.5%)

<a class="reference external image-reference" href="https://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-lgpl--3-blue.png" /></a> <a name="multi-company-base"></a> <h2>Multi Company Base</h2> <p>This module provides an abstract model to be inherited by models that need to implement multi-company functionality.</p> <p>No direct functionality is provided by this module.</p> <a name="implementation"></a> <h3>Implementation</h3> <a name="multi-company-abstract"></a> <h4>Multi Company Abstract</h4> <p>The <cite>multi.company.abstract</cite> 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.</p> <p>When inheriting the <cite>multi.company.abstract</cite> model, you must take care that it is the first model listed in the <cite>_inherit</cite> array</p> <pre> <code lang="python">class ProductTemplate(models.Model): _inherit = [&quot;multi.company.abstract&quot;, &quot;product.template&quot;] _name = &quot;product.template&quot; _description = &quot;Product Template (Multi-Company)&quot;</code> </pre> <p>The following fields are provided by <cite>multi.company.abstract</cite>:</p> <ul class="simple"> <li><cite>company_ids</cite> - All of the companies that this record belongs to. This is a special <cite>res.company.assignment</cite> 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.</li> <li><cite>company_id</cite> - Passes through a singleton company based on the current user, and the allowed companies for the record.</li> </ul> <a name="hooks"></a> <h4>Hooks</h4> <p>A generic <cite>post_init_hook</cite> and <cite>uninstall_hook</cite> is provided, which will alter a pre-existing single-company security rule to be multi-company aware.</p> <p>These hooks will unfortunately not work in every circumstance, but they cut out significant boilerplate when relevant.</p> <pre> <code lang="python">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', )</code> </pre> <p>A module implementing these hooks would need to first identify the proper rule for the record (<cite>product.product_comp_rule</cite> in the above example).</p> <a class="reference external image-reference" href="https://runbot.odoo-community.org/runbot/133/11.0"><img alt="Try me on Runbot" src="https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas" /></a> <a name="bug-tracker"></a> <h3>Bug Tracker</h3> <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/multi-company/issues">GitHub Issues</a>. 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.</p> <a name="credits"></a> <h3>Credits</h3> <a name="images"></a> <h4>Images</h4> <ul class="simple"> <li>Odoo Community Association: <a class="reference external" href="https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg">Icon</a>.</li> </ul> <a name="contributors"></a> <h4>Contributors</h4> <ul class="simple"> <li>Dave Lasley &lt;<a class="reference external" href="mailto:dave&#64;laslabs.com">dave&#64;laslabs.com</a>&gt;</li> <li>Pedro M. Baeza &lt;<a class="reference external" href="mailto:pedro.baeza&#64;tecnativa.com">pedro.baeza&#64;tecnativa.com</a>&gt;</li> <li>Laurent Mignon &lt;<a class="reference external" href="mailto:laurent.mignon&#64;acsone.eu">laurent.mignon&#64;acsone.eu</a>&gt;</li> <li>Cédric Pigeon &lt;<a class="reference external" href="mailto:cedric.pigeon&#64;acsone.eu">cedric.pigeon&#64;acsone.eu</a>&gt;</li> <li>Rodrigo Ferreira &lt;<a class="reference external" href="mailto:rodrigosferreira91&#64;gmail.com">rodrigosferreira91&#64;gmail.com</a>&gt;</li> </ul> <a name="maintainer"></a> <h4>Maintainer</h4> <a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> <p>This module is maintained by the OCA.</p> <p>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.</p> <p>To contribute to this module, please visit <a class="reference external" href="http://odoo-community.org">http://odoo-community.org</a>.</p>