*.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
- Comptabilité
- Inventaire
- PoS
- Project
- MRP
Cette question a été signalée
1
Répondre
3880
Vues
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???
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrirePublications associées | Réponses | Vues | Activité | |
---|---|---|---|---|
|
3
juin 25
|
1031 | ||
|
1
janv. 25
|
17928 | ||
|
1
déc. 19
|
6338 | ||
|
1
déc. 19
|
17251 | ||
|
3
avr. 18
|
5141 |