Metadata-Version: 2.1
Name: odoo12-addon-base-multi-company
Version: 12.0.1.0.1.99.dev13
Summary: Provides a base for adding multi-company support to models.
Home-page: https://github.com/OCA/multi-company
Author: LasLabs, Tecnativa, Odoo Community Association (OCA)
Author-email: support@odoo-community.org
License: LGPL-3
Platform: UNKNOWN
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 12.0
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
Classifier: Development Status :: 5 - Production/Stable
Requires-Python: >=3.5
Requires-Dist: odoo <12.1dev,>=12.0a

==================
Multi Company Base
==================

.. 
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! This file is generated by oca-gen-addon-readme !!
   !! changes will be overwritten.                   !!
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! source digest: sha256:c331f13605278d7ceb1c227857b628e5c438b23b413acad890b3ff218691b978
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
    :target: https://odoo-community.org/page/development-status
    :alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
    :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
    :alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmulti--company-lightgray.png?logo=github
    :target: https://github.com/OCA/multi-company/tree/12.0/base_multi_company
    :alt: OCA/multi-company
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
    :target: https://translation.odoo-community.org/projects/multi-company-12-0/multi-company-12-0-base_multi_company
    :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
    :target: https://runboat.odoo-community.org/builds?repo=OCA/multi-company&target_branch=12.0
    :alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

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.

**Table of contents**

.. contents::
   :local:

Usage
=====

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

.. code-block:: python

   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.

.. code-block:: 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',
       )

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 <https://github.com/OCA/multi-company/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/multi-company/issues/new?body=module:%20base_multi_company%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* LasLabs
* Tecnativa

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>
* Florian da Costa <florian.dacosta@akretion.com>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
   :alt: Odoo Community Association
   :target: https://odoo-community.org

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.

.. |maintainer-pedrobaeza| image:: https://github.com/pedrobaeza.png?size=40px
    :target: https://github.com/pedrobaeza
    :alt: pedrobaeza

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-pedrobaeza| 

This module is part of the `OCA/multi-company <https://github.com/OCA/multi-company/tree/12.0/base_multi_company>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.


