Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
3726 Lượt xem
Hello, I am trying to create a calculated field that will calculate the difference in days between two dates. I have tried this way but it does not work for me

for record in self:
   record[(x_dpuerto)] = record(datetime.now()) - record(x_farribo)

thanks
Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất
Hello thanks for answering I have tried this but it still does not return the days between the two dates. Could you help me find the error?

for record in datetime:
        record ['x_ftest'] = record.x_farribo - record.x_eta

and this is the error that returns:
ValueError: <class 'TypeError'>: "'WrappedModule' object is not iterable" while evaluating
"for record in datetime: \ n record ['x_ftest'] = record.x_farribo - record.x_eta"

Ảnh đại diện
Huỷ bỏ

Hi,

record[(x_dpuerto)] is it a static or a dynamic field ..???

If its static you can go with Mr. Niyas's Answer,

If its a dynamic one ie, difference between two dates when you calculate on today is 20 and for tomorrow it will be 21 ..???

Câu trả lời hay nhất

Hi,

Try like this,

days = (date_1 - date_2).days

Thanks

Ảnh đại diện
Huỷ bỏ
Tác giả

Hello, thank you for answering me so quickly, I am new to using odoo and I would like to create a calculated field that gives me the difference in days between two dates. I don't know much about programming but I would like to get a solution to my problem. thanks in advance

Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 6 25
1041
1
thg 7 23
3741
4
thg 12 22
9676
1
thg 10 18
5084
1
thg 10 16
4509