Hello,
Please i need help how can i add new field in odoo studio on a vue to calculate the difference between (DATE DE PREPARATION - DATE DE COMMANDE )
Thanks
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello,
Please i need help how can i add new field in odoo studio on a vue to calculate the difference between (DATE DE PREPARATION - DATE DE COMMANDE )
Thanks
Hi
Try the following code,
from datetime import datetime
from_date = fields.Date(string="Register date")
final_date = fields.Date(string="Last date")
total_days = fields.Integer(string="TOTAL DAYS")
@api.onchange('from_date', 'final_date', 'total_days')
def calculate_date(self):
if self.from_date and self.final_date:
d1 = datetime.strptime(str(self.from_date), '%Y-%m-%d')
d2 = datetime.strptime(str(self.final_date), '%Y-%m-%d')
d3 = d2 - d1
self.total_days = str(d3.days)
Hope it helps
Create an account today to enjoy exclusive features and engage with our awesome community!
Prijavi
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.