*.py
###Part One
from datetime import date, datetime, timedelta, time
from time import time
import time
import calendar
###Part Two
#Count Date
hire_date = fields.Date(string="Hire Date", default=fields.Date.today)
count_start = fields.Date(string="Count Start", default=fields.Date.today, store=True, compute='_get_count_start', inverse='_write_count_start')
count_end = fields.Date(string="Count End", default=fields.Date.today, store=True, compute='_get_count_end', inverse='_write_count_end')
resign_date = fields.Date(string="Resign Date", default="3000-12-31")
#Count Date
###Part Three
#Count Date
@api.onchange('hire_date')
def _get_count_start(self):
for hr_employee_id in self:
if hr_employee_id.hire_date > hr_employee_id.count_start:
hr_employee_id.count_start = hr_employee_id.hire_date
def _write_count_start(self):
for hr_employee_id in self:
if hr_employee_id.hire_date > hr_employee_id.count_start:
hr_employee_id.count_start = hr_employee_id.hire_date
@api.onchange('resign_date')
def _get_count_end(self):
for hr_employee_id in self:
if hr_employee_id.resign_date < hr_employee_id.count_end:
hr_employee_id.count_end = hr_employee_id.resign_date+timedelta(-1)
def _write_count_end(self):
for hr_employee_id in self:
if hr_employee_id.resign_date < hr_employee_id.count_end:
hr_employee_id.count_end = hr_employee_id.resign_date+timedelta(-1)
#Count Date
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
1
Reply
2542
Views
HI,
Try this,
start_date = fields.Date.from_string(start_date)
last_date = fields.Date.from_string(last_date)
number_of_days = (last_date - start_date).days
If you search inside the odoo code for .days you can see a lot of such examples/use cases.
Thanks
Thank you very much
for time count???
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Jan 24
|
16294 | ||
|
1
Dec 19
|
4561 | ||
|
1
Dec 19
|
15672 | ||
|
3
Apr 18
|
4097 | ||
|
1
May 16
|
5364 |