diff --git a/base_technical_user/README.rst b/base_technical_user/README.rst new file mode 100644 index 00000000000..39fbfca9f77 --- /dev/null +++ b/base_technical_user/README.rst @@ -0,0 +1,112 @@ +=================== +Base Technical User +=================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:0121b096a062ec6dadf8f7eb11001122575767cb35d323d823b4c46bf9cee5b6 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fserver--tools-lightgray.png?logo=github + :target: https://github.com/OCA/server-tools/tree/18.0/base_technical_user + :alt: OCA/server-tools +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-tools-18-0/server-tools-18-0-base_technical_user + :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/server-tools&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of company management. It allows +you to bind a technical user on the company in order to use it in batch +processes. + +The technical user must - be inactive to avoid login - be in the +required groups depending of what you need to do + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +If you install the module, you will find a tab on the company form +allowing to define the technical user. + +In your code you can use the following helper that will return you + +- a self with the user tech if configured +- or a self with sudo user + +.. code:: python + + self_tech = self.sudo_tech() + +If you want to raise an error if the tech user in not configured just +call it with + +.. code:: python + + self_tech = self.sudo_tech(raise_if_missing) + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* ACSONE SA/NV + +Contributors +------------ + +- Cédric Pigeon +- Khoi (Kien Kim) + +Other credits +------------- + +The migration of this module from 17.0 to 18.0 was financially supported +by: + +- Camptocamp. + +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/server-tools `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_technical_user/__init__.py b/base_technical_user/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/base_technical_user/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/base_technical_user/__manifest__.py b/base_technical_user/__manifest__.py new file mode 100644 index 00000000000..9d0ede8b463 --- /dev/null +++ b/base_technical_user/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2017 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "Base Technical User", + "summary": """ + Add a technical user parameter on the company """, + "author": "ACSONE SA/NV, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/server-tools", + "category": "Hidden/Dependency", + "version": "18.0.1.0.0", + "license": "AGPL-3", + "depends": ["base"], + "data": ["views/res_company_view.xml"], + "installable": True, +} diff --git a/base_technical_user/i18n/ar.po b/base_technical_user/i18n/ar.po new file mode 100644 index 00000000000..608c00c4526 --- /dev/null +++ b/base_technical_user/i18n/ar.po @@ -0,0 +1,53 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_technical_user +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: ar\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 " +"&& n%100<=10 ? 3 : n%100>=11 ? 4 : 5;\n" + +#. module: base_technical_user +#: model:ir.model,name:base_technical_user.model_base +msgid "Base" +msgstr "" + +#. module: base_technical_user +#: model:ir.model,name:base_technical_user.model_res_company +msgid "Companies" +msgstr "" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Configuration" +msgstr "" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Technical Parameters" +msgstr "" + +#. module: base_technical_user +#: model:ir.model.fields,field_description:base_technical_user.field_res_company__user_tech_id +msgid "Technical User" +msgstr "" + +#. module: base_technical_user +#. odoo-python +#: code:addons/base_technical_user/models/models.py:0 +#, python-format +msgid "The technical user is missing in the company {}" +msgstr "" + +#. module: base_technical_user +#: model:ir.model.fields,help:base_technical_user.field_res_company__user_tech_id +msgid "This user can be used by process for technical purpose" +msgstr "" diff --git a/base_technical_user/i18n/base_technical_user.pot b/base_technical_user/i18n/base_technical_user.pot new file mode 100644 index 00000000000..91e16f0e138 --- /dev/null +++ b/base_technical_user/i18n/base_technical_user.pot @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_technical_user +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.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_technical_user +#: model:ir.model,name:base_technical_user.model_base +msgid "Base" +msgstr "" + +#. module: base_technical_user +#: model:ir.model,name:base_technical_user.model_res_company +msgid "Companies" +msgstr "" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Configuration" +msgstr "" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Technical Parameters" +msgstr "" + +#. module: base_technical_user +#: model:ir.model.fields,field_description:base_technical_user.field_res_company__user_tech_id +msgid "Technical User" +msgstr "" + +#. module: base_technical_user +#. odoo-python +#: code:addons/base_technical_user/models/models.py:0 +#, python-format +msgid "The technical user is missing in the company {}" +msgstr "" + +#. module: base_technical_user +#: model:ir.model.fields,help:base_technical_user.field_res_company__user_tech_id +msgid "This user can be used by process for technical purpose" +msgstr "" diff --git a/base_technical_user/i18n/de.po b/base_technical_user/i18n/de.po new file mode 100644 index 00000000000..b21677b5a2a --- /dev/null +++ b/base_technical_user/i18n/de.po @@ -0,0 +1,56 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_technical_user +# +# Translators: +# Niki Waibel , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-12-01 02:10+0000\n" +"PO-Revision-Date: 2017-12-01 02:10+0000\n" +"Last-Translator: Niki Waibel , 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: base_technical_user +#: model:ir.model,name:base_technical_user.model_base +msgid "Base" +msgstr "" + +#. module: base_technical_user +#: model:ir.model,name:base_technical_user.model_res_company +msgid "Companies" +msgstr "Unternehmen" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Configuration" +msgstr "" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Technical Parameters" +msgstr "" + +#. module: base_technical_user +#: model:ir.model.fields,field_description:base_technical_user.field_res_company__user_tech_id +msgid "Technical User" +msgstr "" + +#. module: base_technical_user +#. odoo-python +#: code:addons/base_technical_user/models/models.py:0 +#, python-format +msgid "The technical user is missing in the company {}" +msgstr "" + +#. module: base_technical_user +#: model:ir.model.fields,help:base_technical_user.field_res_company__user_tech_id +msgid "This user can be used by process for technical purpose" +msgstr "" diff --git a/base_technical_user/i18n/es.po b/base_technical_user/i18n/es.po new file mode 100644 index 00000000000..0c4872d8cfe --- /dev/null +++ b/base_technical_user/i18n/es.po @@ -0,0 +1,60 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_technical_user +# +# Translators: +# Pedro M. Baeza , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-12-01 02:10+0000\n" +"PO-Revision-Date: 2023-06-15 17:09+0000\n" +"Last-Translator: kikopeiro \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: base_technical_user +#: model:ir.model,name:base_technical_user.model_base +msgid "Base" +msgstr "Base" + +#. module: base_technical_user +#: model:ir.model,name:base_technical_user.model_res_company +msgid "Companies" +msgstr "Compañías" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Configuration" +msgstr "Configuración" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Technical Parameters" +msgstr "Parámetros técnicos" + +#. module: base_technical_user +#: model:ir.model.fields,field_description:base_technical_user.field_res_company__user_tech_id +msgid "Technical User" +msgstr "Usuario técnico" + +#. module: base_technical_user +#. odoo-python +#: code:addons/base_technical_user/models/models.py:0 +#, python-format +msgid "The technical user is missing in the company {}" +msgstr "En la compañia {} no se encuentra el usuario técnico" + +#. module: base_technical_user +#: model:ir.model.fields,help:base_technical_user.field_res_company__user_tech_id +msgid "This user can be used by process for technical purpose" +msgstr "Este usuario debe usarse para procesos con propósitos técnicos" + +#~ msgid "Smart Search" +#~ msgstr "Búsqueda inteligente" diff --git a/base_technical_user/i18n/fr.po b/base_technical_user/i18n/fr.po new file mode 100644 index 00000000000..a56d19ed5e4 --- /dev/null +++ b/base_technical_user/i18n/fr.po @@ -0,0 +1,61 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_technical_user +# +# Translators: +# Quentin THEURET , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-12-01 02:10+0000\n" +"PO-Revision-Date: 2021-05-14 19:47+0000\n" +"Last-Translator: Yves Le Doeuff \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" +"X-Generator: Weblate 4.3.2\n" + +#. module: base_technical_user +#: model:ir.model,name:base_technical_user.model_base +msgid "Base" +msgstr "" + +#. module: base_technical_user +#: model:ir.model,name:base_technical_user.model_res_company +msgid "Companies" +msgstr "Sociétés" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Configuration" +msgstr "" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Technical Parameters" +msgstr "Paramètres techniques" + +#. module: base_technical_user +#: model:ir.model.fields,field_description:base_technical_user.field_res_company__user_tech_id +msgid "Technical User" +msgstr "Utilisateur technique" + +#. module: base_technical_user +#. odoo-python +#: code:addons/base_technical_user/models/models.py:0 +#, python-format +msgid "The technical user is missing in the company {}" +msgstr "L'utilisateur technique manque dans l'entreprise {}" + +#. module: base_technical_user +#: model:ir.model.fields,help:base_technical_user.field_res_company__user_tech_id +msgid "This user can be used by process for technical purpose" +msgstr "" +"Cet utilisateur peut être utilisé par un processus à des fins techniques" + +#~ msgid "Smart Search" +#~ msgstr "Recherche intelligente" diff --git a/base_technical_user/i18n/hr.po b/base_technical_user/i18n/hr.po new file mode 100644 index 00000000000..23a2643451a --- /dev/null +++ b/base_technical_user/i18n/hr.po @@ -0,0 +1,57 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_technical_user +# +# Translators: +# Bole , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-12-01 02:10+0000\n" +"PO-Revision-Date: 2017-12-01 02:10+0000\n" +"Last-Translator: Bole , 2017\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: base_technical_user +#: model:ir.model,name:base_technical_user.model_base +msgid "Base" +msgstr "" + +#. module: base_technical_user +#: model:ir.model,name:base_technical_user.model_res_company +msgid "Companies" +msgstr "Tvrtke" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Configuration" +msgstr "Postavke" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Technical Parameters" +msgstr "Tehnički parametri" + +#. module: base_technical_user +#: model:ir.model.fields,field_description:base_technical_user.field_res_company__user_tech_id +msgid "Technical User" +msgstr "Tehnički korisnik" + +#. module: base_technical_user +#. odoo-python +#: code:addons/base_technical_user/models/models.py:0 +#, python-format +msgid "The technical user is missing in the company {}" +msgstr "" + +#. module: base_technical_user +#: model:ir.model.fields,help:base_technical_user.field_res_company__user_tech_id +msgid "This user can be used by process for technical purpose" +msgstr "Ovaj korisnik može biti korišten od strane procesa u tehničke svrhe" diff --git a/base_technical_user/i18n/it.po b/base_technical_user/i18n/it.po new file mode 100644 index 00000000000..c9a2e9f3f9e --- /dev/null +++ b/base_technical_user/i18n/it.po @@ -0,0 +1,60 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_technical_user +# +# Translators: +# Paolo Valier , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-01-06 02:25+0000\n" +"PO-Revision-Date: 2024-01-02 16:34+0000\n" +"Last-Translator: mymage \n" +"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\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: base_technical_user +#: model:ir.model,name:base_technical_user.model_base +msgid "Base" +msgstr "Base" + +#. module: base_technical_user +#: model:ir.model,name:base_technical_user.model_res_company +msgid "Companies" +msgstr "Aziende" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Configuration" +msgstr "Configurazione" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Technical Parameters" +msgstr "Parametri Tecnici" + +#. module: base_technical_user +#: model:ir.model.fields,field_description:base_technical_user.field_res_company__user_tech_id +msgid "Technical User" +msgstr "Utente tecnico" + +#. module: base_technical_user +#. odoo-python +#: code:addons/base_technical_user/models/models.py:0 +#, python-format +msgid "The technical user is missing in the company {}" +msgstr "Manca l'utente tecnico nell'azienda {}" + +#. module: base_technical_user +#: model:ir.model.fields,help:base_technical_user.field_res_company__user_tech_id +msgid "This user can be used by process for technical purpose" +msgstr "Questo utente può essere usato dai processi per motvi tecnici" + +#~ msgid "Smart Search" +#~ msgstr "Ricerca intelligente" diff --git a/base_technical_user/i18n/nl_NL.po b/base_technical_user/i18n/nl_NL.po new file mode 100644 index 00000000000..13504e9533a --- /dev/null +++ b/base_technical_user/i18n/nl_NL.po @@ -0,0 +1,57 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_technical_user +# +# Translators: +# Peter Hageman , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-12-01 02:10+0000\n" +"PO-Revision-Date: 2017-12-01 02:10+0000\n" +"Last-Translator: Peter Hageman , 2017\n" +"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/" +"teams/23907/nl_NL/)\n" +"Language: nl_NL\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: base_technical_user +#: model:ir.model,name:base_technical_user.model_base +msgid "Base" +msgstr "" + +#. module: base_technical_user +#: model:ir.model,name:base_technical_user.model_res_company +msgid "Companies" +msgstr "Bedrijven" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Configuration" +msgstr "" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Technical Parameters" +msgstr "" + +#. module: base_technical_user +#: model:ir.model.fields,field_description:base_technical_user.field_res_company__user_tech_id +msgid "Technical User" +msgstr "" + +#. module: base_technical_user +#. odoo-python +#: code:addons/base_technical_user/models/models.py:0 +#, python-format +msgid "The technical user is missing in the company {}" +msgstr "" + +#. module: base_technical_user +#: model:ir.model.fields,help:base_technical_user.field_res_company__user_tech_id +msgid "This user can be used by process for technical purpose" +msgstr "" diff --git a/base_technical_user/i18n/pt.po b/base_technical_user/i18n/pt.po new file mode 100644 index 00000000000..449bc2b56fa --- /dev/null +++ b/base_technical_user/i18n/pt.po @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_technical_user +# +# Translators: +# Pedro Castro Silva , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-12-01 02:10+0000\n" +"PO-Revision-Date: 2021-01-11 01:44+0000\n" +"Last-Translator: Pedro Castro Silva \n" +"Language-Team: Portuguese (https://www.transifex.com/oca/teams/23907/pt/)\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 4.3.2\n" + +#. module: base_technical_user +#: model:ir.model,name:base_technical_user.model_base +msgid "Base" +msgstr "" + +#. module: base_technical_user +#: model:ir.model,name:base_technical_user.model_res_company +msgid "Companies" +msgstr "Empresas" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Configuration" +msgstr "Configuração" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Technical Parameters" +msgstr "Parâmetros Técnicos" + +#. module: base_technical_user +#: model:ir.model.fields,field_description:base_technical_user.field_res_company__user_tech_id +msgid "Technical User" +msgstr "Utilizador Técnico" + +#. module: base_technical_user +#. odoo-python +#: code:addons/base_technical_user/models/models.py:0 +#, python-format +msgid "The technical user is missing in the company {}" +msgstr "O utilizador técnico está em falta na empresa {}" + +#. module: base_technical_user +#: model:ir.model.fields,help:base_technical_user.field_res_company__user_tech_id +msgid "This user can be used by process for technical purpose" +msgstr "" +"Este utilizador pode ser usado por um processo para funcionalidades técnicas" diff --git a/base_technical_user/i18n/zh_CN.po b/base_technical_user/i18n/zh_CN.po new file mode 100644 index 00000000000..d11ccacd164 --- /dev/null +++ b/base_technical_user/i18n/zh_CN.po @@ -0,0 +1,54 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_technical_user +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-06-16 11:07+0000\n" +"Last-Translator: xtanuiha \n" +"Language-Team: none\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Weblate 4.17\n" + +#. module: base_technical_user +#: model:ir.model,name:base_technical_user.model_base +msgid "Base" +msgstr "基础" + +#. module: base_technical_user +#: model:ir.model,name:base_technical_user.model_res_company +msgid "Companies" +msgstr "公司" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Configuration" +msgstr "配置" + +#. module: base_technical_user +#: model_terms:ir.ui.view,arch_db:base_technical_user.res_company_view_form_inherit_base_technical_user +msgid "Technical Parameters" +msgstr "技术参数" + +#. module: base_technical_user +#: model:ir.model.fields,field_description:base_technical_user.field_res_company__user_tech_id +msgid "Technical User" +msgstr "技术用户" + +#. module: base_technical_user +#. odoo-python +#: code:addons/base_technical_user/models/models.py:0 +#, python-format +msgid "The technical user is missing in the company {}" +msgstr "在公司 {} 中缺少技术用户" + +#. module: base_technical_user +#: model:ir.model.fields,help:base_technical_user.field_res_company__user_tech_id +msgid "This user can be used by process for technical purpose" +msgstr "此用户可由流程用于技术目的" diff --git a/base_technical_user/models/__init__.py b/base_technical_user/models/__init__.py new file mode 100644 index 00000000000..fe04d2730d6 --- /dev/null +++ b/base_technical_user/models/__init__.py @@ -0,0 +1,2 @@ +from . import res_company +from . import models diff --git a/base_technical_user/models/models.py b/base_technical_user/models/models.py new file mode 100644 index 00000000000..513caeb64c3 --- /dev/null +++ b/base_technical_user/models/models.py @@ -0,0 +1,36 @@ +# Copyright 2020 Akretion (http://www.akretion.com). +# @author Sébastien BEAU +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import _, models +from odoo.exceptions import UserError + + +class Base(models.AbstractModel): + _inherit = "base" + + def sudo_tech(self, raise_if_missing=False): + self_sudoer = self + tech_user = self.env.company.user_tech_id + if tech_user: + self_sudoer = self.with_user(tech_user.id) + # We restrict the allowed companies to the one of the tech user + allowed_company_ids = self.env.context.get("allowed_company_ids") + # TODO: Is any(...) part necessary as we can + # consider company should always be the one of the tech_user ? + if allowed_company_ids and any( + company + for company in allowed_company_ids + if company != tech_user.company_id.id + ): + self_sudoer = self_sudoer.with_context( + allowed_company_ids=self.env.company.ids + ) + elif raise_if_missing: + raise UserError( + _("The technical user is missing in the company {}").format( + self.env.company.name + ) + ) + return self_sudoer diff --git a/base_technical_user/models/res_company.py b/base_technical_user/models/res_company.py new file mode 100644 index 00000000000..1183c0e05cf --- /dev/null +++ b/base_technical_user/models/res_company.py @@ -0,0 +1,14 @@ +# Copyright 2017 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ResCompany(models.Model): + _inherit = "res.company" + + user_tech_id = fields.Many2one( + comodel_name="res.users", + string="Technical User", + help="This user can be used by process for technical purpose", + domain="[('company_id', '=', id)]", + ) diff --git a/base_technical_user/pyproject.toml b/base_technical_user/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/base_technical_user/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/base_technical_user/readme/CONTRIBUTORS.md b/base_technical_user/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..2644f0870ae --- /dev/null +++ b/base_technical_user/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Cédric Pigeon \<\> +- Khoi (Kien Kim) \<\> diff --git a/base_technical_user/readme/CREDITS.md b/base_technical_user/readme/CREDITS.md new file mode 100644 index 00000000000..53c8a2a63c6 --- /dev/null +++ b/base_technical_user/readme/CREDITS.md @@ -0,0 +1,2 @@ +The migration of this module from 17.0 to 18.0 was financially supported by: +- Camptocamp. diff --git a/base_technical_user/readme/DESCRIPTION.md b/base_technical_user/readme/DESCRIPTION.md new file mode 100644 index 00000000000..b320a19677b --- /dev/null +++ b/base_technical_user/readme/DESCRIPTION.md @@ -0,0 +1,6 @@ +This module extends the functionality of company management. It allows +you to bind a technical user on the company in order to use it in batch +processes. + +The technical user must - be inactive to avoid login - be in the +required groups depending of what you need to do diff --git a/base_technical_user/readme/USAGE.md b/base_technical_user/readme/USAGE.md new file mode 100644 index 00000000000..6be4945fc1c --- /dev/null +++ b/base_technical_user/readme/USAGE.md @@ -0,0 +1,18 @@ +If you install the module, you will find a tab on the company form +allowing to define the technical user. + +In your code you can use the following helper that will return you + +- a self with the user tech if configured +- or a self with sudo user + +``` python +self_tech = self.sudo_tech() +``` + +If you want to raise an error if the tech user in not configured just +call it with + +``` python +self_tech = self.sudo_tech(raise_if_missing) +``` diff --git a/base_technical_user/static/description/icon.png b/base_technical_user/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/base_technical_user/static/description/icon.png differ diff --git a/base_technical_user/static/description/index.html b/base_technical_user/static/description/index.html new file mode 100644 index 00000000000..714c1466297 --- /dev/null +++ b/base_technical_user/static/description/index.html @@ -0,0 +1,456 @@ + + + + + +Base Technical User + + + +
+

Base Technical User

+ + +

Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runboat

+

This module extends the functionality of company management. It allows +you to bind a technical user on the company in order to use it in batch +processes.

+

The technical user must - be inactive to avoid login - be in the +required groups depending of what you need to do

+

Table of contents

+ +
+

Usage

+

If you install the module, you will find a tab on the company form +allowing to define the technical user.

+

In your code you can use the following helper that will return you

+
    +
  • a self with the user tech if configured
  • +
  • or a self with sudo user
  • +
+
+self_tech = self.sudo_tech()
+
+

If you want to raise an error if the tech user in not configured just +call it with

+
+self_tech = self.sudo_tech(raise_if_missing)
+
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE SA/NV
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The migration of this module from 17.0 to 18.0 was financially supported +by:

+
    +
  • Camptocamp.
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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/server-tools project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/base_technical_user/tests/__init__.py b/base_technical_user/tests/__init__.py new file mode 100644 index 00000000000..2775d65064a --- /dev/null +++ b/base_technical_user/tests/__init__.py @@ -0,0 +1 @@ +from . import test_sudo_tech diff --git a/base_technical_user/tests/test_sudo_tech.py b/base_technical_user/tests/test_sudo_tech.py new file mode 100644 index 00000000000..19a3ac395ad --- /dev/null +++ b/base_technical_user/tests/test_sudo_tech.py @@ -0,0 +1,81 @@ +# Copyright 2020 Akretion (http://www.akretion.com). +# @author Sébastien BEAU +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import SUPERUSER_ID +from odoo.exceptions import UserError +from odoo.tests import TransactionCase + + +class SudoTechCase(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.company = cls.env.ref("base.main_company") + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + cls.company_2 = cls.env["res.company"].create( + { + "name": "Company 2 tech", + } + ) + cls.company_3 = cls.env["res.company"].create( + { + "name": "Company 3 NO tech", + "user_tech_id": False, + } + ) + cls.user_tech = ( + cls.env["res.users"] + .with_context(no_reset_password=True) + .create({"login": "tech", "name": "tech"}) + ) + cls.user_tech_2 = ( + cls.env["res.users"] + .with_context(no_reset_password=True) + .with_company(cls.company_2) + .create({"login": "tech2", "name": "tech2", "company_id": cls.company_2.id}) + ) + cls.env(user=cls.env.ref("base.user_demo").id) + + def test_sudo_tech(self): + self.company.user_tech_id = self.user_tech + self_tech = self.env["res.partner"].sudo_tech() + self.assertEqual(self_tech._uid, self.user_tech.id) + + def test_sudo_tech_missing_return_sudo(self): + self_tech = self.env["res.partner"].sudo_tech() + self.assertEqual(self_tech._uid, SUPERUSER_ID) + + def test_sudo_tech_missing_raise(self): + with self.assertRaises(UserError): + self.env["res.partner"].sudo_tech(raise_if_missing=True) + + def test_sudo_tech_company_2(self): + self.company_2.user_tech_id = self.user_tech_2 + self_tech = self.env["res.partner"].with_company(self.company_2).sudo_tech() + self.assertEqual(self_tech._uid, self.user_tech_2.id) + + def test_sudo_tech_company_2_record(self): + # We switch company twice to fill in allowed_company_ids + user = self.env.user.with_company(self.company_2).with_company(self.company) + self.assertEqual( + self.company, + user.env.company, + ) + self.company_2.user_tech_id = self.user_tech_2 + self_tech = user.with_company(self.company_2).sudo_tech() + self.assertEqual(self_tech._uid, self.user_tech_2.id) + + def test_sudo_tech_company_3(self): + """ + Ensure the error message is related to the + active company when there is no technical user. + """ + user = self.env.user.with_company(self.company_3) + self.assertEqual(self.company_3, user.env.company) + self.assertNotEqual(user.env.company, user.company_id) + with self.assertRaises(UserError) as em: + user.sudo_tech(raise_if_missing=True) + self.assertIn(self.company_3.name, em.exception.args[0]) + self.assertNotIn(user.company_id.name, em.exception.args[0]) diff --git a/base_technical_user/views/res_company_view.xml b/base_technical_user/views/res_company_view.xml new file mode 100644 index 00000000000..3a7675aa603 --- /dev/null +++ b/base_technical_user/views/res_company_view.xml @@ -0,0 +1,24 @@ + + + + res.company.form (base_technical_user) + res.company + + 20 + + + + + + + + + + + + +