Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] base_multi_company #458

Merged
merged 77 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
a31ee55
[ADD] base_multi_company: Create new module
lasley Apr 20, 2017
c98d9e4
10.0 base multi company lmi (#1)
lmignon May 5, 2017
8d63509
PR fixes (+1 squashed commit)
lasley May 5, 2017
4f89fdd
[FIX] base_multi_company: Allow child_of/parent_of operator into sear…
lmignon May 10, 2017
21b6b93
- Remove depends as company_id is not stored anymore
May 10, 2017
dbdc22a
OCA Transbot updated translations from Transifex
oca-transbot May 20, 2017
a3822f9
[IMP] base_multi_company: Improve ReadMe
lasley Sep 9, 2017
7a9557b
[MIG] *_multi_company: OpenUpgrade migration scripts
pedrobaeza Dec 15, 2017
3b2b6d7
Edit unit test + fix bug
acsonefho Mar 27, 2018
6bd3602
[FIX] Insert in company_ids relation's table only ids of records that…
SimoRubi Apr 21, 2018
07458c3
[UPD] Update base_multi_company.pot
oca-travis Jun 23, 2018
861abbc
Translated using Weblate (Portuguese)
pedrocs-exo Jul 26, 2018
03c2fa9
[MIG] base_multi_company: Migration to 11.0
rodrigets Jul 31, 2018
bd10d00
[UPD] Update base_multi_company.pot
oca-travis Aug 2, 2018
d6c64e6
[FIX] base_multi_company: Fix tests
pedrobaeza Nov 16, 2018
3e470f9
Update translation files
oca-transbot Dec 9, 2018
310f041
[FIX] base_multi_company: Fix several things:
pedrobaeza Jan 17, 2019
fbc7b98
[UPD] Update base_multi_company.pot
oca-travis Jan 17, 2019
0966466
Update translation files
oca-transbot Jan 17, 2019
48b47c3
[MIG] partner_multi_company: Finish migration to 11.0
pedrobaeza Jan 19, 2019
248899b
[UPD] Update base_multi_company.pot
oca-travis Jan 19, 2019
63e6cd1
Update translation files
oca-transbot Jan 19, 2019
7d9efee
Migrate base_multi_company to v12
florian-dacosta May 4, 2019
bb58474
Improve performance adding a techical field used in ir rules
florian-dacosta May 4, 2019
eca0641
fixup! Migrate base_multi_company to v12
florian-dacosta Jul 6, 2019
368a54b
[UPD] Update base_multi_company.pot
oca-travis Sep 20, 2019
a1cb908
[UPD] README.rst
OCA-git-bot Sep 20, 2019
1df1260
Update translation files
oca-transbot Sep 23, 2019
2f63afd
Added translation using Weblate (Chinese (Simplified))
liweijie0812 Sep 23, 2019
86828ce
Translated using Weblate (Chinese (Simplified))
liweijie0812 Sep 23, 2019
b437dab
Translated using Weblate (Chinese (Simplified))
liweijie0812 Sep 23, 2019
31a494c
[FIX] base_multi_company
max3903 Nov 7, 2019
4941539
[UPD] README.rst
OCA-git-bot Nov 7, 2019
45b3d3d
Translated using Weblate (Croatian)
badbole Nov 14, 2019
65cf5ce
Translated using Weblate (Portuguese (Brazil))
Nov 24, 2019
283cbaa
Translated using Weblate (Portuguese)
alvarorib Feb 22, 2020
1a01786
[IMP] Turn Off IR Rule For Test
osi-scampbell Feb 27, 2020
1f31e56
[IMP] Flake8
osi-scampbell Feb 27, 2020
649a68e
[IMP] base_multi_company: black, isort
JoanSForgeFlow Mar 25, 2020
c98cab6
[MIG] base_multi_company: Migration to 13.0
JoanSForgeFlow Mar 25, 2020
5d47c1e
[UPD] Update base_multi_company.pot
oca-travis Apr 7, 2020
9863f5d
[UPD] README.rst
OCA-git-bot Apr 7, 2020
53b6f70
[IMP] base_multi_company: Pre-commit does this
pedrobaeza Jun 3, 2020
c811eaa
Update translation files
oca-transbot Jun 3, 2020
2094bc4
[13.0][FIX] base_multi_company: incompatibility error
LoisRForgeFlow Jul 6, 2020
0980bf3
base_multi_company 13.0.1.0.1
OCA-git-bot Jul 7, 2020
d8fb813
[13.0][FIX] base_multi_company: consider force_company context key.
LoisRForgeFlow Jul 17, 2020
6898c22
base_multi_company 13.0.1.0.2
OCA-git-bot Jul 20, 2020
9d355d6
Added translation using Weblate (Spanish (Argentina))
ibuioli Oct 25, 2020
66646c5
Translated using Weblate (Spanish (Argentina))
ibuioli Oct 25, 2020
13ea7dd
[13.0][FIX] base_multi_company: name_search
LoisRForgeFlow Oct 26, 2020
ab25a84
Translated using Weblate (Spanish)
anasuarez1 Mar 9, 2021
997d889
[IMP] base_multi_company: black, isort, prettier
rousseldenis Mar 9, 2021
d1bfa02
[14.0][MIG] base_multi_company
rousseldenis Mar 9, 2021
a84b5fa
[14.0][IMP] Add test for name_search()
rousseldenis Mar 10, 2021
f2ed97a
[14.0][FIX] base_multi_company: Use [] for domain on company_ids
rousseldenis Jul 5, 2021
5e145c1
[14.0][FIX] base_multi_company: Restore False for searches
rousseldenis Jul 5, 2021
9f650d7
[14.0][IMP] base_multi_company: Add hook for new field
rousseldenis Jul 5, 2021
73027d7
[14.0][FIX] base_multi_company: Compute no_company_ids as sudo
rousseldenis Jul 6, 2021
265bb4a
[14.0][IMP] base_multi_company: Avoid warnings in logs
rousseldenis Jul 6, 2021
606c941
[14.0][IMP] base_multi_company: Allow non-aware multi-company behaviours
rousseldenis Oct 14, 2021
b7b6db6
[14.0][IMP] base_multi_company: Add depends_context for env.company
rousseldenis Oct 15, 2021
93bba54
[FIX] base_multi_company: Make company_id writeable again
pedrobaeza Sep 23, 2021
6750afd
[14.0][IMP] base_multi_company: Avoid one recordset update + add tests
rousseldenis Mar 21, 2022
2562b8c
[14.0][IMP] base_multi_company: Improve module README
rousseldenis Mar 24, 2022
446e6b5
[UPD] Update base_multi_company.pot
oca-travis Mar 24, 2022
99a625a
[UPD] README.rst
OCA-git-bot Mar 24, 2022
130ba97
base_multi_company 14.0.1.1.1
OCA-git-bot Mar 24, 2022
5c47215
[IMP] base_multi_company: black, isort, prettier
JasminSForgeFlow Mar 30, 2022
1ffc8e6
[MIG] base_multi_company: Migration to 15.0
JasminSForgeFlow Mar 30, 2022
23c9566
[UPD] Update base_multi_company.pot
Apr 13, 2022
c87ea15
[UPD] README.rst
OCA-git-bot Apr 13, 2022
6423537
[FIX] base_multi_company: remove external dependency
LoisRForgeFlow Dec 15, 2022
9a4958f
base_multi_company 15.0.1.0.1
OCA-git-bot Dec 15, 2022
91088f1
[MIG] base_multi_company: Migration to 16.0
prabakaran04 Mar 13, 2023
7b0df0d
[ADD] test-requirements.txt
prabakaran04 Apr 5, 2023
0de9fd5
[FIX] base_multi_company: Proper _check_company when multiple compani…
pedrobaeza Nov 28, 2023
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
108 changes: 108 additions & 0 deletions base_multi_company/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
==================
Multi Company Base
==================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/15.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-15-0/multi-company-15-0-base_multi_company
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/133/15.0
:alt: Try me on Runbot

|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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/multi-company/issues/new?body=module:%20base_multi_company%0Aversion:%2015.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>

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/15.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": "16.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"],
}
76 changes: 76 additions & 0 deletions base_multi_company/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# 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
from odoo import SUPERUSER_ID, api

__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.
"""
rule = env.ref(rule_ref)
if not rule: # safeguard if it's deleted
return
rule.write(
{
"active": True,
"domain_force": ("[('company_ids', 'in', [False] + company_ids)]"),
}
)


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

Args:
cr (Cursor): Database cursor 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.
"""
env = api.Environment(cr, SUPERUSER_ID, {})
set_security_rule(env, rule_ref)
# 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 = """
INSERT INTO {}
({}, {})
SELECT id, company_id FROM {} WHERE company_id IS NOT NULL
ON CONFLICT DO NOTHING
""".format(
table_name,
column1,
column2,
model._table,
)
env.cr.execute(SQL)


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

Args:
cr (Cursor): Database cursor to use for operation.
rule_ref (string): XML ID of security rule to remove the
`domain_force` from.
"""
env = api.Environment(cr, SUPERUSER_ID, {})
# Change access rule
rule = env.ref(rule_ref)
rule.write(
{
"active": False,
"domain_force": (" [('company_id', 'in', [False, user.company_id.id])]"),
}
)
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 15.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.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 ""

#. module: base_multi_company
#: model:ir.model.fields,field_description:base_multi_company.field_multi_company_abstract__no_company_ids
msgid "No Companies"
msgstr ""
50 changes: 50 additions & 0 deletions base_multi_company/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 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: 2021-03-09 10:45+0000\n"
"Last-Translator: Ana Suárez <ana.suarez@qubiq.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.3.2\n"

#. 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.fields,field_description:base_multi_company.field_multi_company_abstract__display_name
msgid "Display Name"
msgstr "Nombre mostrado"

#. module: base_multi_company
#: model:ir.model.fields,field_description:base_multi_company.field_multi_company_abstract__id
msgid "ID"
msgstr "ID"

#. module: base_multi_company
#: model:ir.model.fields,field_description:base_multi_company.field_multi_company_abstract____last_update
msgid "Last Modified on"
msgstr "Última modificación el"

#. module: base_multi_company
#: model:ir.model,name:base_multi_company.model_multi_company_abstract
msgid "Multi-Company Abstract"
msgstr "Resumen Multi-Compañía"
47 changes: 47 additions & 0 deletions base_multi_company/i18n/es_AR.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 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: 2020-10-26 01:08+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 3.10\n"

#. 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.fields,field_description:base_multi_company.field_multi_company_abstract__display_name
msgid "Display Name"
msgstr "Mostrar Nombre"

#. module: base_multi_company
#: model:ir.model.fields,field_description:base_multi_company.field_multi_company_abstract__id
msgid "ID"
msgstr "ID"

#. module: base_multi_company
#: model:ir.model.fields,field_description:base_multi_company.field_multi_company_abstract____last_update
msgid "Last Modified on"
msgstr "Última Modificación el"

#. 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"
49 changes: 49 additions & 0 deletions base_multi_company/i18n/fr.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: 2017-12-16 02:03+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n"
"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n"
"Language: fr\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"

#. module: base_multi_company
#: model:ir.model.fields,field_description:base_multi_company.field_multi_company_abstract__company_ids
msgid "Companies"
msgstr "Sociétés"

#. 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.fields,field_description:base_multi_company.field_multi_company_abstract__display_name
msgid "Display Name"
msgstr ""

#. module: base_multi_company
#: model:ir.model.fields,field_description:base_multi_company.field_multi_company_abstract__id
msgid "ID"
msgstr ""

#. module: base_multi_company
#: model:ir.model.fields,field_description:base_multi_company.field_multi_company_abstract____last_update
msgid "Last Modified on"
msgstr ""

#. module: base_multi_company
#: model:ir.model,name:base_multi_company.model_multi_company_abstract
msgid "Multi-Company Abstract"
msgstr ""
Loading
Loading