pull/2961/merge
Siddharth 2025-04-23 16:02:59 -03:00 committed by GitHub
commit f64cdf0a8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
33 changed files with 2489 additions and 0 deletions

View File

@ -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
...
<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 <https://github.com/OCA/web/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_m2x_options%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Authors
-------
* initOS GmbH
* ACSONE SA/NV
* 0k.io
* Tecnativa
* Sygel
Contributors
------------
- David Coninckx <davconinckx@gmail.com>
- Emanuel Cino <ecino@compassion.ch>
- Holger Brunn <hbrunn@therp.nl>
- Nicolas JEUDY <nicolas@sudokeys.com>
- Yannick Vaucher <yannick.vaucher@camptocamp.com>
- Zakaria Makrelouf <z.makrelouf@gmail.com>
- `Tecnativa <https://www.tecnativa.com>`__:
- Jairo Llopis <jairo.llopis@tecnativa.com>
- David Vidal <david.vidal@tecnativa.com>
- Ernesto Tejeda <ernesto.tejeda87@gmail.com>
- Carlos Roca
- Bhavesh Odedra <bodedra@opensourceintegrators.com>
- Dhara Solanki <dhara.solanki@initos.com> (http://www.initos.com)
- `Trobz <https://trobz.com>`__:
- Hoang Diep <hoang@trobz.com>
- `Sygel <https://sygel.es>`__:
- Manuel Regidor <manuel.regidor@sygel.es>
- Valentín Vinagre <valentin.vinagre@sygel.es>
- Harald Panten <harald.panten@sygel.es>
- Siddharth Bhalgami <siddharth.bhalgami@gmail.com>
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 <https://github.com/OCA/web/tree/18.0/web_m2x_options>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -0,0 +1 @@
from . import models

View File

@ -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,
}

View File

@ -0,0 +1,46 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_m2x_options
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 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 <transbot@odoo-community.org>, 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 \"<strong>%s</strong>\""
#~ msgstr "إنشاء \"<strong>%s</strong>\""
#, python-format
#~ msgid "Create and Edit..."
#~ msgstr "إنشاء وتحرير ..."

View File

@ -0,0 +1,117 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_m2x_options
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2017
# Rudolf Schnapka <rs@techno-flex.de>, 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 <nils.coenen@nico-solutions.de>\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 \"<strong>%s</strong>\""
#~ msgstr "Anlegen \"<strong>%s</strong>"
#, 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?"

View File

@ -0,0 +1,106 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_m2x_options
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 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 <informatica@totmaterial.es>\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 \"<strong>%s</strong>\""
#~ msgstr "Crear \"<strong>%s</strong>\""
#, 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?"

View File

@ -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 ""

View File

@ -0,0 +1,45 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_m2x_options
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 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 <transbot@odoo-community.org>, 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 \"<strong>%s</strong>\""
#~ msgstr "Luo \"<strong>%s</strong>\""
#, python-format
#~ msgid "Create and Edit..."
#~ msgstr "Luo ja muokkaa..."

View File

@ -0,0 +1,92 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_m2x_options
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 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 <hughes@damry.org>\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 \"<strong>%s</strong>\""
#~ msgstr "Creer \"<strong>%s</strong>\""
#, 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à ?"

View File

@ -0,0 +1,63 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_m2x_options
#
# Translators:
# Bole <bole@dajmi5.com>, 2017
# OCA Transbot <transbot@odoo-community.org>, 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 <transbot@odoo-community.org>, 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 \"<strong>%s</strong>\""
#~ msgstr "Kreiraj \" <strong>%s</strong>\""
#, 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?"

View File

@ -0,0 +1,94 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_m2x_options
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 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 <stefano.consolaro@mymage.it>\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 \"<strong>%s</strong>\""
#~ msgstr "Crea \"<strong>%s</strong>\""
#, python-format
#~ msgid "Create and Edit..."
#~ msgstr "Crea e Modifica..."

View File

@ -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 <c5e2fd43-d292-4c90-9d1f-74ff3436329a@anonaddy.me>\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 \"<strong>%s</strong>\""
#~ msgstr "Creér<strong>%s</strong>\""
#, 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"

View File

@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_m2x_options
#
# Translators:
# Peter Hageman <hageman.p@gmail.com>, 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 <hageman.p@gmail.com>, 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"

View File

@ -0,0 +1,114 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_m2x_options
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2017
# Rodrigo de Almeida Sottomaior Macedo <rmsolucoeseminformatic4@gmail.com>, 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 <sottomaiormacedotec@users.noreply."
"translation.odoo-community.org>\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 \"<strong>%s</strong>\""
#~ msgstr "Criar \"<strong>%s</strong>\""
#, 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?"

View File

@ -0,0 +1,46 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_m2x_options
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 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 <transbot@odoo-community.org>, 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 \"<strong>%s</strong>\""
#~ msgstr "Ustvari \"<strong>%s</strong>\""
#, python-format
#~ msgid "Create and Edit..."
#~ msgstr "Ustvari in urejaj..."

View File

@ -0,0 +1,45 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_m2x_options
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 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 <transbot@odoo-community.org>, 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 \"<strong>%s</strong>\""
#~ msgstr "Oluştur \"<strong>%s</strong>\""
#, python-format
#~ msgid "Create and Edit..."
#~ msgstr "Oluştur ve düzenle..."

View File

@ -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 ""

View File

@ -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 \"<strong>%s</strong>\""
#~ msgstr "创建 \"<strong>%s</strong>\""
#, 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你确定它还不存在吗"

View File

@ -0,0 +1,2 @@
from . import ir_config_parameter
from . import ir_http

View File

@ -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}

View File

@ -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

View File

@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"

View File

@ -0,0 +1,31 @@
- David Coninckx \<<davconinckx@gmail.com>\>
- Emanuel Cino \<<ecino@compassion.ch>\>
- Holger Brunn \<<hbrunn@therp.nl>\>
- Nicolas JEUDY \<<nicolas@sudokeys.com>\>
- Yannick Vaucher \<<yannick.vaucher@camptocamp.com>\>
- Zakaria Makrelouf \<<z.makrelouf@gmail.com>\>
- [Tecnativa](https://www.tecnativa.com):
- Jairo Llopis \<<jairo.llopis@tecnativa.com>\>
- David Vidal \<<david.vidal@tecnativa.com>\>
- Ernesto Tejeda \<<ernesto.tejeda87@gmail.com>\>
- Carlos Roca
- Bhavesh Odedra \<<bodedra@opensourceintegrators.com>\>
- Dhara Solanki \<<dhara.solanki@initos.com>\> (<http://www.initos.com>)
- [Trobz](https://trobz.com):
- Hoang Diep \<<hoang@trobz.com>\>
- [Sygel](https://sygel.es):
- Manuel Regidor \<<manuel.regidor@sygel.es>\>
- Valentín Vinagre \<<valentin.vinagre@sygel.es>\>
- Harald Panten \<<harald.panten@sygel.es>\>
- Siddharth Bhalgami \<<siddharth.bhalgami@gmail.com>\>

View File

@ -0,0 +1,2 @@
The migration of this module from 15.0 to 16.0 was financially supported
by Camptocamp

View File

@ -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.

View File

@ -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...).

View File

@ -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
...
<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'}}"/>
...
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@ -0,0 +1,561 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>web_m2x_options</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic, pre.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="web-m2x-options">
<h1 class="title">web_m2x_options</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:36f18dc3f0b0b3d8b91f63aa88d55c4936d53fef5857b1dcb903308b536c79c4
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/18.0/web_m2x_options"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-18-0/web-18-0-web_m2x_options"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This modules modifies “many2one” and “many2manytags” form widgets so as
to add some new display control options.</p>
<p>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.</p>
<p>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.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#usage" id="toc-entry-1">Usage</a><ul>
<li><a class="reference internal" href="#in-the-field-s-options-dict" id="toc-entry-2">in the fields options dict</a></li>
<li><a class="reference internal" href="#ir-config-parameter-options" id="toc-entry-3">ir.config_parameter options</a></li>
<li><a class="reference internal" href="#example" id="toc-entry-4">Example</a></li>
</ul>
</li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-5">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-6">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-7">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-8">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-9">Contributors</a></li>
<li><a class="reference internal" href="#other-credits" id="toc-entry-10">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-11">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<div class="section" id="in-the-field-s-options-dict">
<h2><a class="toc-backref" href="#toc-entry-2">in the fields options dict</a></h2>
<p><tt class="docutils literal">create</tt> <em>boolean</em> (Default: depends if user have create rights)</p>
<blockquote>
Whether to display the “Create…” entry in dropdown panel. Only for
m2o fields.</blockquote>
<p><tt class="docutils literal">create_edit</tt> <em>boolean</em> (Default: depends if user have create rights)</p>
<blockquote>
Whether to display “Create and Edit…” entry in dropdown panel</blockquote>
<p><tt class="docutils literal">limit</tt> <em>int</em> (Default: odoo default value is <tt class="docutils literal">8</tt>)</p>
<blockquote>
Number of displayed record in drop-down panel</blockquote>
<p><tt class="docutils literal">search_more</tt> <em>boolean</em></p>
<blockquote>
Used to force disable/enable search more button.</blockquote>
<p><tt class="docutils literal">field_color</tt> <em>string</em></p>
<blockquote>
A string to define the field used to define color. This option has to
be used with colors.</blockquote>
<p><tt class="docutils literal">colors</tt> <em>dictionary</em></p>
<blockquote>
A dictionary to link field value with a HTML color. This option has
to be used with field_color.</blockquote>
<p><tt class="docutils literal">open</tt> <em>boolean</em> (Default: <tt class="docutils literal">False</tt>)</p>
<blockquote>
Makes many2one buttons that open the linked resource.</blockquote>
</div>
<div class="section" id="ir-config-parameter-options">
<h2><a class="toc-backref" href="#toc-entry-3">ir.config_parameter options</a></h2>
<p>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.</p>
<p><tt class="docutils literal">web_m2x_options.create</tt> <em>boolean</em> (Default: depends if user have
create rights)</p>
<blockquote>
Whether to display the “Create…” entry in dropdown panel for all
fields in the odoo instance.</blockquote>
<p><tt class="docutils literal">web_m2x_options.create_edit</tt> <em>boolean</em> (Default: depends if user have
create rights)</p>
<blockquote>
Whether to display “Create and Edit…” entry in dropdown panel for
all fields in the odoo instance.</blockquote>
<p><tt class="docutils literal">web_m2x_options.limit</tt> <em>int</em> (Default: odoo default value is <tt class="docutils literal">8</tt>)</p>
<blockquote>
Number of displayed record in drop-down panel for all fields in the
odoo instance</blockquote>
<p><tt class="docutils literal">web_m2x_options.search_more</tt> <em>boolean</em> (Default: default value is
<tt class="docutils literal">False</tt>)</p>
<blockquote>
Whether the field should always show “Search more…” entry or not.</blockquote>
<p><tt class="docutils literal">web_m2x_options.field_limit_entries</tt> <em>int</em></p>
<blockquote>
Number of displayed lines on all One2many fields</blockquote>
<p>To add these parameters go to Configuration -&gt; Technical -&gt; Parameters
-&gt; System Parameters and add new parameters like:</p>
<ul class="simple">
<li>web_m2x_options.create: False</li>
<li>web_m2x_options.create_edit: False</li>
<li>web_m2x_options.limit: 10</li>
<li>web_m2x_options.search_more: True</li>
<li>web_m2x_options.field_limit_entries: 5</li>
</ul>
</div>
<div class="section" id="example">
<h2><a class="toc-backref" href="#toc-entry-4">Example</a></h2>
<p>Your XML form view definition could contain:</p>
<pre class="code xml literal-block">
...<span class="w">
</span><span class="nt">&lt;field</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;partner_id&quot;</span><span class="w"> </span><span class="na">options=</span><span class="s">&quot;{'limit': 10, 'create': false, 'create_edit': false, 'search_more': true, 'field_color':'type', 'colors':{'contact':'green', 'invoice': 'red', 'delivery': 'blue'}}&quot;</span><span class="nt">/&gt;</span><span class="w">
</span>...
</pre>
</div>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-5">Known issues / Roadmap</a></h1>
<p>Double check that you have no inherited view that remove <tt class="docutils literal">options</tt> you
set on a field ! If nothing works, add a debugger in the first line of
<tt class="docutils literal">_search method</tt> and enable debug mode in Odoo. When you write
something in a many2one field, javascript debugger should pause. If not
verify your installation.</p>
<ul class="simple">
<li>Instead of making the tags rectangle clickable, I think its better
to put the text as a clickable link, so we will get a consistent
behaviour/aspect with other clickable elements (many2one…).</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-6">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_m2x_options%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-7">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-8">Authors</a></h2>
<ul class="simple">
<li>initOS GmbH</li>
<li>ACSONE SA/NV</li>
<li>0k.io</li>
<li>Tecnativa</li>
<li>Sygel</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-9">Contributors</a></h2>
<ul class="simple">
<li>David Coninckx &lt;<a class="reference external" href="mailto:davconinckx&#64;gmail.com">davconinckx&#64;gmail.com</a>&gt;</li>
<li>Emanuel Cino &lt;<a class="reference external" href="mailto:ecino&#64;compassion.ch">ecino&#64;compassion.ch</a>&gt;</li>
<li>Holger Brunn &lt;<a class="reference external" href="mailto:hbrunn&#64;therp.nl">hbrunn&#64;therp.nl</a>&gt;</li>
<li>Nicolas JEUDY &lt;<a class="reference external" href="mailto:nicolas&#64;sudokeys.com">nicolas&#64;sudokeys.com</a>&gt;</li>
<li>Yannick Vaucher &lt;<a class="reference external" href="mailto:yannick.vaucher&#64;camptocamp.com">yannick.vaucher&#64;camptocamp.com</a>&gt;</li>
<li>Zakaria Makrelouf &lt;<a class="reference external" href="mailto:z.makrelouf&#64;gmail.com">z.makrelouf&#64;gmail.com</a>&gt;</li>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Jairo Llopis &lt;<a class="reference external" href="mailto:jairo.llopis&#64;tecnativa.com">jairo.llopis&#64;tecnativa.com</a>&gt;</li>
<li>David Vidal &lt;<a class="reference external" href="mailto:david.vidal&#64;tecnativa.com">david.vidal&#64;tecnativa.com</a>&gt;</li>
<li>Ernesto Tejeda &lt;<a class="reference external" href="mailto:ernesto.tejeda87&#64;gmail.com">ernesto.tejeda87&#64;gmail.com</a>&gt;</li>
<li>Carlos Roca</li>
</ul>
</li>
<li>Bhavesh Odedra &lt;<a class="reference external" href="mailto:bodedra&#64;opensourceintegrators.com">bodedra&#64;opensourceintegrators.com</a>&gt;</li>
<li>Dhara Solanki &lt;<a class="reference external" href="mailto:dhara.solanki&#64;initos.com">dhara.solanki&#64;initos.com</a>&gt; (<a class="reference external" href="http://www.initos.com">http://www.initos.com</a>)</li>
<li><a class="reference external" href="https://trobz.com">Trobz</a>:<ul>
<li>Hoang Diep &lt;<a class="reference external" href="mailto:hoang&#64;trobz.com">hoang&#64;trobz.com</a>&gt;</li>
</ul>
</li>
<li><a class="reference external" href="https://sygel.es">Sygel</a>:<ul>
<li>Manuel Regidor &lt;<a class="reference external" href="mailto:manuel.regidor&#64;sygel.es">manuel.regidor&#64;sygel.es</a>&gt;</li>
<li>Valentín Vinagre &lt;<a class="reference external" href="mailto:valentin.vinagre&#64;sygel.es">valentin.vinagre&#64;sygel.es</a>&gt;</li>
<li>Harald Panten &lt;<a class="reference external" href="mailto:harald.panten&#64;sygel.es">harald.panten&#64;sygel.es</a>&gt;</li>
</ul>
</li>
<li>Siddharth Bhalgami &lt;<a class="reference external" href="mailto:siddharth.bhalgami&#64;gmail.com">siddharth.bhalgami&#64;gmail.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-10">Other credits</a></h2>
<p>The migration of this module from 15.0 to 16.0 was financially supported
by Camptocamp</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-11">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/18.0/web_m2x_options">OCA/web</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<templates xml:space="preserve">
<t
t-name="web_m2x_options.AutoComplete"
t-inherit="web.AutoComplete"
t-inherit-mode="extension"
owl="1"
>
<xpath expr="//t[@t-foreach='source.options']/li/a" position="attributes">
<attribute name="t-attf-style">{{ option.style }}</attribute>
</xpath>
</t>
<t
t-name="web_m2x_options.Many2ManyTagsField"
t-inherit="web.Many2ManyTagsField"
t-inherit-mode="extension"
owl="1"
>
<xpath expr="//Many2XAutocomplete" position="attributes">
<attribute name="searchLimit">props.searchLimit</attribute>
<attribute name="fieldColor">props.fieldColor</attribute>
<attribute name="fieldColorOptions">props.fieldColorOptions</attribute>
</xpath>
</t>
</templates>

View File

@ -0,0 +1,430 @@
/** @odoo-module **/
import {registry} from "@web/core/registry";
import {exprToBoolean} from "@web/core/utils/strings";
import {
Many2ManyTagsField,
Many2ManyTagsFieldColorEditable,
many2ManyTagsField,
} from "@web/views/fields/many2many_tags/many2many_tags_field";
import {Many2OneField, many2OneField} from "@web/views/fields/many2one/many2one_field";
import {Many2OneReferenceField} from "@web/views/fields/many2one_reference/many2one_reference_field";
import {FormController} from "@web/views/form/form_controller";
import {
KanbanMany2OneAvatarField,
Many2OneAvatarField,
} from "@web/views/fields/many2one_avatar/many2one_avatar_field";
import {
KanbanMany2OneAvatarUserField,
Many2OneAvatarUserField,
} from "@mail/views/web/fields/many2one_avatar_user_field/many2one_avatar_user_field";
import {Many2ManyTagsAvatarField} from "@web/views/fields/many2many_tags_avatar/many2many_tags_avatar_field";
import {KanbanMany2ManyTagsAvatarUserField} from "@mail/views/web/fields/many2many_avatar_user_field/many2many_avatar_user_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},
};
KanbanMany2OneAvatarUserField.props = {
...KanbanMany2OneAvatarUserField.props,
noSearchMore: {type: Boolean, optional: true},
fieldColor: {type: String, optional: true},
fieldColorOptions: {type: Object, optional: true},
};
Many2OneAvatarUserField.props = {
...Many2OneAvatarUserField.props,
noSearchMore: {type: Boolean, optional: true},
fieldColor: {type: String, optional: true},
fieldColorOptions: {type: Object, optional: true},
};
Many2OneReferenceField.props = {
...Many2OneReferenceField.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},
};
KanbanMany2ManyTagsAvatarUserField.props = {
...KanbanMany2ManyTagsAvatarUserField.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 (
!exprToBoolean(ir_options["web_m2x_options.create"]) &&
props.canQuickCreate
) {
props.canQuickCreate = false;
} else if (
exprToBoolean(ir_options["web_m2x_options.create"]) &&
!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 (
!exprToBoolean(ir_options["web_m2x_options.create_edit"]) &&
props.canCreateEdit
) {
props.canCreateEdit = false;
} else if (
exprToBoolean(ir_options["web_m2x_options.create_edit"]) &&
!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 (
exprToBoolean(ir_options["web_m2x_options.search_more"]) &&
props.noSearchMore
) {
props.noSearchMore = false;
} else if (!exprToBoolean(ir_options["web_m2x_options.search_more"])) {
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 (exprToBoolean(ir_options["web_m2x_options.open"])) {
props.canOpen = true;
} else if (!exprToBoolean(ir_options["web_m2x_options.open"])) {
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 (
!exprToBoolean(ir_options["web_m2x_options.create"]) &&
props.canQuickCreate
) {
props.canQuickCreate = false;
} else if (
exprToBoolean(ir_options["web_m2x_options.create"]) &&
!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 (
!exprToBoolean(ir_options["web_m2x_options.create_edit"]) &&
props.canCreateEdit
) {
props.canCreateEdit = false;
} else if (
exprToBoolean(ir_options["web_m2x_options.create_edit"]) &&
!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 (
!exprToBoolean(ir_options["web_m2x_options.search_more"]) &&
props.noSearchMore
) {
props.noSearchMore = false;
} else if (exprToBoolean(ir_options["web_m2x_options.search_more"])) {
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},
});

View File

@ -0,0 +1,2 @@
# Copyright 2020 initOS GmbH.
from . import test_ir_config_parameter

View File

@ -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")