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

[18.0][MIG] res_company_code: Migration to 18.0 #752

Merged
merged 24 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a9504b9
[ADD][12.0] new module res_company_code
legalsylvain Oct 24, 2019
45823e3
[UPD] Update res_company_code.pot, README.rst
oca-travis Oct 31, 2019
a773ffd
[IMP] res_company_code: black, isort, prettier
kirca Jun 26, 2020
f7544cc
[MIG] res_company_code: Migration to v13.0
kirca Jun 26, 2020
941cd5c
[UPD] Update res_company_code.pot
oca-travis Oct 8, 2020
e5c966b
[UPD] README.rst
OCA-git-bot Oct 8, 2020
37c8151
Update translation files
oca-transbot Oct 27, 2020
ba40c3d
Added translation using Weblate (Spanish)
anasuarez1 Mar 9, 2021
83b5ccf
Translated using Weblate (Spanish)
anasuarez1 Mar 9, 2021
b382179
[MIG] res_company_code: Migration to 14.0
kevinkhao Aug 30, 2021
1e29d35
[IMP] add name_search functionality, add tests
kevinkhao Aug 30, 2021
9c86f50
[UPD] Update res_company_code.pot
oca-travis Nov 28, 2021
a6639c0
[UPD] README.rst
OCA-git-bot Nov 28, 2021
283275a
res_company_code 14.0.1.0.1
OCA-git-bot Nov 28, 2021
fb99224
Update translation files
oca-transbot Nov 28, 2021
dc12039
[MIG] res_company_code : migrate from 14.0 to 16.0
legalsylvain Oct 17, 2022
4838a06
[UPD] Update res_company_code.pot
Dec 16, 2023
815c20c
[BOT] post-merge updates
OCA-git-bot Dec 16, 2023
db9ed71
Update translation files
weblate Dec 16, 2023
9bba406
Added translation using Weblate (Italian)
mymage Jan 19, 2024
60e0c1a
Translated using Weblate (Italian)
mymage Jan 19, 2024
177429c
[FIX] res_company_code: remove company_ids from demo partner
ArnauCForgeFlow Jul 16, 2024
6749efc
[IMP] res_company_code: pre-commit auto fixes
BhaveshHeliconia Dec 26, 2024
5943203
[MIG] res_company_code: Migration to 18.0
BhaveshHeliconia Dec 26, 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
109 changes: 109 additions & 0 deletions res_company_code/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
============
Company Code
============

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

.. |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/18.0/res_company_code
: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-18-0/multi-company-18-0-res_company_code
: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=18.0
:alt: Try me on Runboat

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

In a big multi-company context, users often use a code to indentify the
differents companies.

- This module adds ``code`` fields on company model.

|image1|

This field is optional, but should be unique, if defined.

- This code will prefix the name, in the Odoo Switch Company Menu
widget:

|image2|

- this module also change the order of the companies, ordering by code,
then by company name. (instead of by sequence, then by name). It so
hides the now useless field sequence.

|image3|

.. |image1| image:: https://raw.githubusercontent.com/OCA/multi-company/18.0/res_company_code/static/description/res_company_form.png
.. |image2| image:: https://raw.githubusercontent.com/OCA/multi-company/18.0/res_company_code/static/description/switch_company_menu.png
.. |image3| image:: https://raw.githubusercontent.com/OCA/multi-company/18.0/res_company_code/static/description/res_company_tree.png

**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:%20res_company_code%0Aversion:%2018.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
-------

* GRAP

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

- Sylvain LE GAL <https://twitter.com/legalsylvain>
- Kiril Vangelovski <[email protected]>
- Kevin Khao <[email protected]>
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__

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

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

|maintainer-legalsylvain|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions res_company_code/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
26 changes: 26 additions & 0 deletions res_company_code/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Company Code",
"summary": "Add 'code' field on company model",
"version": "18.0.1.0.0",
"category": "Tools",
"author": "GRAP, Odoo Community Association (OCA)",
"maintainers": ["legalsylvain"],
"website": "https://github.com/OCA/multi-company",
"license": "AGPL-3",
"depends": [
"web",
"res_company_search_view",
],
"data": [
"views/view_res_company.xml",
],
"demo": [
"demo/res_groups.xml",
"demo/res_company.xml",
],
"installable": True,
}
25 changes: 25 additions & 0 deletions res_company_code/demo/res_company.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo>
<record id="company_test" model="res.company">
<field name="name">My Test Company</field>
<field name="code">C2</field>
<field
name="user_ids"
eval="[
(4, ref('base.user_admin')),
(4, ref('base.user_demo')),
]"
/>
</record>
<record id="base.main_company" model="res.company">
<field name="code">C1</field>
</record>
<record model="res.partner" id="base.partner_demo">
<field name="company_id" eval="False" />
</record>
</odoo>
11 changes: 11 additions & 0 deletions res_company_code/demo/res_groups.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo>
<record id="base.group_multi_company" model="res.groups">
<field name="users" eval="[(4, ref('base.user_admin'))]" />
</record>
</odoo>
42 changes: 42 additions & 0 deletions res_company_code/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * res_company_code
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2021-03-09 17:45+0000\n"
"Last-Translator: Ana Suárez <[email protected]>\n"
"Language-Team: none\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: res_company_code
#: model:ir.model.fields,field_description:res_company_code.field_res_company__code
msgid "Code"
msgstr "Código"

#. module: res_company_code
#: model:ir.model,name:res_company_code.model_res_company
msgid "Companies"
msgstr "Compañías"

#. module: res_company_code
#: model:ir.model.fields,field_description:res_company_code.field_res_company__complete_name
msgid "Complete Name"
msgstr "Nombre completo"

#. module: res_company_code
#: model:ir.model,name:res_company_code.model_ir_http
msgid "HTTP Routing"
msgstr "Enrutamiento HTTP"

#. module: res_company_code
#: model:ir.model.constraint,message:res_company_code.constraint_res_company_code_uniq
msgid "The company code must be unique !"
msgstr "¡El código de compañía debe ser único!"
42 changes: 42 additions & 0 deletions res_company_code/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * res_company_code
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-10-24 10:22+0000\n"
"PO-Revision-Date: 2019-10-24 10:22+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: res_company_code
#: model:ir.model.fields,field_description:res_company_code.field_res_company__code
msgid "Code"
msgstr "Code"

#. module: res_company_code
#: model:ir.model,name:res_company_code.model_res_company
msgid "Companies"
msgstr "Sociétés"

#. module: res_company_code
#: model:ir.model.fields,field_description:res_company_code.field_res_company__complete_name
msgid "Complete Name"
msgstr "Nom Complet"

#. module: res_company_code
#: model:ir.model,name:res_company_code.model_ir_http
msgid "HTTP Routing"
msgstr "Routage HTTP"

#. module: res_company_code
#: model:ir.model.constraint,message:res_company_code.constraint_res_company_code_uniq
msgid "The company code must be unique !"
msgstr "Le code de la société doit être unique !"
42 changes: 42 additions & 0 deletions res_company_code/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * res_company_code
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-01-19 22:33+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\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: res_company_code
#: model:ir.model.fields,field_description:res_company_code.field_res_company__code
msgid "Code"
msgstr "Codice"

#. module: res_company_code
#: model:ir.model,name:res_company_code.model_res_company
msgid "Companies"
msgstr "Aziende"

#. module: res_company_code
#: model:ir.model.fields,field_description:res_company_code.field_res_company__complete_name
msgid "Complete Name"
msgstr "Nome completo"

#. module: res_company_code
#: model:ir.model,name:res_company_code.model_ir_http
msgid "HTTP Routing"
msgstr "Instradamento HTTP"

#. module: res_company_code
#: model:ir.model.constraint,message:res_company_code.constraint_res_company_code_uniq
msgid "The company code must be unique !"
msgstr "Il codice azienda deve essere univoco!"
39 changes: 39 additions & 0 deletions res_company_code/i18n/res_company_code.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * res_company_code
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.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: res_company_code
#: model:ir.model.fields,field_description:res_company_code.field_res_company__code
msgid "Code"
msgstr ""

#. module: res_company_code
#: model:ir.model,name:res_company_code.model_res_company
msgid "Companies"
msgstr ""

#. module: res_company_code
#: model:ir.model.fields,field_description:res_company_code.field_res_company__complete_name
msgid "Complete Name"
msgstr ""

#. module: res_company_code
#: model:ir.model,name:res_company_code.model_ir_http
msgid "HTTP Routing"
msgstr ""

#. module: res_company_code
#: model:ir.model.constraint,message:res_company_code.constraint_res_company_code_uniq
msgid "The company code must be unique !"
msgstr ""
2 changes: 2 additions & 0 deletions res_company_code/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import ir_http
from . import res_company
30 changes: 30 additions & 0 deletions res_company_code/models/ir_http.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models
from odoo.http import request


class Http(models.AbstractModel):
_inherit = "ir.http"

def session_info(self):
result = super().session_info()
user = request.env.user
display_switch_company_menu = (

Check warning on line 15 in res_company_code/models/ir_http.py

View check run for this annotation

Codecov / codecov/patch

res_company_code/models/ir_http.py#L13-L15

Added lines #L13 - L15 were not covered by tests
user.has_group("base.group_multi_company") and len(user.company_ids) > 1
)
# 1. Replace company name by company complete name in the session
# The values are used in the switch_company_menu widget (web module)
# 2. Recompute sequence. (as the widget hard-codes the order by sequence). See :
# https://github.com/odoo/odoo/blob/fbd6a3bc10a3302e7061eb46eb246221e461e76d/addons/web/static/src/webclient/switch_company_menu/switch_company_menu.xml#L10 # noqa: E501
if display_switch_company_menu:
for sequence, company in enumerate(user.company_ids):
result["user_companies"]["allowed_companies"].get(company.id).update(

Check warning on line 24 in res_company_code/models/ir_http.py

View check run for this annotation

Codecov / codecov/patch

res_company_code/models/ir_http.py#L24

Added line #L24 was not covered by tests
{
"name": company.display_name,
"sequence": sequence,
}
)
return result

Check warning on line 30 in res_company_code/models/ir_http.py

View check run for this annotation

Codecov / codecov/patch

res_company_code/models/ir_http.py#L30

Added line #L30 was not covered by tests
Loading