我正在尝试使用这里记录的DB获得在给定月份内结束的订阅。
我可以在某一次约会之前:
end_period = datetime.date(2020, 12, 31)
frappe.db.get_list('Subscription', filters={
'current_invoice_end': ['<', end_period]
})但是我将如何在end_period之前和start_period之后指定
当我试着
frappe.db.get_list('Subscription', filters={
'current_invoice_end': ['<', end_period],
'current_invoice_end': ['>', start_period]
})它把它当作“或”,列出范围以外的东西。
交叉张贴在https://discuss.erpnext.com/t/how-to-use-a-date-range-with-db-api/62348
发布于 2020-06-17 04:28:24
您可以在erpnext src中快速搜索“中间”以检查实现。这是我唯一可靠的消息来源。
"holiday_date": ["between", (self.start_date, self.end_date)],您发布的解决方案不起作用,因为Python不允许在dict上使用两个名称相同的键。
返回列表的另一个解决方案可能是
holidays = frappe.db.sql_list('''select holiday_date, rate from `tabHoliday`
where
parent=%(holiday_list)s
and holiday_date >= %(start_date)s
and holiday_date <= %(end_date)s''', {
"holiday_list": holiday_list,
"start_date": self.start_date,
"end_date": self.end_date
})发布于 2020-07-06 04:40:53
还可以将筛选器作为列表传递:
frappe.db.get_list('Subscription', filters=[
['current_invoice_end', '<', end_period],
['current_invoice_end', '>', start_period]
])为此,我将避免使用直接SQL!
https://stackoverflow.com/questions/62201849
复制相似问题