Skip to content

Commit 9c49be7

Browse files
committed
[MIG] web_portal_properties: Migration to 18.0
1 parent 7e992da commit 9c49be7

7 files changed

Lines changed: 115 additions & 9 deletions

File tree

web_portal_properties/__manifest__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Web Portal Properties",
66
"summary": """Add a new field on properties to show them on portal""",
7-
"version": "17.0.1.0.0",
7+
"version": "18.0.1.0.0",
88
"license": "AGPL-3",
99
"author": "Dixmit,Odoo Community Association (OCA)",
1010
"website": "https://github.com/OCA/web",
@@ -16,5 +16,8 @@
1616
"web_portal_properties/static/src/**/*.esm.js",
1717
"web_portal_properties/static/src/**/*.xml",
1818
],
19+
"web.assets_unit_tests": [
20+
"web_portal_properties/static/tests/**/*.test.js",
21+
],
1922
},
2023
}

web_portal_properties/static/src/components/portal_properties/portal_properties.esm.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
/** @odoo-module **/
21
import {PortalPropertyDefinition} from "./portal_properties_definition.esm";
32
import {PropertiesField} from "@web/views/fields/properties/properties_field";
43
import {_t} from "@web/core/l10n/translation";
5-
import {archParseBoolean} from "@web/views/utils";
4+
import {exprToBoolean} from "@web/core/utils/strings";
65
import {registry} from "@web/core/registry";
76
import {usePopover} from "@web/core/popover/popover_hook";
87

@@ -30,11 +29,12 @@ export const portalPropertiesField = {
3029
component: PortalPropertiesField,
3130
displayName: _t("Properties"),
3231
supportedTypes: ["properties"],
32+
additionalClasses: ["o_field_properties"],
3333
extractProps({attrs}, dynamicInfo) {
3434
return {
3535
context: dynamicInfo.context,
3636
columns: parseInt(attrs.columns || "1", 10),
37-
showAddButton: archParseBoolean(attrs.showAddButton),
37+
showAddButton: exprToBoolean(attrs.showAddButton),
3838
};
3939
},
4040
};

web_portal_properties/static/src/components/portal_properties/portal_properties_definition.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
<div class="o_field_property_definition_portal d-contents mb-3 mb-sm-0">
1010
<label
1111
t-att-for="getUniqueDomID('portal')"
12-
class="o_form_label align-self-center text-900"
12+
class="o_form_label align-self-center text-900 o_property_display_in_portal"
1313
>
1414
Display in Portal
1515
<sup
16-
class="text-info"
17-
title="Whether or not this Property Field is displayed in the Portal views"
18-
>?</sup>
16+
class="text-info"
17+
title="Whether or not this Property Field is displayed in the Portal views"
18+
>?</sup>
1919
</label>
2020
<CheckBox
2121
id="getUniqueDomID('portal')"
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import {animationFrame, click, expect, runAllTimers, test} from "@odoo/hoot";
2+
import {
3+
defineModels,
4+
fields,
5+
models,
6+
mountView,
7+
onRpc,
8+
toggleActionMenu,
9+
} from "@web/../tests/web_test_helpers";
10+
import {defineMailModels} from "@mail/../tests/mail_test_helpers";
11+
12+
class Partner extends models.Model {
13+
display_name = fields.Char();
14+
properties = fields.Properties({
15+
string: "Properties",
16+
searchable: false,
17+
definition_record: "company_id",
18+
definition_record_field: "definitions",
19+
});
20+
company_id = fields.Many2one({
21+
string: "Company",
22+
relation: "properties.definition.model",
23+
});
24+
_records = [
25+
{
26+
id: 1,
27+
display_name: "first partner",
28+
properties: {
29+
property_1: "char value",
30+
property_2: "b",
31+
},
32+
company_id: 37,
33+
},
34+
];
35+
}
36+
37+
class PropertiesDefinitionModel extends models.Model {
38+
_name = "properties.definition.model";
39+
name = fields.Char({string: "Name"});
40+
definitions = fields.PropertiesDefinition();
41+
_records = [
42+
{
43+
id: 37,
44+
name: "Company 1",
45+
definitions: [],
46+
},
47+
];
48+
}
49+
50+
defineModels([Partner, PropertiesDefinitionModel]);
51+
defineMailModels();
52+
test("Portal Properties: check field", async () => {
53+
onRpc("has_access", () => true);
54+
await mountView({
55+
type: "form",
56+
resModel: "partner",
57+
resId: 1,
58+
arch: `
59+
<form>
60+
<sheet>
61+
<group>
62+
<field name="company_id"/>
63+
<field name="properties" widget="portal_properties"/>
64+
</group>
65+
</sheet>
66+
</form>`,
67+
actionMenus: {},
68+
});
69+
expect(".o_field_properties").toHaveCount(1);
70+
await toggleActionMenu();
71+
await animationFrame();
72+
expect(".o-dropdown--menu span:contains(Add Properties)").toHaveCount(1, {
73+
message: "The add button must be in the cog menu",
74+
});
75+
await click(".o-dropdown--menu span .fa-cogs");
76+
await runAllTimers();
77+
await animationFrame();
78+
expect(".o_property_field_popover").toHaveCount(1, {
79+
message: "Should have opened the definition popover",
80+
});
81+
expect(".o_property_field_popover .o_property_display_in_portal").toHaveCount(1, {
82+
message: "The display in portal checkbox should be visible",
83+
});
84+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_ui
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2026 Dixmit
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
import odoo
4+
5+
from odoo.addons.web.tests.test_js import WebSuite
6+
7+
8+
@odoo.tests.tagged("post_install", "-at_install")
9+
class TestWebPortalProperties(WebSuite):
10+
"""Test Web Portal Properties"""
11+
12+
def get_hoot_filters(self):
13+
self._test_params = [("+", "@web_portal_properties")]
14+
return super().get_hoot_filters()
15+
16+
def test_automation_oca(self):
17+
self.test_unit_desktop()

web_portal_properties/views/portal_templates.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
<div class="row" t-if="properties">
99
<t t-foreach="properties" t-as="property">
1010
<div class="col-6" t-if="property.get('view_in_portal')">
11-
<strong t-esc="property['string']" /><t>: </t>
11+
<strong t-esc="property['string']" />
12+
<t>: </t>
1213
<t t-if="property['value']">
1314
<span
1415
t-esc="property['value'][1]"

0 commit comments

Comments
 (0)