[FIX] mail: fix tracking value issue when value is 0
Before this commit: When a tracking field is set to 0, the mail tracking value doesn't display 0 in the chatter. It is empty instead i.e: Field Name: 1 -> After this commit: Tracking value will show the changed value even if it is false or 0 i.e: Field name: 1 -> 0 closes odoo/odoo#58423 Task: 2334048 Closes: https://github.com/odoo/odoo/pull/57342 X-original-commit: 57f4018694a895fd804b51e8206503e3d1d3c5d4 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
committed by
Sébastien Theys
parent
ebe118fc60
commit
b0e2894161
@@ -165,15 +165,11 @@
|
||||
<t t-foreach="trackingValues" t-as="value" t-key="value.id">
|
||||
<li>
|
||||
<div class="o_Message_trackingValue">
|
||||
<div class="o_Message_trackingValueItem" t-esc="value.changed_field"/>
|
||||
<t t-if="value.old_value">
|
||||
<div class="o_Message_trackingValueItem" t-esc="value.old_value || ((value.field_type !== 'boolean') and '')"/>
|
||||
<t t-if="value.old_value !== value.new_value">
|
||||
<div class="o_Message_trackingValueItem fa fa-long-arrow-right" title="Changed" role="img"/>
|
||||
</t>
|
||||
</t>
|
||||
<div class="o_Message_trackingValueFieldName o_Message_trackingValueItem" t-esc="value.changed_field"/>
|
||||
<div class="o_Message_trackingValueOldValue o_Message_trackingValueItem" t-esc="value.old_value"/>
|
||||
<t t-if="value.old_value !== value.new_value">
|
||||
<div class="o_Message_trackingValueItem" t-esc="value.new_value || ((value.field_type !== 'boolean') and '')"/>
|
||||
<div class="o_Message_trackingValueSeparator o_Message_trackingValueItem fa fa-long-arrow-right" title="Changed" role="img"/>
|
||||
<div class="o_Message_trackingValueNewValue o_Message_trackingValueItem" t-esc="value.new_value"/>
|
||||
</t>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@@ -984,6 +984,195 @@ QUnit.test('open chat with author on avatar click should be disabled when curren
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('basic rendering of tracking value (float type)', async function (assert) {
|
||||
assert.expect(8);
|
||||
|
||||
await this.start();
|
||||
const message = this.env.models['mail.message'].create({
|
||||
id: 11,
|
||||
tracking_value_ids: [{
|
||||
changed_field: "Total",
|
||||
field_type: "float",
|
||||
id: 6,
|
||||
new_value: 45.67,
|
||||
old_value: 12.3,
|
||||
}],
|
||||
});
|
||||
await this.createMessageComponent(message);
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_Message_trackingValue',
|
||||
"should display a tracking value"
|
||||
);
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_Message_trackingValueFieldName',
|
||||
"should display the name of the tracked field"
|
||||
);
|
||||
assert.strictEqual(
|
||||
document.querySelector('.o_Message_trackingValueFieldName').textContent,
|
||||
"Total:",
|
||||
"should display the correct tracked field name (Total)",
|
||||
);
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_Message_trackingValueOldValue',
|
||||
"should display the old value"
|
||||
);
|
||||
assert.strictEqual(
|
||||
document.querySelector('.o_Message_trackingValueOldValue').textContent,
|
||||
"12.3",
|
||||
"should display the correct old value (12.3)",
|
||||
);
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_Message_trackingValueSeparator',
|
||||
"should display the separator"
|
||||
);
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_Message_trackingValueNewValue',
|
||||
"should display the new value"
|
||||
);
|
||||
assert.strictEqual(
|
||||
document.querySelector('.o_Message_trackingValueNewValue').textContent,
|
||||
"45.67",
|
||||
"should display the correct new value (45.67)",
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('rendering of tracked field with change of value from non-0 to 0', async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
await this.start();
|
||||
const message = this.env.models['mail.message'].create({
|
||||
id: 11,
|
||||
tracking_value_ids: [{
|
||||
changed_field: "Total",
|
||||
field_type: "float",
|
||||
id: 6,
|
||||
new_value: 0,
|
||||
old_value: 1,
|
||||
}],
|
||||
});
|
||||
await this.createMessageComponent(message);
|
||||
assert.strictEqual(
|
||||
document.querySelector('.o_Message_trackingValue').textContent,
|
||||
"Total:10",
|
||||
"should display the correct content of tracked field with change of value from non-0 to 0 (Total: 1 -> 0)"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('rendering of tracked field with change of value from 0 to non-0', async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
await this.start();
|
||||
const message = this.env.models['mail.message'].create({
|
||||
id: 11,
|
||||
tracking_value_ids: [{
|
||||
changed_field: "Total",
|
||||
field_type: "float",
|
||||
id: 6,
|
||||
new_value: 1,
|
||||
old_value: 0,
|
||||
}],
|
||||
});
|
||||
await this.createMessageComponent(message);
|
||||
assert.strictEqual(
|
||||
document.querySelector('.o_Message_trackingValue').textContent,
|
||||
"Total:01",
|
||||
"should display the correct content of tracked field with change of value from 0 to non-0 (Total: 0 -> 1)"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('rendering of tracked field with change of value from true to false', async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
await this.start();
|
||||
const message = this.env.models['mail.message'].create({
|
||||
id: 11,
|
||||
tracking_value_ids: [{
|
||||
changed_field: "Is Ready",
|
||||
field_type: "boolean",
|
||||
id: 6,
|
||||
new_value: false,
|
||||
old_value: true,
|
||||
}],
|
||||
});
|
||||
await this.createMessageComponent(message);
|
||||
assert.strictEqual(
|
||||
document.querySelector('.o_Message_trackingValue').textContent,
|
||||
"Is Ready:truefalse",
|
||||
"should display the correct content of tracked field with change of value from true to false (Is Ready: true -> false)"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('rendering of tracked field with change of value from false to true', async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
await this.start();
|
||||
const message = this.env.models['mail.message'].create({
|
||||
id: 11,
|
||||
tracking_value_ids: [{
|
||||
changed_field: "Is Ready",
|
||||
field_type: "boolean",
|
||||
id: 6,
|
||||
new_value: true,
|
||||
old_value: false,
|
||||
}],
|
||||
});
|
||||
await this.createMessageComponent(message);
|
||||
assert.strictEqual(
|
||||
document.querySelector('.o_Message_trackingValue').textContent,
|
||||
"Is Ready:falsetrue",
|
||||
"should display the correct content of tracked field with change of value from false to true (Is Ready: false -> true)"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('rendering of tracked field with change of value from string to empty', async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
await this.start();
|
||||
const message = this.env.models['mail.message'].create({
|
||||
id: 11,
|
||||
tracking_value_ids: [{
|
||||
changed_field: "Name",
|
||||
field_type: "char",
|
||||
id: 6,
|
||||
new_value: "",
|
||||
old_value: "Marc",
|
||||
}],
|
||||
});
|
||||
await this.createMessageComponent(message);
|
||||
assert.strictEqual(
|
||||
document.querySelector('.o_Message_trackingValue').textContent,
|
||||
"Name:Marc",
|
||||
"should display the correct content of tracked field with change of value from string to empty (Total: Marc ->)"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('rendering of tracked field with change of value from empty to string', async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
await this.start();
|
||||
const message = this.env.models['mail.message'].create({
|
||||
id: 11,
|
||||
tracking_value_ids: [{
|
||||
changed_field: "Name",
|
||||
field_type: "char",
|
||||
id: 6,
|
||||
new_value: "Marc",
|
||||
old_value: "",
|
||||
}],
|
||||
});
|
||||
await this.createMessageComponent(message);
|
||||
assert.strictEqual(
|
||||
document.querySelector('.o_Message_trackingValue').textContent,
|
||||
"Name:Marc",
|
||||
"should display the correct content of tracked field with change of value from empty to string (Total: -> Marc)"
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user