Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
28d9a85
res_partner_operating_unit
repodevs Oct 17, 2017
aef04ea
res_partner_operating_unit: fix error import `models`
repodevs Oct 17, 2017
a5b5355
res_partner_operating_unit: remove default assigned operating unit in…
repodevs Oct 19, 2017
dd21ae3
res_partner_operating_unit: fix manifest
repodevs Oct 20, 2017
2101b51
res_partner_operating_unit: add unit tests
repodevs Oct 20, 2017
c74a430
res_partner_operating_unit: fix flake8 error
repodevs Oct 20, 2017
9221a31
[12.0][MIG]res_partner_operating_unit.
Dangar-Serpentcs Dec 23, 2019
c633d39
[FIX] res_partner_operating_unit: Allow user to access his related pa…
max3903 Jan 7, 2020
57927a7
[FIX] res_partner_operating_unit
max3903 Jan 7, 2020
84c243e
[FIX] res_partner_operating_unit: Indentation
max3903 Jan 7, 2020
4c8d7f1
[FIX]Fixed Travis error.
Dangar-Serpentcs Jan 15, 2020
f473b09
[UPD] Update res_partner_operating_unit.pot
oca-travis Jan 15, 2020
772bebd
[UPD] README.rst
OCA-git-bot Jan 15, 2020
aff8476
[ADD] icon.png
OCA-git-bot Jan 15, 2020
6ab847c
Added translation using Weblate (Portuguese)
pedrocs-exo Feb 29, 2020
9d3ed0f
Translated using Weblate (Portuguese)
pedrocs-exo Feb 29, 2020
d239d62
[FIX] res_partner_operating_unit: Perf issue (#258)
max3903 Mar 9, 2020
35ea641
[IMP] Add many2many_tags widget on list
patrickrwilson Mar 23, 2020
f120c8c
res_partner_operating_unit 12.0.1.0.1
OCA-git-bot Mar 23, 2020
f0b6f5b
res_partner_operating_unit 12.0.1.1.0
OCA-git-bot Mar 23, 2020
4e9ffa9
[FIX]Fixed an issue of getting trace-back when logged In user going t…
Dangar-Serpentcs Oct 20, 2020
34bc7b6
res_partner_operating_unit 12.0.1.1.1
OCA-git-bot Aug 4, 2021
2d1d6c9
Added translation using Weblate (Italian)
francesco-ooops Aug 23, 2021
b59b08f
Translated using Weblate (Italian)
francesco-ooops Aug 23, 2021
9e2b9fb
Translated using Weblate (Italian)
francesco-ooops Jan 18, 2023
ba40c88
[UPD] README.rst
OCA-git-bot Sep 4, 2023
d0f5ff6
Update translation files
weblate Oct 9, 2023
5ba08cc
[IMP] res_partner_operating_unit: pre-commit auto fixes
huynh-ch Jul 10, 2025
863e62c
[MIG] res_partner_operating_unit: Migration to 18.0
huynh-ch Jul 10, 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
102 changes: 102 additions & 0 deletions res_partner_operating_unit/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
===========================
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/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%2Foperating--unit-lightgray.png?logo=github
:target: https://github.com/OCA/operating-unit/tree/18.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-18-0/operating-unit-18-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=18.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:%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
-------

* 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

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/18.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": "18.0.1.1.1",
"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
56 changes: 56 additions & 0 deletions res_partner_operating_unit/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# © 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


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

@api.model
def operating_unit_default_get(self, uid2=False):
if not uid2:
uid2 = self._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(
"operating.unit",
"operating_unit_partner_rel",
"partner_id",
"operating_unit_id",
"Operating Units",
default=lambda self: self._default_operating_units(),
)

# 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
ou_ids = self.env.user.operating_unit_ids.ids
domain = [
"|",
("operating_unit_ids", "in", ou_ids),
("operating_unit_ids", "=", False),
]
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
ou_ids = self.env.user.operating_unit_ids.ids
domain = [
"|",
("operating_unit_ids", "in", ou_ids),
("operating_unit_ids", "=", False),
]
return super().search_count(domain + args, limit=limit)
45 changes: 45 additions & 0 deletions res_partner_operating_unit/models/res_users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# © 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


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 = [
(4, 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 = [
(4, 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"
5 changes: 5 additions & 0 deletions res_partner_operating_unit/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- 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
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