Se rendre au contenu
Menu
Cette question a été signalée
2643 Vues

I add default fuction in my start_datetime and date_deadline fields and that is working fine in form view , but when I create from gantt view, default value is not display. start_datetime field hour is always displayed 00:00:00 and date_dateline field's hour is always displayed with 23:59:59. How can I fixed it.My screenshot is here https://ibb.co/z8DD7NM

def _default_start_date(self):
        tz = pytz.timezone(self.env.user.tz)
        dt = fields.Datetime.now()
        newdatetime = dt.replace(hour=9, minute=00,second=00)
        logging.info("final date++++++++++++++++")
        logging.info(newdatetime)
        aware_d = tz.localize(newdatetime,is_dst=None)
        utc_d =aware_d.astimezone(pytz.utc)
        # local_datetime = pytz.utc.localize(newdatetime).astimezone(destination_tz).replace(tzinfo=None)
        logging.info("Time zone_+++++++++++++++")
        logging.info(tz)
        logging.info(utc_d)
        final_time = utc_d.strftime('%Y-%m-%d %H:%M:%S')
        return final_time
    def _default_end_date(self):
        tz = pytz.timezone(self.env.user.tz)
        dt = fields.Datetime.now()
        newdatetime = dt.replace(hour=18, minute=00,second=00)
        logging.info("final date++++++++++++++++")
        logging.info(newdatetime)
        aware_d = tz.localize(newdatetime,is_dst=None)
        utc_d =aware_d.astimezone(pytz.utc)
        # local_datetime = pytz.utc.localize(newdatetime).astimezone(destination_tz).replace(tzinfo=None)
        logging.info("Time zone_+++++++++++++++")
        logging.info(tz)
        logging.info(utc_d)
        final_time = utc_d.strftime('%Y-%m-%d %H:%M:%S')
        return final_time
    start_date = fields.Datetime(string="Starting Date",default=_default_start_date)
    date_deadline = fields.Datetime(string='Deadline', index=True, copy=False, tracking=True,default=_default_end_date)



Avatar
Ignorer
Publications associées Réponses Vues Activité
1
mai 22
5792
1
août 21
6307
1
juin 25
1048
3
mai 18
7839
1
févr. 23
5335