Skip to content

Commit 55eaecd

Browse files
committed
[FIX] web_domain_field: Accept empty domain
Steps: 1. Create a domain field that contains `False` 2. Associate the created field to a relational field 3. In a form view, open the dropdown of the filtered relational field Before this change: The following client error is raised: > Error: second argument to Function.prototype.apply must be an array eval_domains/<@https://domain.com/web_domain_field/static/lib/js/pyeval.js:156:40 [...] After this change: All the records can be selected
1 parent 8d17efc commit 55eaecd

File tree

13 files changed

+168
-8
lines changed

13 files changed

+168
-8
lines changed

test-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
odoo_test_helper

web_domain_field/README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ Contributors
116116
* Laurent Mignon <laurent.mignon@acsone.eu>
117117
* Denis Roussel <denis.roussel@acsone.eu>
118118
* Raf Ven <raf.ven@dynapps.be>
119+
* `PyTech <https://www.pytech.it>`_:
120+
121+
* Simone Rubino <simone.rubino@pytech.it>
119122

120123
Maintainers
121124
~~~~~~~~~~~

web_domain_field/__manifest__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
1212
"website": "https://github.com/OCA/web",
1313
"depends": ["web"],
14-
"data": ["views/web_domain_field.xml"],
14+
"data": [
15+
"views/templates.xml",
16+
"views/web_domain_field.xml",
17+
],
1518
"installable": True,
1619
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
* Laurent Mignon <laurent.mignon@acsone.eu>
22
* Denis Roussel <denis.roussel@acsone.eu>
33
* Raf Ven <raf.ven@dynapps.be>
4+
* `PyTech <https://www.pytech.it>`_:
5+
6+
* Simone Rubino <simone.rubino@pytech.it>

web_domain_field/static/description/index.html

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<?xml version="1.0" encoding="utf-8"?>
21
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
32
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
43
<head>
@@ -9,10 +8,11 @@
98

109
/*
1110
:Author: David Goodger (goodger@python.org)
12-
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
11+
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
1312
:Copyright: This stylesheet has been placed in the public domain.
1413
1514
Default cascading style sheet for the HTML output of Docutils.
15+
Despite the name, some widely supported CSS2 features are used.
1616
1717
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
1818
customize this style sheet.
@@ -275,7 +275,7 @@
275275
margin-left: 2em ;
276276
margin-right: 2em }
277277

278-
pre.code .ln { color: grey; } /* line numbers */
278+
pre.code .ln { color: gray; } /* line numbers */
279279
pre.code, code { background-color: #eeeeee }
280280
pre.code .comment, code .comment { color: #5C6576 }
281281
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -301,7 +301,7 @@
301301
span.pre {
302302
white-space: pre }
303303

304-
span.problematic {
304+
span.problematic, pre.problematic {
305305
color: red }
306306

307307
span.section-subtitle {
@@ -429,7 +429,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
429429
</span><span class="p">)</span><span class="w">
430430

431431
</span><span class="nd">&#64;api</span><span class="o">.</span><span class="n">depends</span><span class="p">(</span><span class="s1">'name'</span><span class="p">)</span><span class="w">
432-
</span><span class="k">def</span> <span class="nf">_compute_product_id_domain</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span><span class="w">
432+
</span><span class="k">def</span><span class="w"> </span><span class="nf">_compute_product_id_domain</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span><span class="w">
433433
</span> <span class="k">for</span> <span class="n">rec</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">:</span><span class="w">
434434
</span> <span class="n">rec</span><span class="o">.</span><span class="n">product_id_domain</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="w">
435435
</span> <span class="p">[(</span><span class="s1">'type'</span><span class="p">,</span> <span class="s1">'='</span><span class="p">,</span> <span class="s1">'product'</span><span class="p">),</span> <span class="p">(</span><span class="s1">'name'</span><span class="p">,</span> <span class="s1">'like'</span><span class="p">,</span> <span class="n">rec</span><span class="o">.</span><span class="n">name</span><span class="p">)]</span><span class="w">
@@ -458,12 +458,18 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
458458
<li>Laurent Mignon &lt;<a class="reference external" href="mailto:laurent.mignon&#64;acsone.eu">laurent.mignon&#64;acsone.eu</a>&gt;</li>
459459
<li>Denis Roussel &lt;<a class="reference external" href="mailto:denis.roussel&#64;acsone.eu">denis.roussel&#64;acsone.eu</a>&gt;</li>
460460
<li>Raf Ven &lt;<a class="reference external" href="mailto:raf.ven&#64;dynapps.be">raf.ven&#64;dynapps.be</a>&gt;</li>
461+
<li><a class="reference external" href="https://www.pytech.it">PyTech</a>:<ul>
462+
<li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;pytech.it">simone.rubino&#64;pytech.it</a>&gt;</li>
463+
</ul>
464+
</li>
461465
</ul>
462466
</div>
463467
<div class="section" id="maintainers">
464468
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
465469
<p>This module is maintained by the OCA.</p>
466-
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
470+
<a class="reference external image-reference" href="https://odoo-community.org">
471+
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
472+
</a>
467473
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
468474
mission is to support the collaborative development of Odoo features and
469475
promote its widespread use.</p>

web_domain_field/static/lib/js/pyeval.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ odoo.define('web.domain_field', function (require) {
154154
// Modified part or the original method
155155
if (domain in evaluation_context) {
156156
result_domain.push.apply(
157-
result_domain, $.parseJSON(evaluation_context[domain]));
157+
result_domain, $.parseJSON(evaluation_context[domain]) || []);
158158
return;
159159
}
160160
// End of modifications
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
odoo.define("web_domain_field.false_domain_tour", function (require) {
2+
"use strict";
3+
4+
var tour = require("web_tour.tour");
5+
6+
tour.register(
7+
"web_domain_field.false_domain_tour",
8+
{
9+
test: true,
10+
url: "/web",
11+
},
12+
[
13+
tour.stepUtils.showAppsMenuItem(),
14+
{
15+
content: "Go to Fake Model menu",
16+
trigger: '.o_app[data-menu-xmlid="web_domain_field.fake_model_menu"]',
17+
run: "click",
18+
},
19+
{
20+
content: "Create a new record",
21+
trigger: "button.o_list_button_add",
22+
run: "click",
23+
},
24+
{
25+
content: "Click on partner dropdown",
26+
trigger: 'div[name="partner_id"] .o_dropdown_button',
27+
run: "click",
28+
},
29+
]
30+
);
31+
});

web_domain_field/tests/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2+
3+
from . import test_domain_field
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
~ Copyright 2025 Simone Rubino - PyTech
4+
~ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
5+
-->
6+
<odoo>
7+
<record id="fake_model_form_view" model="ir.ui.view">
8+
<field name="name">Form view for fake model</field>
9+
<field name="model">web_domain_field.fake.model</field>
10+
<field name="arch" type="xml">
11+
<form>
12+
<sheet>
13+
<group>
14+
<field name="partner_id_false_domain" invisible="True" />
15+
<field name="partner_id" domain="partner_id_false_domain" />
16+
</group>
17+
</sheet>
18+
</form>
19+
</field>
20+
</record>
21+
22+
<record id="fake_model_action" model="ir.actions.act_window">
23+
<field name="name">Fake Model action</field>
24+
<field name="res_model">web_domain_field.fake.model</field>
25+
<field name="view_mode">list,form</field>
26+
</record>
27+
28+
<menuitem id="fake_model_menu" action="fake_model_action" />
29+
</odoo>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2+
full_access,Full Access,model_web_domain_field_fake_model,,1,1,1,1

0 commit comments

Comments
 (0)