跳至内容
菜单
此问题已终结
1 回复
1396 查看
export function getRelativeDateDomain(now, offset, rangeType, fieldName, fieldType) {
const startOfNextDay = now.plus({ days: 1 }).startOf("day");
let endDate = now.endOf("day");
let startDate = endDate;
switch (rangeType) {
case "year_to_date": {
const offsetParam = { years: offset };
startDate = now.startOf("year").plus(offsetParam);
endDate = now.endOf("day").plus(offsetParam);
break;
}
case "last_week": {
const offsetParam = { days: 7 * offset };
endDate = endDate.plus(offsetParam);
startDate = startOfNextDay.minus({ days: 7 }).plus(offsetParam);
break;
}
case "last_month": {
const offsetParam = { days: 30 * offset };
endDate = endDate.plus(offsetParam);
startDate = startOfNextDay.minus({ days: 30 }).plus(offsetParam);
break;
}
case "last_three_months": {
const offsetParam = { days: 90 * offset };
endDate = endDate.plus(offsetParam);
startDate = startOfNextDay.minus({ days: 90 }).plus(offsetParam);
break;
}
case "last_six_months": {
const offsetParam = { days: 180 * offset };
endDate = endDate.plus(offsetParam);
startDate = startOfNextDay.minus({ days: 180 }).plus(offsetParam);
break;
}
case "last_year": {
const offsetParam = { days: 365 * offset };
endDate = endDate.plus(offsetParam);
startDate = startOfNextDay.minus({ days: 365 }).plus(offsetParam);
break;
}
case "last_three_years": {
const offsetParam = { days: 3 * 365 * offset };
endDate = endDate.plus(offsetParam);
startDate = startOfNextDay.minus({ days: 3 * 365 }).plus(offsetParam);
break;
}
default:
return undefined;
}

let leftBound, rightBound;
if (fieldType === "date") {
leftBound = serializeDate(startDate);
rightBound = serializeDate(endDate);
} else {
leftBound = serializeDateTime(startDate);
rightBound = serializeDateTime(endDate);
}

return new Domain(["&", [fieldName, ">=", leftBound], [fieldName, "}


I want to inherit this function and modify it to use it. I don't know how to proceed, I tried several methods: patching etc... but nothing

形象
丢弃
最佳答案

Hello soro kader, 


I hope you are doing well.


After research and analysis, I found that the method “getRelativeDateDomain” cannot be inherited. As a solution, you need to replace this function with your custom function at the point where it is called. 

I’ve attached a screenshot for your reference, showing where the “getRelativeDateDomain” method is called from within the Base Odoo Addons.

I Hope this information proves helpful to you.

Thanks & Regards,

Email:   odoo@aktivsoftware.com           

Skype: kalpeshmaheshwari 

形象
丢弃
相关帖文 回复 查看 活动
3
7月 25
2209
1
6月 25
2847
2
5月 25
2182
1
5月 25
1349
1
2月 25
38