Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
347 Lượt xem

Hi,
In Odoo 18 i want to generate a new field in the other information of an order.
The field should be a computed field, to calculate how many days have passed since the order.
I know how to add fields in studio but have trouble with my compute function:

for record in self:
    if record.date_order:
        delta = (fields.Date.today() - record.date_order.date()).days
        record['x_days_since_order'] = delta
    else:
        record['x_days_since_order'] = 0
Ảnh đại diện
Huỷ bỏ