Hello, I am new to 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
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- إدارة علاقات العملاء
- e-Commerce
- المحاسبة
- المخزون
- PoS
- Project
- MRP
لقد تم الإبلاغ عن هذا السؤال
Hi,
Check the odoo documention for respective version here
https://www.odoo.com/documentation/14.0/ , regarding compute function.
field_1 = fields.Date(string="")
field_2 = fields.Date(string="")
field_3 = fields.Integer(compute='_compute_days', string="")
@api.multi
@api.depends('field_1', 'field_2')
def _compute_days(self):
for record in self:
record.field_3 = (record.field_1 - record.field_2).days
Hope it helps,
Thanks
Thank you very much for answering, now when testing your code I realize that I do not know where to insert it, forgive my ingorance is that I am starting to study programming now and becoming familiar with odoo. You could tell me where to put the code, I would appreciate it, I tried here but it didn't work for me:
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيلالمنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
---|---|---|---|---|
|
2
يناير 24
|
2670 | ||
|
2
سبتمبر 23
|
5486 | ||
Add Any Number To Date
تم الحل
|
|
2
ديسمبر 23
|
7268 | |
|
2
يونيو 22
|
4601 | ||
|
1
يوليو 18
|
4722 |