[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#66381 X-original-commit: f7b2a5825e3786be53d04276af4c4c403b7a293e Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
@@ -250,6 +250,9 @@
|
||||
if (field.relation === 'res.currency') {
|
||||
return session.company_currency_id;
|
||||
}
|
||||
if (field.relation === 'ir.attachment') {
|
||||
return false;
|
||||
}
|
||||
return this._getRandomSubRecordId();
|
||||
case "one2many":
|
||||
case "many2many": {
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user