[FIX] web: display daterange separator in readonly
Before this commit, a forward-ported fix regarding the display of the arrow separator in daterange fields has been incorrectly adapted to fit conflicting changes, and the separator does not appear in readonly with both date values set. This commit fixes that by restoring the proper conditions. closes odoo/odoo#128509 Signed-off-by: Géry Debongnie <ged@odoo.com>
This commit is contained in:
@@ -213,8 +213,8 @@ export class DateTimeField extends Component {
|
||||
shouldShowSeparator() {
|
||||
return (
|
||||
this.state.range &&
|
||||
this.props.required &&
|
||||
(this.isEmpty(this.startDateField) || this.isEmpty(this.endDateField))
|
||||
(this.props.required ||
|
||||
(!this.isEmpty(this.startDateField) && !this.isEmpty(this.endDateField)))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1074,6 +1074,27 @@ QUnit.module("Fields", (hooks) => {
|
||||
assert.containsNone(target, ".o_add_date");
|
||||
});
|
||||
|
||||
QUnit.test("related start date, required, both start date and end date set", async (assert) => {
|
||||
serverData.models.partner.fields.date_end = { string: "Some Date", type: "date" };
|
||||
const [firstRecord] = serverData.models.partner.records;
|
||||
firstRecord.date_end = firstRecord.date;
|
||||
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
arch: /* xml */ `
|
||||
<form>
|
||||
<field name="date" widget="daterange" options="{'start_date_field': 'date_end'}" required="1" />
|
||||
</form>`,
|
||||
resId: 1,
|
||||
});
|
||||
|
||||
assert.strictEqual(getInputs()[0].value, "02/03/2017");
|
||||
assert.containsOnce(target, ".fa-long-arrow-right");
|
||||
assert.strictEqual(getInputs()[1].value, "02/03/2017");
|
||||
});
|
||||
|
||||
QUnit.test("list daterange with start date and empty end date", async (assert) => {
|
||||
serverData.models.partner.fields.date_end = { string: "Some Date", type: "date" };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user