summaryrefslogtreecommitdiff
path: root/addons/web/static
diff options
context:
space:
mode:
authorMohammed Shekha <msh@odoo.com>2020-10-30 11:10:53 +0000
committerMohammed Shekha <msh@odoo.com>2021-02-17 12:20:13 +0000
commitf7b2a5825e3786be53d04276af4c4c403b7a293e (patch)
treed04a1091297dd98d850fcf10a099dffd43e04db7 /addons/web/static
parent572ba1be7d8b47192c98aec10cfe1b0b3dbbeb45 (diff)
[FIX] web: do not display cover images in sample data
Before this commit, in sample mode, cover images might be displayed in kanban views. It isn't what we want as those images are real images from the database, not sample ones, but randomly linked to the sample records (the id of many2one fields is randomly generated). This commit tweaks the SampleServer to always set many2one fields pointing to model 'ir.attachment' to false. task-2368505 closes odoo/odoo#66350 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static')
-rw-r--r--addons/web/static/src/js/views/sample_server.js3
-rw-r--r--addons/web/static/tests/views/sample_server_tests.js8
2 files changed, 10 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/sample_server.js b/addons/web/static/src/js/views/sample_server.js
index 43c5594413b..8af27feb2ac 100644
--- a/addons/web/static/src/js/views/sample_server.js
+++ b/addons/web/static/src/js/views/sample_server.js
@@ -251,6 +251,9 @@ odoo.define('web.SampleServer', function (require) {
if (field.relation === 'res.currency') {
return session.company_currency_id;
}
+ if (field.relation === 'ir.attachment') {
+ return false;
+ }
return this._getRandomSubRecordId();
case "one2many":
case "many2many": {
diff --git a/addons/web/static/tests/views/sample_server_tests.js b/addons/web/static/tests/views/sample_server_tests.js
index 0f1dd45f795..35e33e6366d 100644
--- a/addons/web/static/tests/views/sample_server_tests.js
+++ b/addons/web/static/tests/views/sample_server_tests.js
@@ -54,6 +54,7 @@ odoo.define('web.sample_server_tests', function (require) {
salary: { string: "Salary", type: 'monetary' },
currency: { string: "Currency", type: 'many2one', relation: 'res.currency' },
manager_id: { string: "Manager", type: 'many2one', relation: 'res.users' },
+ cover_image_id: { string: "Cover Image", type: 'many2one', relation: 'ir.attachment' },
managed_ids: { string: "Managing", type: 'one2many', relation: 'res.users' },
tag_ids: { string: "Tags", type: 'many2many', relation: 'tag' },
type: { string: "Type", type: 'selection', selection: [
@@ -70,6 +71,9 @@ odoo.define('web.sample_server_tests', function (require) {
] },
age: { string: "Age", type: 'integer' },
},
+ 'ir.attachment': {
+ display_name: { string: "Name", type: 'char' },
+ }
};
},
}, function () {
@@ -77,7 +81,7 @@ odoo.define('web.sample_server_tests', function (require) {
QUnit.module("Basic behaviour");
QUnit.test("Sample data: people type + all field names", async function (assert) {
- assert.expect(25);
+ assert.expect(26);
mock.patch(session, {
company_currency_id: 4,
@@ -150,6 +154,8 @@ odoo.define('web.sample_server_tests', function (require) {
assert.strictEqual(typeof rec.manager_id[0], 'number');
assert.ok(SAMPLE_PEOPLE.includes(rec.manager_id[1]));
+ assert.strictEqual(rec.cover_image_id, false);
+
assert.strictEqual(rec.managed_ids.length, 2);
assert.ok(rec.managed_ids.every(
(id) => typeof id === 'number')