[FIX] web: py.js evaluation of current_date
current_date was absent from py_builtin. For that reason, it was
impossible for the search model to evaluate a dynamic domains like
"[('date_deadline', '<', current_date)]"
We add current_date to py_builtin.
closes odoo/odoo#77035
X-original-commit: ade082c5ad9221c82de90ddbe68b814b1487753d
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
This commit is contained in:
@@ -31,6 +31,11 @@ export const BUILTINS = {
|
||||
return PyDate.today();
|
||||
},
|
||||
|
||||
get current_date() {
|
||||
// deprecated: today should be prefered
|
||||
return this.today;
|
||||
},
|
||||
|
||||
get today() {
|
||||
return PyDate.today().strftime("%Y-%m-%d");
|
||||
},
|
||||
|
||||
@@ -190,5 +190,10 @@ QUnit.module("py", {}, () => {
|
||||
QUnit.test("now", (assert) => {
|
||||
assert.ok(check("now", formatDateTime));
|
||||
});
|
||||
|
||||
QUnit.test("current_date", (assert) => {
|
||||
patchDate(2021, 8, 20, 10, 0, 0);
|
||||
assert.deepEqual(evaluateExpr("current_date"), "2021-09-20");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -793,6 +793,7 @@ QUnit.module("Search", (hooks) => {
|
||||
<filter name="filter_0" domain="[('datetime', '=', (datetime.datetime.combine(context_today(), datetime.time(0,0,0)).to_utc()))]"/>
|
||||
<filter name="filter_1" domain="[('date', '=', context_today() + relativedelta(days=-365))]"/>
|
||||
<filter name="filter_2" domain="[('create_date', '>', (context_today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d'))]"/>
|
||||
<filter name="filter_3" domain="[('date_deadline', '<', current_date)]"/>
|
||||
</search>
|
||||
`;
|
||||
|
||||
@@ -800,6 +801,7 @@ QUnit.module("Search", (hooks) => {
|
||||
[["datetime", "=", "2021-09-16 22:00:00"]],
|
||||
[["date", "=", "2020-09-17 00:00:00"]],
|
||||
[["create_date", ">", "2021-09-16"]],
|
||||
[["date_deadline", "<", "2021-09-17"]],
|
||||
];
|
||||
|
||||
const model = await makeSearchModel({ serverData, searchViewArch });
|
||||
|
||||
Reference in New Issue
Block a user