Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9bcd206
res_partner_operating_unit
repodevs Oct 17, 2017
185030e
res_partner_operating_unit: fix error import `models`
repodevs Oct 17, 2017
19ec521
res_partner_operating_unit: remove default assigned operating unit in…
repodevs Oct 19, 2017
4bdbfe0
res_partner_operating_unit: fix manifest
repodevs Oct 20, 2017
4579667
res_partner_operating_unit: add unit tests
repodevs Oct 20, 2017
0e4315f
res_partner_operating_unit: fix flake8 error
repodevs Oct 20, 2017
2cdb203
[12.0][MIG]res_partner_operating_unit.
Dangar-Serpentcs Dec 23, 2019
f558ecb
[FIX] res_partner_operating_unit: Allow user to access his related pa…
max3903 Jan 7, 2020
4fd32b7
[FIX] res_partner_operating_unit
max3903 Jan 7, 2020
b55567b
[FIX] res_partner_operating_unit: Indentation
max3903 Jan 7, 2020
1b6ae0d
[FIX]Fixed Travis error.
Dangar-Serpentcs Jan 15, 2020
102da28
Added translation using Weblate (Portuguese)
pedrocs-exo Feb 29, 2020
cc40fd4
Translated using Weblate (Portuguese)
pedrocs-exo Feb 29, 2020
90d40ef
[FIX] res_partner_operating_unit: Perf issue (#258)
max3903 Mar 9, 2020
9f216ea
[IMP] Add many2many_tags widget on list
patrickrwilson Mar 23, 2020
2ec96fb
res_partner_operating_unit 12.0.1.0.1
OCA-git-bot Mar 23, 2020
09257e2
res_partner_operating_unit 12.0.1.1.0
OCA-git-bot Mar 23, 2020
26e4609
[FIX]Fixed an issue of getting trace-back when logged In user going t…
Dangar-Serpentcs Oct 20, 2020
fa64c92
res_partner_operating_unit 12.0.1.1.1
OCA-git-bot Aug 4, 2021
98ebb24
Added translation using Weblate (Italian)
francesco-ooops Aug 23, 2021
8e45f3a
Translated using Weblate (Italian)
francesco-ooops Aug 23, 2021
2f1dc5e
Translated using Weblate (Italian)
francesco-ooops Jan 18, 2023
de444e6
[IMP] res_partner_operating_unit: pre-commit auto fixes
huynh-ch Jul 10, 2025
308b7be
[MIG] res_partner_operating_unit: Migration to 18.0
huynh-ch Jul 10, 2025
1725e5f
[IMP] res_partner_operating_unit: pre-commit auto fixes
yankinmax Nov 21, 2025
6f4dc34
[MIG] res_partner_operating_unit: Migration to 19.0
yankinmax Nov 21, 2025
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
110 changes: 110 additions & 0 deletions res_partner_operating_unit/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

===========================
Partner with Operating Unit
===========================

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

.. |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/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%2Foperating--unit-lightgray.png?logo=github
:target: https://github.com/OCA/operating-unit/tree/19.0/res_partner_operating_unit
:alt: OCA/operating-unit
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/operating-unit-19-0/operating-unit-19-0-res_partner_operating_unit
: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/operating-unit&target_branch=19.0
:alt: Try me on Runboat

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

This module introduces the following features:

- Adds the Operating Unit (OU) to res partner.
- The user’s default Operating Unit (OU) is proposed at the time of
creating Partner.
- Security rules are defined to ensure that users can only see Partner
of that Operating Units in which they are allowed access to.

**Table of contents**

.. contents::
:local:

Usage
=====

- Go to customer
- You only see the customer of your operating units
- Create an customer. It is assigned to your default operating unit.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/operating-unit/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/operating-unit/issues/new?body=module:%20res_partner_operating_unit%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
-------

* Edi Santoso
* Niaga Solution

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

- Edi Santoso <repodevs@gmail.com>
- Maxime Chambreuil <mchambreuil@opensourceintegrators.com>
- Hiren Dangar <hiren.dangar.serpentcs@gmail.com>
- `Komit <https://komit-consulting.com>`__:

- Cai Hoang Huynh

- `Camptocamp <https://www.camptocamp.com>`__:

- Maksym Yankin <maksym.yankin@camptocamp.com>

Other credits
-------------

- Niaga Solution
- Open Source Integrators
- Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>

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/operating-unit <https://github.com/OCA/operating-unit/tree/19.0/res_partner_operating_unit>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions res_partner_operating_unit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import models
16 changes: 16 additions & 0 deletions res_partner_operating_unit/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# © 2017 Niaga Solution - Edi Santoso <repodevs@gmail.com>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{
"name": "Partner with Operating Unit",
"summary": "Introduces Operating Unit fields in Partner",
"version": "19.0.1.0.0",
"author": "Edi Santoso, Niaga Solution, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/operating-unit",
"category": "Generic",
"depends": ["operating_unit"],
"license": "LGPL-3",
"data": [
"views/res_partner_view.xml",
],
"installable": True,
}
43 changes: 43 additions & 0 deletions res_partner_operating_unit/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * res_partner_operating_unit
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-01-18 11:48+0000\n"
"Last-Translator: Francesco Foresti <francesco.foresti@ooops404.com>\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.14.1\n"

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

#. module: res_partner_operating_unit
#: model:ir.model.fields,field_description:res_partner_operating_unit.field_fsm_location__operating_unit_ids
#: model:ir.model.fields,field_description:res_partner_operating_unit.field_fsm_person__operating_unit_ids
#: model:ir.model.fields,field_description:res_partner_operating_unit.field_res_partner__operating_unit_ids
msgid "Operating Units"
msgstr "Unità operative"

#. module: res_partner_operating_unit
#: code:addons/res_partner_operating_unit/models/res_users.py:34
#, python-format
msgid ""
"The operating units of the partner must include the default one of the user."
msgstr ""
"Le unità operative del contatto devono includere quella predefinita "
"dell'utente."

#. module: res_partner_operating_unit
#: model:ir.model,name:res_partner_operating_unit.model_res_users
msgid "Users"
msgstr "Utenti"
43 changes: 43 additions & 0 deletions res_partner_operating_unit/i18n/pt.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * res_partner_operating_unit
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2020-02-29 15:13+0000\n"
"Last-Translator: Pedro Castro Silva <pedrocs@exo.pt>\n"
"Language-Team: none\n"
"Language: pt\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: res_partner_operating_unit
#: model:ir.model,name:res_partner_operating_unit.model_res_partner
msgid "Contact"
msgstr "Contacto"

#. module: res_partner_operating_unit
#: model:ir.model.fields,field_description:res_partner_operating_unit.field_fsm_location__operating_unit_ids
#: model:ir.model.fields,field_description:res_partner_operating_unit.field_fsm_person__operating_unit_ids
#: model:ir.model.fields,field_description:res_partner_operating_unit.field_res_partner__operating_unit_ids
msgid "Operating Units"
msgstr "Unidades Operacionais"

#. module: res_partner_operating_unit
#: code:addons/res_partner_operating_unit/models/res_users.py:34
#, python-format
msgid ""
"The operating units of the partner must include the default one of the user."
msgstr ""
"As unidades operacionais deste parceiro devem incluir a predefinida do "
"utilizador."

#. module: res_partner_operating_unit
#: model:ir.model,name:res_partner_operating_unit.model_res_users
msgid "Users"
msgstr "Utilizadores"
38 changes: 38 additions & 0 deletions res_partner_operating_unit/i18n/res_partner_operating_unit.pot
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:
# * res_partner_operating_unit
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.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_partner_operating_unit
#: model:ir.model,name:res_partner_operating_unit.model_res_partner
msgid "Contact"
msgstr ""

#. module: res_partner_operating_unit
#: model:ir.model.fields,field_description:res_partner_operating_unit.field_fsm_location__operating_unit_ids
#: model:ir.model.fields,field_description:res_partner_operating_unit.field_fsm_person__operating_unit_ids
#: model:ir.model.fields,field_description:res_partner_operating_unit.field_res_partner__operating_unit_ids
msgid "Operating Units"
msgstr ""

#. module: res_partner_operating_unit
#: code:addons/res_partner_operating_unit/models/res_users.py:34
#, python-format
msgid "The operating units of the partner must include the default one of the user."
msgstr ""

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

3 changes: 3 additions & 0 deletions res_partner_operating_unit/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import res_partner
from . import res_users
58 changes: 58 additions & 0 deletions res_partner_operating_unit/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# © 2017 Niaga Solution - Edi Santoso <repodevs@gmail.com>
# Copyright (C) 2019 Serpent Consulting Services
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import api, fields, models
from odoo.fields import Domain


class ResPartner(models.Model):
_inherit = "res.partner"

@api.model
def operating_unit_default_get(self, uid2=False):
if not uid2:
uid2 = self.env.uid
user = self.env["res.users"].browse(uid2)
return user.default_operating_unit_id

@api.model
def _default_operating_unit(self):
return self.operating_unit_default_get()

@api.model
def _default_operating_units(self):
return self._default_operating_unit()

operating_unit_ids = fields.Many2many(
comodel_name="operating.unit",
relation="operating_unit_partner_rel",
column1="partner_id",
column2="operating_unit_id",
string="Operating Units",
default=lambda self: self._default_operating_units(),
)

@api.model
def _user_ous_domain(self):
ou_ids = self.env.user.operating_unit_ids.ids
domain = Domain.OR(
[
Domain("operating_unit_ids", "in", ou_ids),
Domain("operating_unit_ids", "=", False),
]
)
return domain

# Extending methods to replace a record rule.
# Ref: https://github.com/OCA/operating-unit/issues/258
@api.model
def search(self, args, offset=0, limit=None, order=None):
# Get the OUs of the user
domain = self._user_ous_domain()
return super().search(domain + args, offset=offset, limit=limit, order=order)

@api.model
def search_count(self, args, limit=None):
# Get the OUs of the user
domain = self._user_ous_domain()
return super().search_count(domain + args, limit=limit)
46 changes: 46 additions & 0 deletions res_partner_operating_unit/models/res_users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# © 2017 Niaga Solution - Edi Santoso <repodevs@gmail.com>
# Copyright (C) 2019 Serpent Consulting Services
# Copyright (C) 2019 Open Source Integrators
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import api, models
from odoo.exceptions import UserError
from odoo.fields import Command


class ResUsers(models.Model):
_inherit = "res.users"

@api.model_create_multi
def create(self, vals_list):
res = super().create(vals_list)
for rec in res:
if rec.default_operating_unit_id:
rec.partner_id.operating_unit_ids = [
Command.link(rec.default_operating_unit_id.id)
]
rec.check_partner_operating_unit()
return res

def write(self, vals):
for user in self:
res = super().write(vals)
if vals.get("default_operating_unit_id"):
# Add the new OU
user.partner_id.operating_unit_ids = [
Command.link(user.default_operating_unit_id.id)
]
user.check_partner_operating_unit()
return res

def check_partner_operating_unit(self):
if (
self.partner_id.operating_unit_ids
and self.default_operating_unit_id.id
not in self.partner_id.operating_unit_ids.ids
):
raise UserError(
self.env._(
"The operating units of the partner must include the default "
"one of the user."
)
)
3 changes: 3 additions & 0 deletions res_partner_operating_unit/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
7 changes: 7 additions & 0 deletions res_partner_operating_unit/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- Edi Santoso \<repodevs@gmail.com\>
- Maxime Chambreuil \<mchambreuil@opensourceintegrators.com\>
- Hiren Dangar \<hiren.dangar.serpentcs@gmail.com\>
- [Komit](https://komit-consulting.com):
- Cai Hoang Huynh
- [Camptocamp](https://www.camptocamp.com):
- Maksym Yankin \<maksym.yankin@camptocamp.com\>
3 changes: 3 additions & 0 deletions res_partner_operating_unit/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Niaga Solution
- Open Source Integrators
- Serpent Consulting Services Pvt. Ltd. \<support@serpentcs.com\>
7 changes: 7 additions & 0 deletions res_partner_operating_unit/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This module introduces the following features:

- Adds the Operating Unit (OU) to res partner.
- The user’s default Operating Unit (OU) is proposed at the time of
creating Partner.
- Security rules are defined to ensure that users can only see Partner
of that Operating Units in which they are allowed access to.
3 changes: 3 additions & 0 deletions res_partner_operating_unit/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Go to customer
- You only see the customer of your operating units
- Create an customer. It is assigned to your default operating unit.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading