如何在计算域的域中指定日期:
for record in self:
last_confirmed_order = self.env['sale.order'].search(
[('partner_id', '=', record.name),('date_order','>=',time.strftime('%Y-%m-%d'))],
order='date_order desc',
limit=1000
)
sum = 0
for x in last_confirmed_order:
sum = sum + x.amount_total
record['x_last_order_sum'] = sum
感谢我将代码调整为的建议
for record in self:
today=time.strftime('%Y-%m-%d')
last_confirmed_order = self.env['sale.order'].search(
[('partner_id', '=', record.name),('date_order','=',today)],
order='date_order desc',
limit=1000
)
record['x_last_order'] = last_confirmed_order.date_order
for x in last_confirmed_order:
sum = sum + x.amount_total
record['x_last_order_sum'] = sum
我没有收到错误,但值保持为零。虽然我今天确实有该客户的订单。我是否必须将 date_order 转换为与 YMD 相同的格式?