0

如何在计算域的域中指定日期:

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 相同的格式?

4

1 回答 1

2

域过滤器运算符是问题

尝试使用 '>=' 而不是 ">="

于 2018-04-12T09:58:13.697 回答