How can I specify a date in the domain of a computed field:
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
Thx for the advice I adjusted my code to
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
I get no error but the value stays zero. While I do have orders for that customer today. Do I have to convert date_order to same format as Y M D ?
the domain filter operator is the problem
Try using '>=' instead of ">="