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

[15.0] [MIG] base_multi_company #347

Merged
merged 70 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
b23ee66
[ADD] base_multi_company: Create new module
lasley Apr 20, 2017
58ac94d
10.0 base multi company lmi (#1)
lmignon May 5, 2017
4bc16f3
PR fixes (+1 squashed commit)
lasley May 5, 2017
3f33eaa
[FIX] base_multi_company: Allow child_of/parent_of operator into sear…
lmignon May 10, 2017
36a6d39
- Remove depends as company_id is not stored anymore
May 10, 2017
aaa4866
OCA Transbot updated translations from Transifex
oca-transbot May 20, 2017
7188cad
[IMP] base_multi_company: Improve ReadMe
lasley Sep 9, 2017
157698b
[MIG] *_multi_company: OpenUpgrade migration scripts
pedrobaeza Dec 15, 2017
801873e
Edit unit test + fix bug
acsonefho Mar 27, 2018
6e35cc6
[FIX] Insert in company_ids relation's table only ids of records that…
SimoRubi Apr 21, 2018
3dda1d1
[UPD] Update base_multi_company.pot
oca-travis Jun 23, 2018
65118f8
Translated using Weblate (Portuguese)
pedrocs-exo Jul 26, 2018
74c3a4b
[MIG] base_multi_company: Migration to 11.0
rodrigets Jul 31, 2018
018004c
[UPD] Update base_multi_company.pot
oca-travis Aug 2, 2018
97d5275
[FIX] base_multi_company: Fix tests
pedrobaeza Nov 16, 2018
a6fd5f0
Update translation files
oca-transbot Dec 9, 2018
9609bc0
[FIX] base_multi_company: Fix several things:
pedrobaeza Jan 17, 2019
ca3f4b3
[UPD] Update base_multi_company.pot
oca-travis Jan 17, 2019
e6a4e6b
Update translation files
oca-transbot Jan 17, 2019
a53b602
[MIG] partner_multi_company: Finish migration to 11.0
pedrobaeza Jan 19, 2019
c4b228f
[UPD] Update base_multi_company.pot
oca-travis Jan 19, 2019
cadeb4c
Update translation files
oca-transbot Jan 19, 2019
f929468
Migrate base_multi_company to v12
florian-dacosta May 4, 2019
a9007b7
Improve performance adding a techical field used in ir rules
florian-dacosta May 4, 2019
f30e49d
fixup! Migrate base_multi_company to v12
florian-dacosta Jul 6, 2019
97b563d
[UPD] Update base_multi_company.pot
oca-travis Sep 20, 2019
aad9d74
[UPD] README.rst
OCA-git-bot Sep 20, 2019
8b0b74e
Update translation files
oca-transbot Sep 23, 2019
014e51b
Added translation using Weblate (Chinese (Simplified))
liweijie0812 Sep 23, 2019
31459f5
Translated using Weblate (Chinese (Simplified))
liweijie0812 Sep 23, 2019
55ccc82
Translated using Weblate (Chinese (Simplified))
liweijie0812 Sep 23, 2019
8a98d35
[FIX] base_multi_company
max3903 Nov 7, 2019
8bd8363
[UPD] README.rst
OCA-git-bot Nov 7, 2019
89f16e5
Translated using Weblate (Croatian)
badbole Nov 14, 2019
56ba795
Translated using Weblate (Portuguese (Brazil))
Nov 24, 2019
b867297
Translated using Weblate (Portuguese)
alvarorib Feb 22, 2020
f41572d
[IMP] Turn Off IR Rule For Test
osi-scampbell Feb 27, 2020
588147a
[IMP] Flake8
osi-scampbell Feb 27, 2020
16eb0ee
[IMP] base_multi_company: black, isort
JoanSForgeFlow Mar 25, 2020
ab1a9a7
[MIG] base_multi_company: Migration to 13.0
JoanSForgeFlow Mar 25, 2020
06e30ca
[UPD] Update base_multi_company.pot
oca-travis Apr 7, 2020
7c96ecc
[UPD] README.rst
OCA-git-bot Apr 7, 2020
d6ab693
[IMP] base_multi_company: Pre-commit does this
pedrobaeza Jun 3, 2020
de27daf
Update translation files
oca-transbot Jun 3, 2020
468594b
[13.0][FIX] base_multi_company: incompatibility error
LoisRForgeFlow Jul 6, 2020
e733ba6
base_multi_company 13.0.1.0.1
OCA-git-bot Jul 7, 2020
7ec79dd
[13.0][FIX] base_multi_company: consider force_company context key.
LoisRForgeFlow Jul 17, 2020
ca8347d
base_multi_company 13.0.1.0.2
OCA-git-bot Jul 20, 2020
32f8b6e
Added translation using Weblate (Spanish (Argentina))
ibuioli Oct 25, 2020
e17c18f
Translated using Weblate (Spanish (Argentina))
ibuioli Oct 25, 2020
db76c15
[13.0][FIX] base_multi_company: name_search
LoisRForgeFlow Oct 26, 2020
8730b02
Translated using Weblate (Spanish)
anasuarez1 Mar 9, 2021
e6a561c
[IMP] base_multi_company: black, isort, prettier
rousseldenis Mar 9, 2021
5af97bf
[14.0][MIG] base_multi_company
rousseldenis Mar 9, 2021
23f6580
[14.0][IMP] Add test for name_search()
rousseldenis Mar 10, 2021
7ea8a66
[14.0][FIX] base_multi_company: Use [] for domain on company_ids
rousseldenis Jul 5, 2021
2d6c329
[14.0][FIX] base_multi_company: Restore False for searches
rousseldenis Jul 5, 2021
1fd5bea
[14.0][IMP] base_multi_company: Add hook for new field
rousseldenis Jul 5, 2021
4b0d65d
[14.0][FIX] base_multi_company: Compute no_company_ids as sudo
rousseldenis Jul 6, 2021
849e926
[14.0][IMP] base_multi_company: Avoid warnings in logs
rousseldenis Jul 6, 2021
5cf0638
[14.0][IMP] base_multi_company: Allow non-aware multi-company behaviours
rousseldenis Oct 14, 2021
eb94286
[14.0][IMP] base_multi_company: Add depends_context for env.company
rousseldenis Oct 15, 2021
e64488a
[FIX] base_multi_company: Make company_id writeable again
pedrobaeza Sep 23, 2021
f0d0f12
[14.0][IMP] base_multi_company: Avoid one recordset update + add tests
rousseldenis Mar 21, 2022
5bfa662
[14.0][IMP] base_multi_company: Improve module README
rousseldenis Mar 24, 2022
52b33df
[UPD] Update base_multi_company.pot
oca-travis Mar 24, 2022
0f76833
[UPD] README.rst
OCA-git-bot Mar 24, 2022
d00db6b
base_multi_company 14.0.1.1.1
OCA-git-bot Mar 24, 2022
893cc27
[IMP] base_multi_company: black, isort, prettier
JasminSForgeFlow Mar 30, 2022
0662175
[MIG] base_multi_company: Migration to 15.0
JasminSForgeFlow Mar 30, 2022
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:/OCA/multi-company/tree/14.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-14-0/multi-company-14-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/14.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:/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:/OCA/multi-company/issues/new?body=module:%20base_multi_company%0Aversion:%2014.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 <[email protected]>
* Pedro M. Baeza <[email protected]>
* Laurent Mignon <[email protected]>
* Cédric Pigeon <[email protected]>
* Rodrigo Ferreira <[email protected]>
* Florian da Costa <[email protected]>
* Denis Roussel <[email protected]>

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:/pedrobaeza.png?size=40px
:target: https:/pedrobaeza
:alt: pedrobaeza

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

|maintainer-pedrobaeza|

This module is part of the `OCA/multi-company <https:/OCA/multi-company/tree/14.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
17 changes: 17 additions & 0 deletions base_multi_company/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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": "15.0.1.0.0",
"author": "ACSONE SA/NV, LasLabs, Tecnativa, Odoo Community Association (OCA)",
"category": "base",
"website": "https:/OCA/multi-company",
"license": "LGPL-3",
"installable": True,
"application": False,
"development_status": "Production/Stable",
"maintainers": ["pedrobaeza"],
"external_dependencies": {"python": ["odoo-test-helper"]},
}
83 changes: 83 additions & 0 deletions base_multi_company/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Copyright 2015-2016 Pedro M. Baeza <[email protected]>
# 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": (
"['|', ('no_company_ids', '=', True), ('company_ids', "
"'in', 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.
"""
with api.Environment.manage():
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
""".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.
"""
with api.Environment.manage():
env = api.Environment(cr, SUPERUSER_ID, {})
# Change access rule
rule = env.ref(rule_ref)
rule.write(
{
"active": False,
"domain_force": (
" ['|', ('company_id', '=', user.company_id.id),"
" ('company_id', '=', False)]"
),
}
)
49 changes: 49 additions & 0 deletions base_multi_company/i18n/base_multi_company.pot
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
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.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.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 ""

#. 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 <[email protected]>, 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 <[email protected]>\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 <[email protected]>\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"
Loading