Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
348231f
[ADD] base_multi_company: Create new module
lasley Apr 20, 2017
9a2ae97
10.0 base multi company lmi (#1)
lmignon May 5, 2017
b060d38
PR fixes (+1 squashed commit)
lasley May 5, 2017
9eb0949
[FIX] base_multi_company: Allow child_of/parent_of operator into sear…
lmignon May 10, 2017
31398fa
- Remove depends as company_id is not stored anymore
May 10, 2017
786b0b7
OCA Transbot updated translations from Transifex
oca-transbot May 20, 2017
72380b7
[IMP] base_multi_company: Improve ReadMe
lasley Sep 9, 2017
3c842d6
[MIG] *_multi_company: OpenUpgrade migration scripts
pedrobaeza Dec 15, 2017
0a58a1c
Edit unit test + fix bug
acsonefho Mar 27, 2018
be4337b
[FIX] Insert in company_ids relation's table only ids of records that…
SimoRubi Apr 21, 2018
5503d50
[UPD] Update base_multi_company.pot
oca-travis Jun 23, 2018
9ff3b67
Translated using Weblate (Portuguese)
pedrocs-exo Jul 26, 2018
8ab335c
[MIG] base_multi_company: Migration to 11.0
rodrigets Jul 31, 2018
1add850
[UPD] Update base_multi_company.pot
oca-travis Aug 2, 2018
8c0e33e
[FIX] base_multi_company: Fix tests
pedrobaeza Nov 16, 2018
f6cf4d5
Update translation files
oca-transbot Dec 9, 2018
839216e
[FIX] base_multi_company: Fix several things:
pedrobaeza Jan 17, 2019
1470955
[UPD] Update base_multi_company.pot
oca-travis Jan 17, 2019
e69a5a2
Update translation files
oca-transbot Jan 17, 2019
c06c6d8
[MIG] partner_multi_company: Finish migration to 11.0
pedrobaeza Jan 19, 2019
2072c37
[UPD] Update base_multi_company.pot
oca-travis Jan 19, 2019
12e82d4
Update translation files
oca-transbot Jan 19, 2019
509fbf9
Migrate base_multi_company to v12
florian-dacosta May 4, 2019
ab20207
Improve performance adding a techical field used in ir rules
florian-dacosta May 4, 2019
26eda68
fixup! Migrate base_multi_company to v12
florian-dacosta Jul 6, 2019
bbe85ad
[UPD] Update base_multi_company.pot
oca-travis Sep 20, 2019
c6c44dd
[UPD] README.rst
OCA-git-bot Sep 20, 2019
7c60447
Update translation files
oca-transbot Sep 23, 2019
37f5107
Added translation using Weblate (Chinese (Simplified))
liweijie0812 Sep 23, 2019
f7e83fd
Translated using Weblate (Chinese (Simplified))
liweijie0812 Sep 23, 2019
2069bf0
Translated using Weblate (Chinese (Simplified))
liweijie0812 Sep 23, 2019
a08775d
[FIX] base_multi_company
max3903 Nov 7, 2019
8ebe2f1
[UPD] README.rst
OCA-git-bot Nov 7, 2019
7e19ae5
Translated using Weblate (Croatian)
badbole Nov 14, 2019
9c30bf6
Translated using Weblate (Portuguese (Brazil))
Nov 24, 2019
52c222b
Translated using Weblate (Portuguese)
alvarorib Feb 22, 2020
f4c46fe
[IMP] Turn Off IR Rule For Test
osi-scampbell Feb 27, 2020
258befb
[IMP] Flake8
osi-scampbell Feb 27, 2020
9616b7c
[IMP] base_multi_company: black, isort
JoanSForgeFlow Mar 25, 2020
e993713
[MIG] base_multi_company: Migration to 13.0
JoanSForgeFlow Mar 25, 2020
e56a725
[UPD] Update base_multi_company.pot
oca-travis Apr 7, 2020
d983b0b
[UPD] README.rst
OCA-git-bot Apr 7, 2020
f22fd43
[IMP] base_multi_company: Pre-commit does this
pedrobaeza Jun 3, 2020
6e41b48
Update translation files
oca-transbot Jun 3, 2020
4dc1770
[13.0][FIX] base_multi_company: incompatibility error
LoisRForgeFlow Jul 6, 2020
619483b
base_multi_company 13.0.1.0.1
OCA-git-bot Jul 7, 2020
dfb044d
[13.0][FIX] base_multi_company: consider force_company context key.
LoisRForgeFlow Jul 17, 2020
c82f4e6
base_multi_company 13.0.1.0.2
OCA-git-bot Jul 20, 2020
fda6a0e
Added translation using Weblate (Spanish (Argentina))
ibuioli Oct 25, 2020
1c04cd8
Translated using Weblate (Spanish (Argentina))
ibuioli Oct 25, 2020
8955aad
[13.0][FIX] base_multi_company: name_search
LoisRForgeFlow Oct 26, 2020
2e57c65
Translated using Weblate (Spanish)
anasuarez1 Mar 9, 2021
f382763
[IMP] base_multi_company: black, isort, prettier
rousseldenis Mar 9, 2021
c85545b
[14.0][MIG] base_multi_company
rousseldenis Mar 9, 2021
fe61862
[14.0][IMP] Add test for name_search()
rousseldenis Mar 10, 2021
dba88ef
[14.0][FIX] base_multi_company: Use [] for domain on company_ids
rousseldenis Jul 5, 2021
bc10ec3
[14.0][FIX] base_multi_company: Restore False for searches
rousseldenis Jul 5, 2021
3e9075a
[14.0][IMP] base_multi_company: Add hook for new field
rousseldenis Jul 5, 2021
e491819
[14.0][FIX] base_multi_company: Compute no_company_ids as sudo
rousseldenis Jul 6, 2021
0a5f098
[14.0][IMP] base_multi_company: Avoid warnings in logs
rousseldenis Jul 6, 2021
a304db3
[14.0][IMP] base_multi_company: Allow non-aware multi-company behaviours
rousseldenis Oct 14, 2021
9746904
[14.0][IMP] base_multi_company: Add depends_context for env.company
rousseldenis Oct 15, 2021
311f282
[FIX] base_multi_company: Make company_id writeable again
pedrobaeza Sep 23, 2021
a2e2c11
[14.0][IMP] base_multi_company: Avoid one recordset update + add tests
rousseldenis Mar 21, 2022
c2628ef
[14.0][IMP] base_multi_company: Improve module README
rousseldenis Mar 24, 2022
ae1fd62
[UPD] Update base_multi_company.pot
oca-travis Mar 24, 2022
af6f4e4
[UPD] README.rst
OCA-git-bot Mar 24, 2022
2f3d73f
base_multi_company 14.0.1.1.1
OCA-git-bot Mar 24, 2022
3f4efed
[IMP] base_multi_company: black, isort, prettier
JasminSForgeFlow Mar 30, 2022
bce36b3
[MIG] base_multi_company: Migration to 15.0
JasminSForgeFlow Mar 30, 2022
4fda638
[UPD] Update base_multi_company.pot
Apr 13, 2022
192cd01
[UPD] README.rst
OCA-git-bot Apr 13, 2022
f3bf867
[FIX] base_multi_company: remove external dependency
LoisRForgeFlow Dec 15, 2022
3748ecc
base_multi_company 15.0.1.0.1
OCA-git-bot Dec 15, 2022
c1423b5
[MIG] base_multi_company: Migration to 16.0
prabakaran04 Mar 13, 2023
ecf930c
[FIX] base_multi_company: Proper _check_company when multiple compani…
pedrobaeza Nov 28, 2023
33e49cb
[UPD] Update base_multi_company.pot
Dec 5, 2023
7c7ae66
[BOT] post-merge updates
OCA-git-bot Dec 5, 2023
4b40cbc
Update translation files
weblate Dec 5, 2023
c051698
Update translation files
weblate Dec 5, 2023
bbb4b25
[FIX] base_multi_company: apply '_name_search' fix to 'search_read'
renda-dev Dec 4, 2023
1ae9e7b
[BOT] post-merge updates
OCA-git-bot Dec 7, 2023
045b567
Translated using Weblate (Spanish)
Ivorra78 Dec 7, 2023
5aebfb6
Translated using Weblate (Spanish (Argentina))
ibuioli Dec 9, 2023
6d4fb4b
[FIX] base_multi_company: Check multiple companies
SirAionTech Dec 18, 2023
7162f2e
[BOT] post-merge updates
OCA-git-bot Dec 18, 2023
a9f586d
Added translation using Weblate (Italian)
mymage Jan 19, 2024
3356d73
Translated using Weblate (Italian)
mymage Jan 19, 2024
c0e9084
Translated using Weblate (Portuguese (Brazil))
May 20, 2024
ef51038
[IMP] base_multi_company: pre-commit stuff
rven May 21, 2024
37c794e
[MIG] base_multi_company: Migration to 17.0
rven May 21, 2024
5b677fa
[UPD] Update base_multi_company.pot
Jul 25, 2024
868b1c7
[BOT] post-merge updates
OCA-git-bot Jul 25, 2024
80bacf5
Update translation files
weblate Jul 25, 2024
8f00bc4
[FIX] base_multi_company: search with in operator
chienandalu Nov 18, 2024
1742865
[BOT] post-merge updates
OCA-git-bot Nov 20, 2024
bb523c3
[FIX] base_multi_company: support `in False` search operators
yajo Jan 29, 2025
274accd
[BOT] post-merge updates
OCA-git-bot Aug 21, 2025
6a7627e
[IMP] base_multi_company: pre-commit auto fixes
ArnauCForgeFlow Aug 6, 2025
7a4fff6
[MIG] base_multi_company: Migration to 18.0
ArnauCForgeFlow Aug 6, 2025
2b354a8
[UPD] Update base_multi_company.pot
Aug 22, 2025
f8d101b
[BOT] post-merge updates
OCA-git-bot Aug 22, 2025
20a233b
Added translation using Weblate (Turkish)
bo-eska Sep 18, 2025
2b8d1a7
Translated using Weblate (Turkish)
bo-eska Sep 18, 2025
7c4fe5c
[19.0][FIX]pre-commit.
Vandan-Pandeji-SerpentCS Oct 14, 2025
11bb692
[MIG] base_multi_company: Migration to 19.0
Vandan-Pandeji-SerpentCS Oct 14, 2025
c0b5003
[19.0][IMP] base_multi_company: fix access errors and add robustness
astirpe Mar 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions base_multi_company/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

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

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

.. |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/license-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/19.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-19-0/multi-company-19-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=19.0
:alt: Try me on Runboat

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

This module will provide a way to change the way Odoo manages a
'multi-company' implementation.

Abstract
--------

Odoo traditional implementation of multi-company:

- Some models contain a field named Company (company_id) that allows to
set one company or None in order to:

- Limit access to that company if set.
- not limiting access to any company if not set.

This module changes that in order to introduce a finer company access.
e.g.: If you want to give record access to company A and B but not for
C.

This module is not doing anything by its own but provide a transversal
implementation for further ones. e.g.: If you want to implement OCA
multi-company behaviour for products, install also the
'product_multi_company' or 'partner_multi_company' modules.

**Table of contents**

.. contents::
:local:

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:%2019.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
-------

* ACSONE SA/NV
* 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>
- Denis Roussel <denis.roussel@acsone.eu>
- Jairo Llopis (``Moduon <https://www.moduon.team/>``\ \_\_)

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/19.0/base_multi_company>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions base_multi_company/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2017 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from . import models
16 changes: 16 additions & 0 deletions base_multi_company/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2017 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

{
"name": "Multi Company Base",
"summary": "Provides a base for adding multi-company support to models.",
"version": "19.0.1.0.0",
"author": "ACSONE SA/NV, LasLabs, Tecnativa, Odoo Community Association (OCA)",
"category": "base",
"website": "https://github.com/OCA/multi-company",
"license": "LGPL-3",
"installable": True,
"application": False,
"development_status": "Production/Stable",
"maintainers": ["pedrobaeza"],
}
90 changes: 90 additions & 0 deletions base_multi_company/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Copyright 2015-2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2017 LasLabs Inc.
# License LGPL-3 - See http://www.gnu.org/licenses/lgpl-3.0.html
import warnings

__all__ = [
"post_init_hook",
"uninstall_hook",
]


def set_security_rule(env, rule_ref):
"""Set the condition for multi-company in the security rule.

:param: env: Environment
:param: rule_ref: XML-ID of the security rule to change.
"""
warnings.warn(
"This hook is deprecated. Use `fill_company_ids` instead.",
DeprecationWarning,
stacklevel=2,
)
rule = env.ref(rule_ref)
if rule: # safeguard if it's deleted
rule.write(
{
"active": True,
"domain_force": (
"['|', ('company_ids', '=', False),"
" ('company_ids', 'in', company_ids)]"
),
}
)


def post_init_hook(env, rule_ref, model_name):
"""Set the `domain_force` and default `company_ids` to `company_id`.

Args:
env (Environment): Environment to use for operation.
rule_ref (string): XML ID of security rule to write the
`domain_force` from.
model_name (string): Name of Odoo model object to search for
existing records.
"""
set_security_rule(env, rule_ref)
fill_company_ids(env, model_name)


def fill_company_ids(env, model_name):
"""Fill company_ids with company_id values."""
# Copy company values
model = env[model_name]
table_name = model._fields["company_ids"].relation
column1 = model._fields["company_ids"].column1
column2 = model._fields["company_ids"].column2
SQL = f"""
INSERT INTO {table_name}
({column1}, {column2})
SELECT id, company_id FROM {model._table} WHERE company_id IS NOT NULL
ON CONFLICT DO NOTHING
"""
env.cr.execute(SQL)


def uninstall_hook(env, rule_ref):
"""Restore rule to base value.

Args:
env (Environment): Environment to use for operation.
rule_ref (string): XML ID of security rule to remove the
`domain_force` from.
"""
warnings.warn(
"This hook is deprecated.",
DeprecationWarning,
stacklevel=2,
)
# Change access rule
rule = env.ref(rule_ref)
if rule: # safeguard if it's deleted
rule.write(
{
"active": False,
"domain_force": (
" ['|', ('company_ids', '=', False),"
" ('company_ids', 'in', company_ids)]"
),
}
)
34 changes: 34 additions & 0 deletions base_multi_company/i18n/base_multi_company.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_multi_company
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: base_multi_company
#: model:ir.model,name:base_multi_company.model_base
msgid "Base"
msgstr ""

#. module: base_multi_company
#: model:ir.model.fields,field_description:base_multi_company.field_multi_company_abstract__company_ids
msgid "Companies"
msgstr ""

#. module: base_multi_company
#: model:ir.model.fields,field_description:base_multi_company.field_multi_company_abstract__company_id
msgid "Company"
msgstr ""

#. module: base_multi_company
#: model:ir.model,name:base_multi_company.model_multi_company_abstract
msgid "Multi-Company Abstract"
msgstr ""
49 changes: 49 additions & 0 deletions base_multi_company/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_multi_company
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-12-16 02:03+0000\n"
"PO-Revision-Date: 2023-12-07 18:35+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: base_multi_company
#: model:ir.model,name:base_multi_company.model_base
msgid "Base"
msgstr "Base"

#. module: base_multi_company
#: model:ir.model.fields,field_description:base_multi_company.field_multi_company_abstract__company_ids
msgid "Companies"
msgstr "Compañías"

#. module: base_multi_company
#: model:ir.model.fields,field_description:base_multi_company.field_multi_company_abstract__company_id
msgid "Company"
msgstr "Compañía"

#. module: base_multi_company
#: model:ir.model,name:base_multi_company.model_multi_company_abstract
msgid "Multi-Company Abstract"
msgstr "Resumen Multi-Compañía"

#~ msgid "Display Name"
#~ msgstr "Nombre mostrado"

#~ msgid "ID"
#~ msgstr "ID"

#~ msgid "Last Modified on"
#~ msgstr "Última modificación el"
46 changes: 46 additions & 0 deletions base_multi_company/i18n/es_AR.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_multi_company
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-12-09 23:47+0000\n"
"Last-Translator: Ignacio Buioli <ibuioli@gmail.com>\n"
"Language-Team: none\n"
"Language: es_AR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: base_multi_company
#: model:ir.model,name:base_multi_company.model_base
msgid "Base"
msgstr "Base"

#. module: base_multi_company
#: model:ir.model.fields,field_description:base_multi_company.field_multi_company_abstract__company_ids
msgid "Companies"
msgstr "Compañías"

#. module: base_multi_company
#: model:ir.model.fields,field_description:base_multi_company.field_multi_company_abstract__company_id
msgid "Company"
msgstr "Compañía"

#. module: base_multi_company
#: model:ir.model,name:base_multi_company.model_multi_company_abstract
msgid "Multi-Company Abstract"
msgstr "Resumen de Multi-Compañía"

#~ msgid "Display Name"
#~ msgstr "Mostrar Nombre"

#~ msgid "ID"
#~ msgstr "ID"

#~ msgid "Last Modified on"
#~ msgstr "Última Modificación el"
Loading
Loading