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

[17.0] [MIG] partner_multi_company: Migration to 17.0 #626

Open
wants to merge 45 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
942b3f4
New module partner_multi_company
oihane Dec 18, 2015
f8a4ab6
partner_multi_company: Tests + README
pedrobaeza Dec 21, 2015
16d57fd
partner_multi_company: Sync company_ids field
pedrobaeza Jan 19, 2016
b4add64
product_multi_company: Avoid errors in other tests
pedrobaeza Jan 23, 2016
8410bdd
partner_multi_company: Migration to 9.0
pedrobaeza Dec 6, 2016
e9ccd83
OCA Transbot updated translations from Transifex
oca-transbot Dec 10, 2016
b63d746
[MIG] partner_multi_company: Upgrade to v10
lasley Jun 14, 2017
593306b
[MIG] *_multi_company: OpenUpgrade migration scripts
pedrobaeza Dec 15, 2017
22d0408
OCA Transbot updated translations from Transifex
oca-transbot Dec 30, 2017
e3b98fa
[MIG] partner_multi_company: Migration to 11.0
cubells Nov 15, 2018
ef5598c
[MIG] partner_multi_company: Finish migration to 11.0
pedrobaeza Jan 19, 2019
4b022ed
[UPD] Update partner_multi_company.pot
oca-travis Jan 19, 2019
b50d386
Update translation files
oca-transbot Jan 27, 2019
49fc391
[12.0][MIG] partner_multi_company
kittiu Jun 18, 2019
0d51db2
[UPD] Update partner_multi_company.pot
oca-travis Nov 14, 2019
cf4ed52
[UPD] README.rst
OCA-git-bot Nov 14, 2019
72c9bb6
Update translation files
oca-transbot Nov 14, 2019
e2a74c6
Update translation files
oca-transbot Nov 19, 2019
c3ae77f
[FIX] If user switch company, don't delete user's partner's other com…
MiquelRForgeFlow Feb 27, 2020
3e95c85
partner_multi_company 12.0.1.0.1
OCA-git-bot Mar 6, 2020
6e96be6
[IMP] partner_multi_company: black, isort
JoanSForgeFlow Mar 25, 2020
ab57f6e
[MIG] partner_multi_company: Migration to 13.0
JoanSForgeFlow Mar 26, 2020
3fba274
added migration scripts
JoanSForgeFlow Jun 23, 2020
3d7fd32
[UPT]partner_multi_company/migrations do not keep old table + update …
AaronHForgeFlow Jul 8, 2020
67f79b9
[UPD] Update partner_multi_company.pot
oca-travis Jan 12, 2021
49cfc82
[UPD] README.rst
OCA-git-bot Jan 12, 2021
a1da067
Translated using Weblate (Spanish)
anasuarez1 Mar 9, 2021
c33d348
[FIX] pre-commit [ci skip]
pedrobaeza Oct 22, 2021
5af1e69
[IMP] partner_multi_company: black, isort, prettier
JasminSForgeFlow Mar 9, 2022
ffda4a6
[MIG] partner_multi_company: Migration to 14.0
JasminSForgeFlow Mar 9, 2022
514c071
[MIG] partner_multi_company: Migration to 15.0
JasminSForgeFlow Mar 10, 2022
29b779c
[UPD] Update partner_multi_company.pot
Apr 26, 2022
36f1c03
[UPD] README.rst
OCA-git-bot Apr 26, 2022
d55d265
[MIG] partner_multi_company: Migration to 16.0
Mar 15, 2023
923a117
[UPD] Update partner_multi_company.pot
Dec 18, 2023
19ba2a9
[BOT] post-merge updates
OCA-git-bot Dec 18, 2023
04c932e
Update translation files
weblate Dec 18, 2023
01bff04
Translated using Weblate (Spanish)
Ivorra78 Dec 18, 2023
a8fb759
[FIX] partner_multi_company: Initialize company_ids field
pedrobaeza Jan 3, 2024
be79774
[BOT] post-merge updates
OCA-git-bot Jan 4, 2024
78c69c6
Added translation using Weblate (Italian)
mymage Jan 19, 2024
2d4ed5f
Translated using Weblate (Italian)
mymage Jan 19, 2024
b2cfe67
[IMP] partner_multi_company: pre-commit stuff
rven May 21, 2024
da65374
[MIG] partner_multi_company: Migration to 17.0
rven May 21, 2024
ccb28f2
[IMP] partner_multi_company: prevent inconsistencies between user and…
ArnauCForgeFlow Jul 16, 2024
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
1 change: 1 addition & 0 deletions mail_multicompany/tests/test_mail_multicompany.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class TestMailMultiCompany(TransactionCase):
def setUpClass(cls):
super().setUpClass()
cls.user_demo = cls.env.ref("base.user_demo")
cls.user_demo.partner_id.company_id = False
company_obj = cls.env["res.company"]
server_obj = cls.env["ir.mail_server"]
cls.company1 = company_obj.create({"name": "Company 1"})
Expand Down
105 changes: 105 additions & 0 deletions partner_multi_company/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
=====================
Partner multi-company
=====================

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

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmulti--company-lightgray.png?logo=github
:target: https://github.com/OCA/multi-company/tree/17.0/partner_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-17-0/multi-company-17-0-partner_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=17.0
:alt: Try me on Runboat

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

This modules allows to select in which of the companies you want to use
each of the partners.

**Table of contents**

.. contents::
:local:

Installation
============

This module uses the post and uninstall hooks for updating default
partner template security rule. This only means that updating the module
will not restore the security rule this module changes. Only a complete
removal and reinstallation will serve.

Usage
=====

On the partner form view, go to the "Sales & Purchases" tab, and put the
companies in which you want to use that partner. If none is selected,
the partner will be visible in all of them. The default value is the
current one.

Known issues / Roadmap
======================

- Allow to select different companies from the parent in contacts.

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:%20partner_multi_company%0Aversion:%2017.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
-------

* Tecnativa

Contributors
------------

- Oihane Crucelaegui <[email protected]>
- Dave Lasley <[email protected]>
- `Tecnativa <https://www.tecnativa.com>`__:

- Pedro M. Baeza <[email protected]>
- Vicent Cubells <[email protected]>

- Kitti Upariphutthiphong <[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.

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions partner_multi_company/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import models
from .hooks import post_init_hook
from .hooks import uninstall_hook
18 changes: 18 additions & 0 deletions partner_multi_company/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2015 Oihane Crucelaegui
# Copyright 2015-2019 Pedro M. Baeza <[email protected]>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

{
"name": "Partner multi-company",
"summary": "Select individually the partner visibility on each company",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"depends": ["base_multi_company"],
"author": "Tecnativa, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/multi-company",
"category": "Partner Management",
"data": ["views/res_partner_view.xml"],
"installable": True,
"post_init_hook": "post_init_hook",
"uninstall_hook": "uninstall_hook",
}
63 changes: 63 additions & 0 deletions partner_multi_company/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import logging

_logger = logging.getLogger(__name__)


def post_init_hook(env):
"""
Set access rule to support multi-company fields
"""
# Change access rule
rule = env.ref("base.res_partner_rule")
rule.write(
{
"domain_force": (
"['|', '|', ('partner_share', '=', False),"
"('company_ids', 'in', company_ids),"
"('company_ids', '=', False)]"
),
}
)
# Initialize m2m table for preserving old restrictions
env.cr.execute(
"""
INSERT INTO res_company_res_partner_rel
(res_partner_id, res_company_id)
SELECT id, company_id
FROM res_partner
WHERE company_id IS NOT NULL
"""
)
fix_user_partner_companies(env)


def fix_user_partner_companies(env):
for user in env["res.users"].search([]):
user_company_ids = set(user.company_ids.ids)
partner_company_ids = set(user.partner_id.company_ids.ids)
if not user_company_ids.issubset(partner_company_ids) and partner_company_ids:
missing_company_ids = list(user_company_ids - partner_company_ids)

Check warning on line 39 in partner_multi_company/hooks.py

View check run for this annotation

Codecov / codecov/patch

partner_multi_company/hooks.py#L39

Added line #L39 was not covered by tests
user.partner_id.write(
{"company_ids": [(4, company_id) for company_id in missing_company_ids]}
)


def uninstall_hook(env):
"""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.
"""
# Change access rule
rule = env.ref("base.res_partner_rule")
rule.write(
{
"domain_force": (
"['|', '|', ('partner_share', '=', False),"
"('company_id', 'in', company_ids),"
"('company_id', '=', False)]"
),
}
)
50 changes: 50 additions & 0 deletions partner_multi_company/i18n/de.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:
# * partner_multi_company
#
# Translators:
# Rudolf Schnapka <[email protected]>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0c\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-12-24 03:32+0000\n"
"PO-Revision-Date: 2016-12-24 03:32+0000\n"
"Last-Translator: Rudolf Schnapka <[email protected]>, 2017\n"
"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n"
"Language: de\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: partner_multi_company
#: model:ir.model.fields,field_description:partner_multi_company.field_res_partner__company_ids
msgid "Companies"
msgstr "Unternehmen"

#. module: partner_multi_company
#: model:ir.model.fields,field_description:partner_multi_company.field_res_partner__company_id
msgid "Company"
msgstr ""

#. module: partner_multi_company
#: model:ir.model,name:partner_multi_company.model_res_partner
msgid "Contact"
msgstr ""

#. module: partner_multi_company
#: model:ir.model.fields,field_description:partner_multi_company.field_res_partner__display_name
msgid "Display Name"
msgstr ""

#. module: partner_multi_company
#: model:ir.model,name:partner_multi_company.model_res_users
msgid "User"
msgstr ""

#~ msgid "Users"
#~ msgstr "Anwender"

#~ msgid "Partner"
#~ msgstr "Partner"
48 changes: 48 additions & 0 deletions partner_multi_company/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_multi_company
#
# Translators:
# OCA Transbot <[email protected]>, 2016
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0c\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-12-10 01:34+0000\n"
"PO-Revision-Date: 2023-12-18 20:33+0000\n"
"Last-Translator: Ivorra78 <[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.17\n"

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

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

#. module: partner_multi_company
#: model:ir.model,name:partner_multi_company.model_res_partner
msgid "Contact"
msgstr "Contacto"

#. module: partner_multi_company
#: model:ir.model.fields,field_description:partner_multi_company.field_res_partner__display_name
msgid "Display Name"
msgstr "Nombre mostrado"

#. module: partner_multi_company
#: model:ir.model,name:partner_multi_company.model_res_users
msgid "User"
msgstr "Usuario"

#~ msgid "Users"
#~ msgstr "Usuarios"
51 changes: 51 additions & 0 deletions partner_multi_company/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_multi_company
#
# Translators:
# OCA Transbot <[email protected]>, 2016
# leemannd <[email protected]>, 2016
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0c\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-12-10 05:05+0000\n"
"PO-Revision-Date: 2016-12-10 05:05+0000\n"
"Last-Translator: leemannd <[email protected]>, 2016\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: partner_multi_company
#: model:ir.model.fields,field_description:partner_multi_company.field_res_partner__company_ids
msgid "Companies"
msgstr "Sociétés"

#. module: partner_multi_company
#: model:ir.model.fields,field_description:partner_multi_company.field_res_partner__company_id
msgid "Company"
msgstr ""

#. module: partner_multi_company
#: model:ir.model,name:partner_multi_company.model_res_partner
msgid "Contact"
msgstr ""

#. module: partner_multi_company
#: model:ir.model.fields,field_description:partner_multi_company.field_res_partner__display_name
msgid "Display Name"
msgstr ""

#. module: partner_multi_company
#: model:ir.model,name:partner_multi_company.model_res_users
msgid "User"
msgstr ""

#~ msgid "Users"
#~ msgstr "Utilisateurs"

#~ msgid "Partner"
#~ msgstr "Partenaire"
38 changes: 38 additions & 0 deletions partner_multi_company/i18n/hr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_multi_company
#
# Translators:
# Bole <[email protected]>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-01-27 07:37+0000\n"
"PO-Revision-Date: 2018-01-27 07:37+0000\n"
"Last-Translator: Bole <[email protected]>, 2018\n"
"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n"
"Language: hr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"

#. module: partner_multi_company
#: model:ir.model,name:partner_multi_company.model_res_partner
msgid "Contact"
msgstr ""

#. module: partner_multi_company
#: model:ir.model.fields,field_description:partner_multi_company.field_res_partner__display_name
msgid "Display Name"
msgstr ""

#. module: partner_multi_company
#: model:ir.model,name:partner_multi_company.model_res_users
msgid "Users"
msgstr "Korisnici"

#~ msgid "Partner"
#~ msgstr "Partner"
Loading
Loading