diff --git a/web_m2x_options/README.rst b/web_m2x_options/README.rst new file mode 100644 index 000000000000..1142f3bf8670 --- /dev/null +++ b/web_m2x_options/README.rst @@ -0,0 +1,232 @@ +=============== +web_m2x_options +=============== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:36f18dc3f0b0b3d8b91f63aa88d55c4936d53fef5857b1dcb903308b536c79c4 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/18.0/web_m2x_options + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_m2x_options + :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/web&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This modules modifies "many2one" and "many2manytags" form widgets so as +to add some new display control options. + +Options provided includes possibility to remove "Create..." and/or +"Create and Edit..." entries drop down. You can also change default +number of proposition appearing in the drop-down. + +If not specified, the module will avoid proposing any of the create +options if the current user has no permission rights to create the +related object. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +in the field's options dict +--------------------------- + +``create`` *boolean* (Default: depends if user have create rights) + + Whether to display the "Create..." entry in dropdown panel. Only for + m2o fields. + +``create_edit`` *boolean* (Default: depends if user have create rights) + + Whether to display "Create and Edit..." entry in dropdown panel + +``limit`` *int* (Default: odoo default value is ``8``) + + Number of displayed record in drop-down panel + +``search_more`` *boolean* + + Used to force disable/enable search more button. + +``field_color`` *string* + + A string to define the field used to define color. This option has to + be used with colors. + +``colors`` *dictionary* + + A dictionary to link field value with a HTML color. This option has + to be used with field_color. + +``open`` *boolean* (Default: ``False``) + + Makes many2one buttons that open the linked resource. + +ir.config_parameter options +--------------------------- + +Now you can disable "Create..." and "Create and Edit..." entry for all +widgets in the odoo instance. If you disable one option, you can enable +it for particular field by setting "create: True" option directly on the +field definition. + +``web_m2x_options.create`` *boolean* (Default: depends if user have +create rights) + + Whether to display the "Create..." entry in dropdown panel for all + fields in the odoo instance. + +``web_m2x_options.create_edit`` *boolean* (Default: depends if user have +create rights) + + Whether to display "Create and Edit..." entry in dropdown panel for + all fields in the odoo instance. + +``web_m2x_options.limit`` *int* (Default: odoo default value is ``8``) + + Number of displayed record in drop-down panel for all fields in the + odoo instance + +``web_m2x_options.search_more`` *boolean* (Default: default value is +``False``) + + Whether the field should always show "Search more..." entry or not. + +``web_m2x_options.field_limit_entries`` *int* + + Number of displayed lines on all One2many fields + +To add these parameters go to Configuration -> Technical -> Parameters +-> System Parameters and add new parameters like: + +- web_m2x_options.create: False +- web_m2x_options.create_edit: False +- web_m2x_options.limit: 10 +- web_m2x_options.search_more: True +- web_m2x_options.field_limit_entries: 5 + +Example +------- + +Your XML form view definition could contain: + +.. code:: xml + + ... + + ... + +Known issues / Roadmap +====================== + +Double check that you have no inherited view that remove ``options`` you +set on a field ! If nothing works, add a debugger in the first line of +``_search method`` and enable debug mode in Odoo. When you write +something in a many2one field, javascript debugger should pause. If not +verify your installation. + +- Instead of making the tags rectangle clickable, I think it's better + to put the text as a clickable link, so we will get a consistent + behaviour/aspect with other clickable elements (many2one...). + +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 +------- + +* initOS GmbH +* ACSONE SA/NV +* 0k.io +* Tecnativa +* Sygel + +Contributors +------------ + +- David Coninckx + +- Emanuel Cino + +- Holger Brunn + +- Nicolas JEUDY + +- Yannick Vaucher + +- Zakaria Makrelouf + +- `Tecnativa `__: + + - Jairo Llopis + - David Vidal + - Ernesto Tejeda + - Carlos Roca + +- Bhavesh Odedra + +- Dhara Solanki (http://www.initos.com) + +- `Trobz `__: + + - Hoang Diep + +- `Sygel `__: + + - Manuel Regidor + - Valentín Vinagre + - Harald Panten + +- Siddharth Bhalgami + +Other credits +------------- + +The migration of this module from 15.0 to 16.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/web `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_m2x_options/__init__.py b/web_m2x_options/__init__.py new file mode 100644 index 000000000000..0650744f6bc6 --- /dev/null +++ b/web_m2x_options/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/web_m2x_options/__manifest__.py b/web_m2x_options/__manifest__.py new file mode 100644 index 000000000000..8000c6bdedbb --- /dev/null +++ b/web_m2x_options/__manifest__.py @@ -0,0 +1,32 @@ +# Copyright 2015 0k.io +# Copyright 2016 ACSONE SA/NV +# Copyright 2017 Tecnativa +# Copyright 2020 initOS GmbH. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "web_m2x_options", + "version": "18.0.1.0.0", + "category": "Web", + "author": "initOS GmbH," + "ACSONE SA/NV, " + "0k.io, " + "Tecnativa, " + "Sygel, " + "Siddharth Bhalgami, " + "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/web", + "license": "AGPL-3", + "depends": ["web"], + "assets": { + "web.assets_backend": [ + ( + "before", + "web/static/src/views/fields/*", + "web_m2x_options/static/src/components/form.esm.js", + ), + "web_m2x_options/static/src/components/base.xml", + ] + }, + "installable": True, +} diff --git a/web_m2x_options/i18n/ar.po b/web_m2x_options/i18n/ar.po new file mode 100644 index 000000000000..e05575208b7d --- /dev/null +++ b/web_m2x_options/i18n/ar.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_m2x_options +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-01-03 03:50+0000\n" +"PO-Revision-Date: 2018-01-03 03:50+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Arabic (https://www.transifex.com/oca/teams/23907/ar/)\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 && n%100<=99 ? 4 : 5;\n" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_http +msgid "HTTP Routing" +msgstr "" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_config_parameter +msgid "System Parameter" +msgstr "" + +#, python-format +#~ msgid "Search More..." +#~ msgstr "البحث عن المزيد ..." + +#, python-format +#~ msgid "Cancel" +#~ msgstr "إلغاء" + +#, python-format +#~ msgid "Create \"%s\"" +#~ msgstr "إنشاء \"%s\"" + +#, python-format +#~ msgid "Create and Edit..." +#~ msgstr "إنشاء وتحرير ..." diff --git a/web_m2x_options/i18n/de.po b/web_m2x_options/i18n/de.po new file mode 100644 index 000000000000..2e79349f23a2 --- /dev/null +++ b/web_m2x_options/i18n/de.po @@ -0,0 +1,117 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_m2x_options +# +# Translators: +# OCA Transbot , 2017 +# Rudolf Schnapka , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-01-03 03:50+0000\n" +"PO-Revision-Date: 2023-06-20 11:09+0000\n" +"Last-Translator: Nils Coenen \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" +"X-Generator: Weblate 4.17\n" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_http +msgid "HTTP Routing" +msgstr "" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_config_parameter +msgid "System Parameter" +msgstr "Systemparameter" + +#, python-format +#~ msgid ", are you sure it does not exist yet?" +#~ msgstr ", bist du sicher, dass es noch nicht existiert?" + +#, python-format +#~ msgid "Create" +#~ msgstr "Anlegen" + +#, python-format +#~ msgid "Create \"%s\"" +#~ msgstr "Erstelle \"%s\"" + +#, python-format +#~ msgid "Create and Edit" +#~ msgstr "Erstellen und bearbeiten" + +#, python-format +#~ msgid "Create and edit..." +#~ msgstr "Erstellen und bearbeiten..." + +#, python-format +#~ msgid "Discard" +#~ msgstr "Verwerfen" + +#, python-format +#~ msgid "New: %s" +#~ msgstr "Neu: %s" + +#, python-format +#~ msgid "No records" +#~ msgstr "Keine Datensätze" + +#, python-format +#~ msgid "Open: " +#~ msgstr "Öffnen: " + +#, python-format +#~ msgid "Search More..." +#~ msgstr "Suche weitere..." + +#, python-format +#~ msgid "Start typing..." +#~ msgstr "Beginne zu tippen..." + +#, python-format +#~ msgid "You are creating a new" +#~ msgstr "Du erstellst ein Neues" + +#, python-format +#~ msgid "as a new" +#~ msgstr "als neu" + +#, python-format +#~ msgid "Cancel" +#~ msgstr "Abbrechen" + +#, python-format +#~ msgid "Create \"%s\"" +#~ msgstr "Anlegen \"%s" + +#, python-format +#~ msgid "Create a %s" +#~ msgstr "Eine %s anlegen" + +#, python-format +#~ msgid "Create and Edit..." +#~ msgstr "Anlegen und Bearbeiten" + +#, python-format +#~ msgid "Create and edit" +#~ msgstr "Anlegen und bearbeiten" + +#, python-format +#~ msgid "No results to show..." +#~ msgstr "Keine Resultate zu zeigen..." + +#, python-format +#~ msgid "Quick search: %s" +#~ msgstr "Schnellsuche: %s" + +#, python-format +#~ msgid "You are creating a new %s, are you sure it does not exist yet?" +#~ msgstr "" +#~ "Sie legen eine neue %s an, sind Sie sicher, dass diese nicht bereits " +#~ "vorhanden ist?" diff --git a/web_m2x_options/i18n/es.po b/web_m2x_options/i18n/es.po new file mode 100644 index 000000000000..803eeaee4b8d --- /dev/null +++ b/web_m2x_options/i18n/es.po @@ -0,0 +1,106 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_m2x_options +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-01-03 03:50+0000\n" +"PO-Revision-Date: 2023-09-02 20:35+0000\n" +"Last-Translator: Ivorra78 \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: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_http +msgid "HTTP Routing" +msgstr "Enrutamiento HTTP" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_config_parameter +msgid "System Parameter" +msgstr "Parámetro del Sistema" + +#, python-format +#~ msgid ", are you sure it does not exist yet?" +#~ msgstr ",¿Está seguro de que aún no existe?" + +#, python-format +#~ msgid "Create" +#~ msgstr "Crear" + +#, python-format +#~ msgid "Create \"%s\"" +#~ msgstr "Crear \"%s\"" + +#, python-format +#~ msgid "Create and Edit" +#~ msgstr "Crear y Editar" + +#, python-format +#~ msgid "Create and edit..." +#~ msgstr "Crear y editar..." + +#, python-format +#~ msgid "Discard" +#~ msgstr "Descartar" + +#, python-format +#~ msgid "New: %s" +#~ msgstr "Nuevo: %s" + +#, python-format +#~ msgid "No records" +#~ msgstr "Sin registros" + +#, python-format +#~ msgid "Open: " +#~ msgstr "Abrir " + +#, python-format +#~ msgid "Search More..." +#~ msgstr "Buscar más..." + +#, python-format +#~ msgid "Start typing..." +#~ msgstr "Empieza a escribir..." + +#, python-format +#~ msgid "You are creating a new" +#~ msgstr "Estás creando un nuevo" + +#, python-format +#~ msgid "as a new" +#~ msgstr "como un nuevo" + +#, python-format +#~ msgid "Cancel" +#~ msgstr "Cancelar" + +#, python-format +#~ msgid "Create \"%s\"" +#~ msgstr "Crear \"%s\"" + +#, python-format +#~ msgid "Create a %s" +#~ msgstr "Crear un %s" + +#, python-format +#~ msgid "Create and Edit..." +#~ msgstr "Crear y editar..." + +#, python-format +#~ msgid "Create and edit" +#~ msgstr "Crear y editar" + +#, python-format +#~ msgid "You are creating a new %s, are you sure it does not exist yet?" +#~ msgstr "Está creando un nuevo %s, ¿está seguro de no existe ya?" diff --git a/web_m2x_options/i18n/es_BO.po b/web_m2x_options/i18n/es_BO.po new file mode 100644 index 000000000000..69c7a33e9b9c --- /dev/null +++ b/web_m2x_options/i18n/es_BO.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_m2x_options +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: es_BO\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: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_http +msgid "HTTP Routing" +msgstr "" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_config_parameter +msgid "System Parameter" +msgstr "" diff --git a/web_m2x_options/i18n/fi.po b/web_m2x_options/i18n/fi.po new file mode 100644 index 000000000000..a4643a39e7cd --- /dev/null +++ b/web_m2x_options/i18n/fi.po @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_m2x_options +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-01-03 03:50+0000\n" +"PO-Revision-Date: 2018-01-03 03:50+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Finnish (https://www.transifex.com/oca/teams/23907/fi/)\n" +"Language: fi\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: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_http +msgid "HTTP Routing" +msgstr "" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_config_parameter +msgid "System Parameter" +msgstr "" + +#, python-format +#~ msgid "Search More..." +#~ msgstr "Hae lisää..." + +#, python-format +#~ msgid "Cancel" +#~ msgstr "Peru" + +#, python-format +#~ msgid "Create \"%s\"" +#~ msgstr "Luo \"%s\"" + +#, python-format +#~ msgid "Create and Edit..." +#~ msgstr "Luo ja muokkaa..." diff --git a/web_m2x_options/i18n/fr.po b/web_m2x_options/i18n/fr.po new file mode 100644 index 000000000000..8333ac7df810 --- /dev/null +++ b/web_m2x_options/i18n/fr.po @@ -0,0 +1,92 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_m2x_options +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-01-03 03:50+0000\n" +"PO-Revision-Date: 2024-02-02 11:35+0000\n" +"Last-Translator: Hughes Damry \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.17\n" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_http +msgid "HTTP Routing" +msgstr "" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_config_parameter +msgid "System Parameter" +msgstr "Paramètres système" + +#, python-format +#~ msgid ", are you sure it does not exist yet?" +#~ msgstr ", êtes-vous sûr qu'il n'existe pas déjà ?" + +#, python-format +#~ msgid "Create" +#~ msgstr "Créer" + +#, python-format +#~ msgid "Create and Edit" +#~ msgstr "Créer et Modifier" + +#, python-format +#~ msgid "Create and edit..." +#~ msgstr "Créer et modifier..." + +#, python-format +#~ msgid "Open: " +#~ msgstr "Ouvrir : " + +#, python-format +#~ msgid "Search More..." +#~ msgstr "Rechercher plus..." + +#, python-format +#~ msgid "You are creating a new" +#~ msgstr "Vous créez un nouveau" + +#, python-format +#~ msgid "Cancel" +#~ msgstr "Annuler" + +#, python-format +#~ msgid "Create \"%s\"" +#~ msgstr "Creer \"%s\"" + +#, python-format +#~ msgid "Create a %s" +#~ msgstr "Créer un %s" + +#, python-format +#~ msgid "Create and Edit..." +#~ msgstr "Créer et modifier..." + +#, python-format +#~ msgid "Create and edit" +#~ msgstr "Créer et modifier" + +#, python-format +#~ msgid "No results to show..." +#~ msgstr "Aucun résultat à afficher..." + +#, python-format +#~ msgid "Quick search: %s" +#~ msgstr "Recherche rapide: %s" + +#, python-format +#~ msgid "You are creating a new %s, are you sure it does not exist yet?" +#~ msgstr "" +#~ "Vous créez un nouveau %s, est-ce que vous êtes sur qu'il n'existe pas " +#~ "déjà ?" diff --git a/web_m2x_options/i18n/hr.po b/web_m2x_options/i18n/hr.po new file mode 100644 index 000000000000..a5fdf1fffaf4 --- /dev/null +++ b/web_m2x_options/i18n/hr.po @@ -0,0 +1,63 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_m2x_options +# +# Translators: +# Bole , 2017 +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-01-03 03:50+0000\n" +"PO-Revision-Date: 2018-01-03 03:50+0000\n" +"Last-Translator: OCA Transbot , 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: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_http +msgid "HTTP Routing" +msgstr "" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_config_parameter +msgid "System Parameter" +msgstr "" + +#, python-format +#~ msgid "Create" +#~ msgstr "Kreiraj" + +#, python-format +#~ msgid "Search More..." +#~ msgstr "Traži dalje..." + +#, python-format +#~ msgid "Cancel" +#~ msgstr "Otkaži" + +#, python-format +#~ msgid "Create \"%s\"" +#~ msgstr "Kreiraj \" %s\"" + +#, python-format +#~ msgid "Create a %s" +#~ msgstr "Kreiraj %s" + +#, python-format +#~ msgid "Create and Edit..." +#~ msgstr "Kreiraj i uredi..." + +#, python-format +#~ msgid "Create and edit" +#~ msgstr "Kreiraj i uredi" + +#, python-format +#~ msgid "You are creating a new %s, are you sure it does not exist yet?" +#~ msgstr "Želite kreirati novi %s, jeste li sigurni da već ne postoji?" diff --git a/web_m2x_options/i18n/it.po b/web_m2x_options/i18n/it.po new file mode 100644 index 000000000000..8933130947ad --- /dev/null +++ b/web_m2x_options/i18n/it.po @@ -0,0 +1,94 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_m2x_options +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-01-03 03:50+0000\n" +"PO-Revision-Date: 2023-12-24 18:42+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: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_http +msgid "HTTP Routing" +msgstr "Instradamento HTTP" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_config_parameter +msgid "System Parameter" +msgstr "Parametro di sistema" + +#, python-format +#~ msgid ", are you sure it does not exist yet?" +#~ msgstr ", si è sicuri che nn esista già?" + +#, python-format +#~ msgid "Create" +#~ msgstr "Crea" + +#, python-format +#~ msgid "Create \"%s\"" +#~ msgstr "Crea \"%s\"" + +#, python-format +#~ msgid "Create and Edit" +#~ msgstr "Crea e modifica" + +#, python-format +#~ msgid "Create and edit..." +#~ msgstr "Crea e modifica..." + +#, python-format +#~ msgid "Discard" +#~ msgstr "Abbandona" + +#, python-format +#~ msgid "New: %s" +#~ msgstr "Nuovo: %s" + +#, python-format +#~ msgid "No records" +#~ msgstr "Nessun record" + +#, python-format +#~ msgid "Open: " +#~ msgstr "Apri: " + +#, python-format +#~ msgid "Search More..." +#~ msgstr "Cerca altro..." + +#, python-format +#~ msgid "Start typing..." +#~ msgstr "Inizia a scrivere..." + +#, python-format +#~ msgid "You are creating a new" +#~ msgstr "Si sta creando un nuovo" + +#, python-format +#~ msgid "as a new" +#~ msgstr "come nuovo" + +#, python-format +#~ msgid "Cancel" +#~ msgstr "Annulla" + +#, python-format +#~ msgid "Create \"%s\"" +#~ msgstr "Crea \"%s\"" + +#, python-format +#~ msgid "Create and Edit..." +#~ msgstr "Crea e Modifica..." diff --git a/web_m2x_options/i18n/nl.po b/web_m2x_options/i18n/nl.po new file mode 100644 index 000000000000..251b4202a920 --- /dev/null +++ b/web_m2x_options/i18n/nl.po @@ -0,0 +1,80 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_m2x_options +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-05-17 20:47+0000\n" +"Last-Translator: Bosd \n" +"Language-Team: none\n" +"Language: 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" +"X-Generator: Weblate 4.3.2\n" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_http +msgid "HTTP Routing" +msgstr "" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_config_parameter +msgid "System Parameter" +msgstr "Systeem Parameter" + +#, python-format +#~ msgid "Create" +#~ msgstr "Aanmaken" + +#, python-format +#~ msgid "Open: " +#~ msgstr "Open: " + +#, python-format +#~ msgid "Search More..." +#~ msgstr "Zoek meer..." + +#, python-format +#~ msgid "Cancel" +#~ msgstr "Annuleren" + +#, fuzzy, python-format +#~ msgid "Create \"%s\"" +#~ msgstr "Creér%s\"" + +#, python-format +#~ msgid "Create a %s" +#~ msgstr "Maak een %s" + +#, python-format +#~ msgid "Create and Edit..." +#~ msgstr "Aanmaken en bewerken..." + +#, python-format +#~ msgid "Create and edit" +#~ msgstr "Aanmaken en bewerken" + +#, python-format +#~ msgid "No results to show..." +#~ msgstr "Geen resultaten om weer te geven..." + +#, python-format +#~ msgid "Quick search: %s" +#~ msgstr "Snel zoeken: %s" + +#, python-format +#~ msgid "You are creating a new %s, are you sure it does not exist yet?" +#~ msgstr "U maakt een nieuw %s, weet u het zeker dat dit nog niet bestaat?" + +#~ msgid "Display Name" +#~ msgstr "Weergavenaam" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Laatst Gewijzigd op" diff --git a/web_m2x_options/i18n/nl_NL.po b/web_m2x_options/i18n/nl_NL.po new file mode 100644 index 000000000000..d37b1ed9752e --- /dev/null +++ b/web_m2x_options/i18n/nl_NL.po @@ -0,0 +1,38 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_m2x_options +# +# Translators: +# Peter Hageman , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-01 03:35+0000\n" +"PO-Revision-Date: 2017-07-01 03:35+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: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_http +msgid "HTTP Routing" +msgstr "" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_config_parameter +msgid "System Parameter" +msgstr "" + +#, python-format +#~ msgid "Create" +#~ msgstr "Aanmaken" + +#, python-format +#~ msgid "Cancel" +#~ msgstr "Annuleer" diff --git a/web_m2x_options/i18n/pt_BR.po b/web_m2x_options/i18n/pt_BR.po new file mode 100644 index 000000000000..52feb8612ff3 --- /dev/null +++ b/web_m2x_options/i18n/pt_BR.po @@ -0,0 +1,114 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_m2x_options +# +# Translators: +# OCA Transbot , 2017 +# Rodrigo de Almeida Sottomaior Macedo , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-01-03 03:50+0000\n" +"PO-Revision-Date: 2024-05-29 19:34+0000\n" +"Last-Translator: Rodrigo Macedo \n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/" +"teams/23907/pt_BR/)\n" +"Language: pt_BR\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: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_http +msgid "HTTP Routing" +msgstr "Roteamento HTTP" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_config_parameter +msgid "System Parameter" +msgstr "Parâmetros do Sistema" + +#, python-format +#~ msgid ", are you sure it does not exist yet?" +#~ msgstr ", tem certeza que ainda não existe?" + +#, python-format +#~ msgid "Create" +#~ msgstr "Criar" + +#, python-format +#~ msgid "Create \"%s\"" +#~ msgstr "Criar \"%s\"" + +#, python-format +#~ msgid "Create and Edit" +#~ msgstr "Criar e Editar" + +#, python-format +#~ msgid "Create and edit..." +#~ msgstr "Criar e editar..." + +#, python-format +#~ msgid "Discard" +#~ msgstr "Descartar" + +#, python-format +#~ msgid "New: %s" +#~ msgstr "Novo: %s" + +#, python-format +#~ msgid "No records" +#~ msgstr "Sem registros" + +#, python-format +#~ msgid "Open: " +#~ msgstr "Abrir: " + +#, python-format +#~ msgid "Search More..." +#~ msgstr "Buscar mais..." + +#, python-format +#~ msgid "Start typing..." +#~ msgstr "Comece a digitar..." + +#, python-format +#~ msgid "You are creating a new" +#~ msgstr "Você está criando um novo" + +#, python-format +#~ msgid "as a new" +#~ msgstr "como um novo" + +#, python-format +#~ msgid "Cancel" +#~ msgstr "Cancelar" + +#, python-format +#~ msgid "Create \"%s\"" +#~ msgstr "Criar \"%s\"" + +#, python-format +#~ msgid "Create a %s" +#~ msgstr "Criar um %s" + +#, python-format +#~ msgid "Create and Edit..." +#~ msgstr "Criar e editar.." + +#, python-format +#~ msgid "Create and edit" +#~ msgstr "Criar e editar" + +#, python-format +#~ msgid "No results to show..." +#~ msgstr "sem resultado para mostrar..." + +#, python-format +#~ msgid "You are creating a new %s, are you sure it does not exist yet?" +#~ msgstr "" +#~ "Você está criando um novo %s, você tem certeza de que ainda não existe?" diff --git a/web_m2x_options/i18n/sl.po b/web_m2x_options/i18n/sl.po new file mode 100644 index 000000000000..8429ebc3ee6b --- /dev/null +++ b/web_m2x_options/i18n/sl.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_m2x_options +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-01-03 03:50+0000\n" +"PO-Revision-Date: 2018-01-03 03:50+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || " +"n%100==4 ? 2 : 3);\n" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_http +msgid "HTTP Routing" +msgstr "" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_config_parameter +msgid "System Parameter" +msgstr "" + +#, python-format +#~ msgid "Search More..." +#~ msgstr "Poišči več..." + +#, python-format +#~ msgid "Cancel" +#~ msgstr "Preklic" + +#, python-format +#~ msgid "Create \"%s\"" +#~ msgstr "Ustvari \"%s\"" + +#, python-format +#~ msgid "Create and Edit..." +#~ msgstr "Ustvari in urejaj..." diff --git a/web_m2x_options/i18n/tr.po b/web_m2x_options/i18n/tr.po new file mode 100644 index 000000000000..c08876152445 --- /dev/null +++ b/web_m2x_options/i18n/tr.po @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_m2x_options +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-01-03 03:50+0000\n" +"PO-Revision-Date: 2018-01-03 03:50+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Turkish (https://www.transifex.com/oca/teams/23907/tr/)\n" +"Language: tr\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: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_http +msgid "HTTP Routing" +msgstr "" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_config_parameter +msgid "System Parameter" +msgstr "" + +#, python-format +#~ msgid "Search More..." +#~ msgstr "Daha Fazla..." + +#, python-format +#~ msgid "Cancel" +#~ msgstr "İptal" + +#, python-format +#~ msgid "Create \"%s\"" +#~ msgstr "Oluştur \"%s\"" + +#, python-format +#~ msgid "Create and Edit..." +#~ msgstr "Oluştur ve düzenle..." diff --git a/web_m2x_options/i18n/web_m2x_options.pot b/web_m2x_options/i18n/web_m2x_options.pot new file mode 100644 index 000000000000..9bec14cdef0e --- /dev/null +++ b/web_m2x_options/i18n/web_m2x_options.pot @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_m2x_options +# +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: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_http +msgid "HTTP Routing" +msgstr "" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_config_parameter +msgid "System Parameter" +msgstr "" diff --git a/web_m2x_options/i18n/zh_CN.po b/web_m2x_options/i18n/zh_CN.po new file mode 100644 index 000000000000..8c2aa4c8cf67 --- /dev/null +++ b/web_m2x_options/i18n/zh_CN.po @@ -0,0 +1,71 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_m2x_options +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-07-08 05:19+0000\n" +"Last-Translator: 黎伟杰 <674416404@qq.com>\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 3.10\n" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_http +msgid "HTTP Routing" +msgstr "" + +#. module: web_m2x_options +#: model:ir.model,name:web_m2x_options.model_ir_config_parameter +msgid "System Parameter" +msgstr "系统参数" + +#, python-format +#~ msgid "Create" +#~ msgstr "创建" + +#, python-format +#~ msgid "Open: " +#~ msgstr "打开: " + +#, python-format +#~ msgid "Search More..." +#~ msgstr "搜索更多..." + +#, python-format +#~ msgid "Cancel" +#~ msgstr "取消" + +#, python-format +#~ msgid "Create \"%s\"" +#~ msgstr "创建 \"%s\"" + +#, python-format +#~ msgid "Create a %s" +#~ msgstr "创建一个%s" + +#, python-format +#~ msgid "Create and Edit..." +#~ msgstr "创建和编辑..." + +#, python-format +#~ msgid "Create and edit" +#~ msgstr "创建和编辑" + +#, python-format +#~ msgid "No results to show..." +#~ msgstr "没有结果显示..." + +#, python-format +#~ msgid "Quick search: %s" +#~ msgstr "快速搜索: %s" + +#, python-format +#~ msgid "You are creating a new %s, are you sure it does not exist yet?" +#~ msgstr "你正在创建一个新的%s,你确定它还不存在吗?" diff --git a/web_m2x_options/models/__init__.py b/web_m2x_options/models/__init__.py new file mode 100644 index 000000000000..60b90d385bc2 --- /dev/null +++ b/web_m2x_options/models/__init__.py @@ -0,0 +1,2 @@ +from . import ir_config_parameter +from . import ir_http diff --git a/web_m2x_options/models/ir_config_parameter.py b/web_m2x_options/models/ir_config_parameter.py new file mode 100644 index 000000000000..9841b57b1c38 --- /dev/null +++ b/web_m2x_options/models/ir_config_parameter.py @@ -0,0 +1,18 @@ +from odoo import api, models + + +class IrConfigParameter(models.Model): + _inherit = "ir.config_parameter" + + @api.model + def get_web_m2x_options(self): + opts = [ + "web_m2x_options.create", + "web_m2x_options.create_edit", + "web_m2x_options.limit", + "web_m2x_options.search_more", + "web_m2x_options.field_limit_entries", + "web_m2x_options.open", + ] + values = self.sudo().search_read([["key", "in", opts]], ["key", "value"]) + return {res["key"]: res["value"] for res in values} diff --git a/web_m2x_options/models/ir_http.py b/web_m2x_options/models/ir_http.py new file mode 100644 index 000000000000..f7933c4d28c1 --- /dev/null +++ b/web_m2x_options/models/ir_http.py @@ -0,0 +1,11 @@ +from odoo import models + + +class Http(models.AbstractModel): + _inherit = "ir.http" + + def session_info(self): + IrConfigSudo = self.env["ir.config_parameter"].sudo() + session_info = super().session_info() + session_info.update({"web_m2x_options": IrConfigSudo.get_web_m2x_options()}) + return session_info diff --git a/web_m2x_options/pyproject.toml b/web_m2x_options/pyproject.toml new file mode 100644 index 000000000000..4231d0cccb3d --- /dev/null +++ b/web_m2x_options/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/web_m2x_options/readme/CONTRIBUTORS.md b/web_m2x_options/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..95d4dc22549a --- /dev/null +++ b/web_m2x_options/readme/CONTRIBUTORS.md @@ -0,0 +1,31 @@ +- David Coninckx \<\> + +- Emanuel Cino \<\> + +- Holger Brunn \<\> + +- Nicolas JEUDY \<\> + +- Yannick Vaucher \<\> + +- Zakaria Makrelouf \<\> + +- [Tecnativa](https://www.tecnativa.com): + - Jairo Llopis \<\> + - David Vidal \<\> + - Ernesto Tejeda \<\> + - Carlos Roca + +- Bhavesh Odedra \<\> + +- Dhara Solanki \<\> () + +- [Trobz](https://trobz.com): + - Hoang Diep \<\> + +- [Sygel](https://sygel.es): + - Manuel Regidor \<\> + - Valentín Vinagre \<\> + - Harald Panten \<\> + +- Siddharth Bhalgami \<\> diff --git a/web_m2x_options/readme/CREDITS.md b/web_m2x_options/readme/CREDITS.md new file mode 100644 index 000000000000..291e14c81e2a --- /dev/null +++ b/web_m2x_options/readme/CREDITS.md @@ -0,0 +1,2 @@ +The migration of this module from 15.0 to 16.0 was financially supported +by Camptocamp diff --git a/web_m2x_options/readme/DESCRIPTION.md b/web_m2x_options/readme/DESCRIPTION.md new file mode 100644 index 000000000000..ad2c876662ad --- /dev/null +++ b/web_m2x_options/readme/DESCRIPTION.md @@ -0,0 +1,10 @@ +This modules modifies "many2one" and "many2manytags" form widgets so as +to add some new display control options. + +Options provided includes possibility to remove "Create..." and/or +"Create and Edit..." entries drop down. You can also change default +number of proposition appearing in the drop-down. + +If not specified, the module will avoid proposing any of the create +options if the current user has no permission rights to create the +related object. diff --git a/web_m2x_options/readme/ROADMAP.md b/web_m2x_options/readme/ROADMAP.md new file mode 100644 index 000000000000..48e3fe77135e --- /dev/null +++ b/web_m2x_options/readme/ROADMAP.md @@ -0,0 +1,9 @@ +Double check that you have no inherited view that remove `options` you +set on a field ! If nothing works, add a debugger in the first line of +`_search method` and enable debug mode in Odoo. When you write something +in a many2one field, javascript debugger should pause. If not verify +your installation. + +- Instead of making the tags rectangle clickable, I think it's better to + put the text as a clickable link, so we will get a consistent + behaviour/aspect with other clickable elements (many2one...). diff --git a/web_m2x_options/readme/USAGE.md b/web_m2x_options/readme/USAGE.md new file mode 100644 index 000000000000..22cda9e22278 --- /dev/null +++ b/web_m2x_options/readme/USAGE.md @@ -0,0 +1,83 @@ +## in the field's options dict + +`create` *boolean* (Default: depends if user have create rights) + +> Whether to display the "Create..." entry in dropdown panel. Only for m2o fields. + +`create_edit` *boolean* (Default: depends if user have create rights) + +> Whether to display "Create and Edit..." entry in dropdown panel + +`limit` *int* (Default: odoo default value is `8`) + +> Number of displayed record in drop-down panel + +`search_more` *boolean* + +> Used to force disable/enable search more button. + +`field_color` *string* + +> A string to define the field used to define color. This option has to +> be used with colors. + +`colors` *dictionary* + +> A dictionary to link field value with a HTML color. This option has to +> be used with field_color. + +`open` *boolean* (Default: `False`) + +> Makes many2one buttons that open the linked resource. + +## ir.config_parameter options + +Now you can disable "Create..." and "Create and Edit..." entry for all +widgets in the odoo instance. If you disable one option, you can enable +it for particular field by setting "create: True" option directly on the +field definition. + +`web_m2x_options.create` *boolean* (Default: depends if user have create +rights) + +> Whether to display the "Create..." entry in dropdown panel for all +> fields in the odoo instance. + +`web_m2x_options.create_edit` *boolean* (Default: depends if user have +create rights) + +> Whether to display "Create and Edit..." entry in dropdown panel for +> all fields in the odoo instance. + +`web_m2x_options.limit` *int* (Default: odoo default value is `8`) + +> Number of displayed record in drop-down panel for all fields in the +> odoo instance + +`web_m2x_options.search_more` *boolean* (Default: default value is +`False`) + +> Whether the field should always show "Search more..." entry or not. + +`web_m2x_options.field_limit_entries` *int* + +> Number of displayed lines on all One2many fields + +To add these parameters go to Configuration -\> Technical -\> Parameters +-\> System Parameters and add new parameters like: + +- web_m2x_options.create: False +- web_m2x_options.create_edit: False +- web_m2x_options.limit: 10 +- web_m2x_options.search_more: True +- web_m2x_options.field_limit_entries: 5 + +## Example + +Your XML form view definition could contain: + +``` xml +... + +... +``` diff --git a/web_m2x_options/static/description/icon.png b/web_m2x_options/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/web_m2x_options/static/description/icon.png differ diff --git a/web_m2x_options/static/description/index.html b/web_m2x_options/static/description/index.html new file mode 100644 index 000000000000..4bbe2455d7fa --- /dev/null +++ b/web_m2x_options/static/description/index.html @@ -0,0 +1,561 @@ + + + + + +web_m2x_options + + + +
+

web_m2x_options

+ + +

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

+

This modules modifies “many2one” and “many2manytags” form widgets so as +to add some new display control options.

+

Options provided includes possibility to remove “Create…” and/or +“Create and Edit…” entries drop down. You can also change default +number of proposition appearing in the drop-down.

+

If not specified, the module will avoid proposing any of the create +options if the current user has no permission rights to create the +related object.

+

Table of contents

+ +
+

Usage

+
+

in the field’s options dict

+

create boolean (Default: depends if user have create rights)

+
+Whether to display the “Create…” entry in dropdown panel. Only for +m2o fields.
+

create_edit boolean (Default: depends if user have create rights)

+
+Whether to display “Create and Edit…” entry in dropdown panel
+

limit int (Default: odoo default value is 8)

+
+Number of displayed record in drop-down panel
+

search_more boolean

+
+Used to force disable/enable search more button.
+

field_color string

+
+A string to define the field used to define color. This option has to +be used with colors.
+

colors dictionary

+
+A dictionary to link field value with a HTML color. This option has +to be used with field_color.
+

open boolean (Default: False)

+
+Makes many2one buttons that open the linked resource.
+
+
+

ir.config_parameter options

+

Now you can disable “Create…” and “Create and Edit…” entry for all +widgets in the odoo instance. If you disable one option, you can enable +it for particular field by setting “create: True” option directly on the +field definition.

+

web_m2x_options.create boolean (Default: depends if user have +create rights)

+
+Whether to display the “Create…” entry in dropdown panel for all +fields in the odoo instance.
+

web_m2x_options.create_edit boolean (Default: depends if user have +create rights)

+
+Whether to display “Create and Edit…” entry in dropdown panel for +all fields in the odoo instance.
+

web_m2x_options.limit int (Default: odoo default value is 8)

+
+Number of displayed record in drop-down panel for all fields in the +odoo instance
+

web_m2x_options.search_more boolean (Default: default value is +False)

+
+Whether the field should always show “Search more…” entry or not.
+

web_m2x_options.field_limit_entries int

+
+Number of displayed lines on all One2many fields
+

To add these parameters go to Configuration -> Technical -> Parameters +-> System Parameters and add new parameters like:

+
    +
  • web_m2x_options.create: False
  • +
  • web_m2x_options.create_edit: False
  • +
  • web_m2x_options.limit: 10
  • +
  • web_m2x_options.search_more: True
  • +
  • web_m2x_options.field_limit_entries: 5
  • +
+
+
+

Example

+

Your XML form view definition could contain:

+
+...
+<field name="partner_id" options="{'limit': 10, 'create': false, 'create_edit': false, 'search_more': true, 'field_color':'type', 'colors':{'contact':'green', 'invoice': 'red', 'delivery': 'blue'}}"/>
+...
+
+
+
+
+

Known issues / Roadmap

+

Double check that you have no inherited view that remove options you +set on a field ! If nothing works, add a debugger in the first line of +_search method and enable debug mode in Odoo. When you write +something in a many2one field, javascript debugger should pause. If not +verify your installation.

+
    +
  • Instead of making the tags rectangle clickable, I think it’s better +to put the text as a clickable link, so we will get a consistent +behaviour/aspect with other clickable elements (many2one…).
  • +
+
+
+

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

+
    +
  • initOS GmbH
  • +
  • ACSONE SA/NV
  • +
  • 0k.io
  • +
  • Tecnativa
  • +
  • Sygel
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The migration of this module from 15.0 to 16.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/web project on GitHub.

+

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

+
+
+
+ + diff --git a/web_m2x_options/static/src/components/base.xml b/web_m2x_options/static/src/components/base.xml new file mode 100644 index 000000000000..8cab2b7a0c27 --- /dev/null +++ b/web_m2x_options/static/src/components/base.xml @@ -0,0 +1,30 @@ + + + + + + + {{ option.style }} + + + + + + props.searchLimit + props.fieldColor + props.fieldColorOptions + + + + diff --git a/web_m2x_options/static/src/components/form.esm.js b/web_m2x_options/static/src/components/form.esm.js new file mode 100644 index 000000000000..e76b705e7619 --- /dev/null +++ b/web_m2x_options/static/src/components/form.esm.js @@ -0,0 +1,396 @@ +/** @odoo-module **/ +import {registry} from "@web/core/registry"; +import { + Many2ManyTagsField, + Many2ManyTagsFieldColorEditable, + many2ManyTagsField, +} from "@web/views/fields/many2many_tags/many2many_tags_field"; +import {Many2OneField, many2OneField} from "@web/views/fields/many2one/many2one_field"; +import {FormController} from "@web/views/form/form_controller"; +import { + KanbanMany2OneAvatarField, + Many2OneAvatarField, +} from "@web/views/fields/many2one_avatar/many2one_avatar_field"; +import {Many2ManyTagsAvatarField} from "@web/views/fields/many2many_tags_avatar/many2many_tags_avatar_field"; + +import {Many2XAutocomplete} from "@web/views/fields/relational_utils"; +import {evaluateBooleanExpr} from "@web/core/py_js/py"; +import {isX2Many} from "@web/views/utils"; +import {patch} from "@web/core/utils/patch"; +import {session} from "@web/session"; + +Many2OneField.props = { + ...Many2OneField.props, + noSearchMore: {type: Boolean, optional: true}, + fieldColor: {type: String, optional: true}, + fieldColorOptions: {type: Object, optional: true}, +}; +Many2XAutocomplete.props = { + ...Many2XAutocomplete.props, + fieldColor: {type: String, optional: true}, + fieldColorOptions: {type: Object, optional: true}, +}; + +KanbanMany2OneAvatarField.props = { + ...KanbanMany2OneAvatarField.props, + fieldColor: {type: String, optional: true}, + fieldColorOptions: {type: Object, optional: true}, +}; + +Many2OneAvatarField.props = { + ...Many2OneAvatarField.props, + noSearchMore: {type: Boolean, optional: true}, + fieldColor: {type: String, optional: true}, + fieldColorOptions: {type: Object, optional: true}, +}; + +Many2ManyTagsField.props = { + ...Many2ManyTagsField.props, + searchLimit: {type: Number, optional: true}, + fieldColor: {type: String, optional: true}, + fieldColorOptions: {type: Object, optional: true}, +}; + +Many2ManyTagsFieldColorEditable.props = { + ...Many2ManyTagsFieldColorEditable.props, + searchLimit: {type: Number, optional: true}, + fieldColor: {type: String, optional: true}, + fieldColorOptions: {type: Object, optional: true}, +}; + +Many2ManyTagsAvatarField.props = { + ...Many2ManyTagsAvatarField.props, + fieldColor: {type: String, optional: true}, + fieldColorOptions: {type: Object, optional: true}, +}; + +patch(many2OneField, { + m2oOptionsPropsCreate(props, attrs, options) { + const ir_options = session.web_m2x_options; + if (options.create === false) { + props.canQuickCreate = false; + } else if (options.create) { + props.canQuickCreate = attrs.can_create + ? evaluateBooleanExpr(attrs.can_create) + : true; + } else if ( + ir_options["web_m2x_options.create"] === "False" && + props.canQuickCreate + ) { + props.canQuickCreate = false; + } else if ( + ir_options["web_m2x_options.create"] === "True" && + !props.canQuickCreate + ) { + props.canQuickCreate = attrs.can_create + ? evaluateBooleanExpr(attrs.can_create) + : true; + } + return props; + }, + + m2oOptionsPropsCreateEdit(props, attrs, options) { + const ir_options = session.web_m2x_options; + if (options.create_edit === false) { + props.canCreateEdit = false; + } else if (options.create_edit) { + // Same condition set in web/views/fields/many2one/many2one_field + props.canCreateEdit = attrs.can_create + ? evaluateBooleanExpr(attrs.can_create) + : true; + } else if ( + ir_options["web_m2x_options.create_edit"] === "False" && + props.canCreateEdit + ) { + props.canCreateEdit = false; + } else if ( + ir_options["web_m2x_options.create_edit"] === "True" && + !props.canCreateEdit + ) { + // Same condition set in web/views/fields/many2one/many2one_field + props.canCreateEdit = attrs.can_create + ? evaluateBooleanExpr(attrs.can_create) + : true; + } + return props; + }, + + m2oOptionsPropsLimit(props, attrs, options) { + const ir_options = session.web_m2x_options; + if (Number(options.limit)) { + props.searchLimit = Number(options.limit); + } else if (Number(ir_options["web_m2x_options.limit"])) { + props.searchLimit = Number(ir_options["web_m2x_options.limit"]); + } + return props; + }, + + m2oOptionsPropsSearchMore(props, attrs, options) { + const ir_options = session.web_m2x_options; + if (options.search_more) { + props.noSearchMore = false; + } else if (options.search_more === false) { + props.noSearchMore = true; + } else if ( + ir_options["web_m2x_options.search_more"] === "True" && + props.noSearchMore + ) { + props.noSearchMore = false; + } else if (ir_options["web_m2x_options.search_more"] === "False") { + props.noSearchMore = true; + } + return props; + }, + + m2oOptionsPropsOpen(props, attrs, options) { + const ir_options = session.web_m2x_options; + if (options.open) { + props.canOpen = true; + } else if (options.open === false) { + props.canOpen = false; + } else if (ir_options["web_m2x_options.open"] === "True") { + props.canOpen = true; + } else if (ir_options["web_m2x_options.open"] === "False") { + props.canOpen = false; + } + return props; + }, + + m2oOptionsProps(props, attrs, options) { + props = this.m2oOptionsPropsCreate(props, attrs, options); + props = this.m2oOptionsPropsCreateEdit(props, attrs, options); + props = this.m2oOptionsPropsLimit(props, attrs, options); + props = this.m2oOptionsPropsSearchMore(props, attrs, options); + props = this.m2oOptionsPropsOpen(props, attrs, options); + props.fieldColor = options.field_color; + props.fieldColorOptions = options.colors; + return props; + }, + extractProps({attrs, context, decorations, options, string}, dynamicInfo) { + const props = super.extractProps( + {attrs, context, decorations, options, string}, + dynamicInfo + ); + const new_props = this.m2oOptionsProps(props, attrs, options); + return new_props; + }, +}); + +patch(Many2OneField.prototype, { + get Many2XAutocompleteProps() { + const search_limit = this.props.searchLimit; + const no_search_more = this.props.noSearchMore; + const field_color = this.props.fieldColor; + const field_color_options = this.props.fieldColorOptions; + const props = super.Many2XAutocompleteProps; + const ret_props = {...props}; + if (Number(search_limit) && Number(search_limit) > 1) { + ret_props.searchLimit = search_limit - 1; + } + if (no_search_more) { + ret_props.noSearchMore = no_search_more; + } + if (field_color && field_color_options) { + ret_props.fieldColor = field_color; + ret_props.fieldColorOptions = field_color_options; + } + return ret_props; + }, +}); + +patch(many2ManyTagsField, { + m2mOptionsPropsCreate(props, attrs, options) { + const ir_options = session.web_m2x_options; + // Create option already available for m2m fields + if (!options.create) { + if ( + ir_options["web_m2x_options.create"] === "False" && + props.canQuickCreate + ) { + props.canQuickCreate = false; + } else if ( + ir_options["web_m2x_options.create"] === "True" && + !props.canQuickCreate + ) { + props.canQuickCreate = attrs.can_create + ? evaluateBooleanExpr(attrs.can_create) + : true; + } + } + return props; + }, + + m2mOptionsPropsCreateEdit(props, attrs, options) { + const ir_options = session.web_m2x_options; + if (options.create_edit === false) { + props.canCreateEdit = false; + } else if (options.create_edit) { + // Same condition set in web/views/fields/many2one/many2one_field + props.canCreateEdit = attrs.can_create + ? evaluateBooleanExpr(attrs.can_create) + : true; + } else if ( + ir_options["web_m2x_options.create_edit"] === "False" && + props.canCreateEdit + ) { + props.canCreateEdit = false; + } else if ( + ir_options["web_m2x_options.create_edit"] === "True" && + !props.canCreateEdit + ) { + // Same condition set in web/views/fields/many2one/many2one_field + props.canCreateEdit = attrs.can_create + ? evaluateBooleanExpr(attrs.can_create) + : true; + } + return props; + }, + + m2mOptionsPropsLimit(props, attrs, options) { + const ir_options = session.web_m2x_options; + if (Number(options.limit) && options.limit > 1) { + props.searchLimit = Number(options.limit) - 1; + } else if ( + Number(ir_options["web_m2x_options.limit"]) && + ir_options["web_m2x_options.limit"] > 1 + ) { + props.searchLimit = Number(ir_options["web_m2x_options.limit"]) - 1; + } + return props; + }, + + m2mOptionsPropsSearchMore(props, attrs, options) { + const ir_options = session.web_m2x_options; + if (options.search_more) { + props.noSearchMore = false; + } else if (options.search_more === false) { + props.noSearchMore = true; + } else if ( + ir_options["web_m2x_options.search_more"] === "True" && + props.noSearchMore + ) { + props.noSearchMore = false; + } else if (ir_options["web_m2x_options.search_more"] === "False") { + props.noSearchMore = true; + } + return props; + }, + + m2mOptionsProps(props, attrs, options) { + props = this.m2mOptionsPropsCreate(props, attrs, options); + props = this.m2mOptionsPropsCreateEdit(props, attrs, options); + props = this.m2mOptionsPropsLimit(props, attrs, options); + props = this.m2mOptionsPropsSearchMore(props, attrs, options); + props.fieldColor = options.field_color; + props.fieldColorOptions = options.colors; + return props; + }, + extractProps({attrs, options, string}, dynamicInfo) { + const props = super.extractProps({attrs, options, string}, dynamicInfo); + const new_props = this.m2mOptionsProps(props, attrs, options); + return new_props; + }, +}); + +patch(Many2XAutocomplete.prototype, { + setup() { + super.setup(); + this.ir_options = session.web_m2x_options; + }, + async loadOptionsSource(request) { + var options = await super.loadOptionsSource(request); + this.field_color = this.props.fieldColor; + this.colors = this.props.fieldColorOptions; + if (this.colors && this.field_color) { + var value_ids = options.map((result) => result.value); + const objects = await this.orm.call( + this.props.resModel, + "search_read", + [], + { + domain: [["id", "in", value_ids]], + fields: [this.field_color], + } + ); + for (var index in objects) { + for (var index_value in options) { + if (options[index_value].value === objects[index].id) { + // Find value in values by comparing ids + var option = options[index_value]; + // Find color with field value as key + var color = + this.colors[objects[index][this.field_color]] || "black"; + option.style = "color:" + color; + break; + } + } + } + } + return options; + }, +}); + +patch(FormController.prototype, { + /** + * @override + */ + setup() { + super.setup(...arguments); + this._setSubViewLimit(); + }, + /** + * @override + * add more method to add subview limit on formview + */ + async _setSubViewLimit() { + const ir_options = session.web_m2x_options || {}; + const activeFields = this.archInfo.fieldNodes, + isSmall = this.user; + + var limit = ir_options["web_m2x_options.field_limit_entries"]; + if (!(typeof limit === "undefined")) { + limit = parseInt(limit, 10); + } + for (const fieldName in activeFields) { + const field = activeFields[fieldName]; + if (!isX2Many(field)) { + // What follows only concerns x2many fields + continue; + } + // Const fieldInfo = activeFields[fieldName]; + if (field.invisible) { + // No need to fetch the sub view if the field is always invisible + continue; + } + + if (!field.field.useSubView) { + // The FieldComponent used to render the field doesn't need a sub view + continue; + } + let viewType = field.viewMode || "list,kanban"; + viewType = viewType.replace("tree", "list"); + if (viewType.includes(",")) { + viewType = isSmall ? "kanban" : "list"; + } + field.viewMode = viewType; + if (field.views && field.views[viewType] && limit) { + field.views[viewType].limit = limit; + } + } + }, +}); + +// O.W.L. v18+: schema is validated in dev mode on adding to registry +patch(registry.category("fields").validationSchema, { + m2oOptionsPropsCreate: {type: Function, optional: true}, + m2oOptionsPropsCreateEdit: {type: Function, optional: true}, + m2oOptionsPropsLimit: {type: Function, optional: true}, + m2oOptionsPropsSearchMore: {type: Function, optional: true}, + m2oOptionsPropsOpen: {type: Function, optional: true}, + m2oOptionsProps: {type: Function, optional: true}, + m2mOptionsPropsCreate: {type: Function, optional: true}, + m2mOptionsPropsCreateEdit: {type: Function, optional: true}, + m2mOptionsPropsLimit: {type: Function, optional: true}, + m2mOptionsPropsSearchMore: {type: Function, optional: true}, + m2mOptionsProps: {type: Function, optional: true}, +}); diff --git a/web_m2x_options/tests/__init__.py b/web_m2x_options/tests/__init__.py new file mode 100644 index 000000000000..b472ff361438 --- /dev/null +++ b/web_m2x_options/tests/__init__.py @@ -0,0 +1,2 @@ +# Copyright 2020 initOS GmbH. +from . import test_ir_config_parameter diff --git a/web_m2x_options/tests/test_ir_config_parameter.py b/web_m2x_options/tests/test_ir_config_parameter.py new file mode 100644 index 000000000000..01522858919f --- /dev/null +++ b/web_m2x_options/tests/test_ir_config_parameter.py @@ -0,0 +1,26 @@ +# Copyright 2020 initOS GmbH. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests import common + + +class TestIrConfigParameter(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env["ir.config_parameter"].set_param("web_m2x_options.limit", 10) + cls.env["ir.config_parameter"].set_param("web_m2x_options.create_edit", "True") + cls.env["ir.config_parameter"].set_param("web_m2x_options.create", "True") + cls.env["ir.config_parameter"].set_param("web_m2x_options.search_more", "False") + + def test_web_m2x_options_key(self): + web_m2x_options = self.env["ir.config_parameter"].get_web_m2x_options() + self.assertIn("web_m2x_options.limit", web_m2x_options) + self.assertNotIn("web_m2x_options.search_more_test", web_m2x_options) + + def test_web_m2x_options_value(self): + web_m2x_options = self.env["ir.config_parameter"].get_web_m2x_options() + self.assertEqual(web_m2x_options["web_m2x_options.limit"], "10") + self.assertTrue(bool(web_m2x_options["web_m2x_options.create_edit"])) + self.assertTrue(bool(web_m2x_options["web_m2x_options.create"])) + self.assertEqual(web_m2x_options["web_m2x_options.search_more"], "False")