[MIG]web_m2x_options: Migration to 17.0

This commit is contained in:
manu
2024-07-22 17:13:53 +02:00
parent f6edfac2f9
commit 6c3884f025
18 changed files with 543 additions and 730 deletions

View File

@@ -1,20 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<!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 0.12: http://docutils.sourceforge.net/" />
<title>Add new options for many2one field</title>
<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 7614 2013-02-21 15:55:51Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
@@ -37,6 +36,14 @@ table.borderless td, table.borderless th {
.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 }
@@ -161,12 +168,12 @@ h2.subtitle {
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left {
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 {
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
@@ -177,6 +184,11 @@ img.align-center, .figure.align-center, object.align-center {
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
@@ -194,6 +206,15 @@ div.align-right {
/* 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 }
@@ -338,74 +359,198 @@ ul.auto-toc {
</style>
</head>
<body>
<div class="document" id="add-new-options-for-many2one-field">
<h1 class="title">Add new options for many2one field</h1>
<div class="document" id="web-m2x-options">
<h1 class="title">web_m2x_options</h1>
<div class="section" id="description">
<h1>Description</h1>
<p>This modules modifies &quot;many2one&quot; and &quot;many2manytags&quot; form widgets so as to add some new display
control options.</p>
<p><strong>New: support many2manytags widget !</strong></p>
<p><strong>New: support global option management with ir.config_parameter !</strong></p>
<p>Options provided includes possibility to remove &quot;Create...&quot; and/or &quot;Create and
Edit...&quot; entries from many2one drop down. You can also change default number of
proposition appearing in the drop-down. Or prevent the dialog box poping in
case of validation error.</p>
<p>If not specified, the module will avoid proposing any of the create options
if the current user have no permission rights to create the related object.</p>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:0afece0246fa101b62c0522c1df2070cea624097713b5c6991fce8a2903dc1ef
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/17.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-17-0/web-17-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=17.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="requirements">
<h1>Requirements</h1>
<p>Was tested on openerp 8.0, trunk, saas-5 branch. New way to import js file. (thanks to tfossoul)</p>
</div>
<div class="section" id="new-options">
<h1>New options</h1>
<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 &quot;Create...&quot; entry in dropdown panel.</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 &quot;Create and Edit...&quot; entry in dropdown panel</blockquote>
<p><tt class="docutils literal">m2o_dialog</tt> <em>boolean</em> (Default: depends if user have create rights)</p>
<blockquote>
Whether to display the many2one dialog in case of validation error.</blockquote>
<p><tt class="docutils literal">limit</tt> <em>int</em> (Default: openerp default value is <tt class="docutils literal">7</tt>)</p>
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">
<h1>ir.config_parameter options</h1>
<p>Now you can disable &quot;Create...&quot; and &quot;Create and Edit...&quot; entry for all widgets in the odoo instance.
If you disable one option, you can enable it for particular field by setting &quot;create: True&quot; 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>
<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 &quot;Create...&quot; 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>
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 &quot;Create and Edit...&quot; 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: openerp default value is <tt class="docutils literal">7</tt>)</p>
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>To add these parameters go to Configuration -&gt; Technical -&gt; Parameters -&gt; System Parameters and add new parameters like:</p>
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">
<h1>Example</h1>
<h2><a class="toc-backref" href="#toc-entry-4">Example</a></h2>
<p>Your XML form view definition could contain:</p>
<pre class="literal-block">
...
&lt;field name=&quot;partner_id&quot; options=&quot;{'limit': 10, 'create': false, 'create_edit': false}&quot;/&gt;
...
<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 class="section" id="note">
<h1>Note</h1>
<p>Double check that you have no inherited view that remote <tt class="docutils literal">options</tt> you set on a field !
If nothing work, add a debugger in the first ligne of <tt class="docutils literal">get_search_result method</tt> and enable debug mode in OpenERP. When you write something in a many2one field, javascript debugger should pause. If not verify your installation.</p>
</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>
</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/17.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>