@@ -482,7 +482,7 @@ def write(self, values):
482482
483483 for init_local_state , build in zip (init_local_states , self ):
484484 if init_local_state not in ('done' , 'running' ) and build .local_state in ('done' , 'running' ):
485- build .build_end = now ()
485+ build .build_end = self . env . cr . now ()
486486
487487 for init_global_state , build in zip (init_global_states , self ):
488488 if init_global_state not in ('done' , 'running' ) and build .global_state in ('done' , 'running' ):
@@ -503,6 +503,12 @@ def _add_child(self, param_values, orphan=False, description=False, additionnal_
503503 commit_link_ids |= additionnal_commit_links
504504 param_values ['commit_link_ids' ] = commit_link_ids
505505
506+ if "faketime" in param_values .get ('config_data' , {}):
507+ current_offset = param_values ['config_data' ].get ('faketime_offset' , 0 )
508+ new_offest = current_offset + self .build_time
509+ new_config_data = {** param_values .get ('config_data' , {}), 'faketime_offset' : new_offest }
510+ param_values ['config_data' ] = new_config_data
511+
506512 return self .create ({
507513 'params_id' : self .params_id .copy (param_values ).id ,
508514 'parent_id' : self .id ,
@@ -565,7 +571,7 @@ def _compute_build_time(self):
565571 if build .build_end and build .build_start :
566572 build .build_time = int (dt2time (build .build_end ) - dt2time (build .build_start ))
567573 elif build .build_start :
568- build .build_time = int (time . time ( ) - dt2time (build .build_start ))
574+ build .build_time = int (dt2time ( self . env . cr . now () ) - dt2time (build .build_start ))
569575 else :
570576 build .build_time = 0
571577
@@ -783,8 +789,8 @@ def _init_pendings(self):
783789 self .ensure_one ()
784790 build = self
785791 build .port = self ._find_port ()
786- build .job_start = now ()
787- build .build_start = now ()
792+ build .job_start = self . env . cr . now ()
793+ build .build_start = self . env . cr . now ()
788794 build .job_end = False
789795 build ._log ('_schedule' , 'Init build environment with config %s ' % build .params_id .config_id .name )
790796 try :
@@ -818,7 +824,7 @@ def _process_requested_actions(self):
818824 try :
819825 port = self ._find_port ()
820826 build .write ({
821- 'job_start' : now (),
827+ 'job_start' : self . env . cr . now (),
822828 'job_end' : False ,
823829 'active_step' : False ,
824830 'requested_action' : False ,
@@ -875,7 +881,7 @@ def _schedule(self):
875881 return True # avoid to make results with remaining logs
876882 # No job running, make result and select next job
877883
878- build .job_end = now ()
884+ build .job_end = self . env . cr . now ()
879885 build .docker_start = False
880886 # make result of previous job
881887 try :
@@ -1165,9 +1171,9 @@ def _kill(self, result=None):
11651171 return
11661172 build ._log ('kill' , 'Kill build %s' % build .dest )
11671173 docker_stop (build ._get_docker_name (), build ._path ())
1168- v = {'local_state' : 'done' , 'requested_action' : False , 'active_step' : False , 'job_end' : now ()}
1174+ v = {'local_state' : 'done' , 'requested_action' : False , 'active_step' : False , 'job_end' : self . env . cr . now ()}
11691175 if not build .build_end :
1170- v ['build_end' ] = now ()
1176+ v ['build_end' ] = self . env . cr . now ()
11711177 if result :
11721178 v ['local_result' ] = result
11731179 build .write (v )
@@ -1281,9 +1287,11 @@ def _cmd(self, python_params=None, py_version=None, local_only=True, sub_command
12811287
12821288 faketime = []
12831289 if faketime_params := self .params_id .config_data .get ('faketime' ):
1284- if self .parent_id :
1285- parent_time_offset = (self .parent_id .build_end or self .create_date ) - self .parent_id .build_start
1286- faketime_params = (parser .parse (faketime_params ) + parent_time_offset ).strftime ('%Y-%m-%d %H:%M %Z' )
1290+ time_offset_seconds = self .build_time
1291+ if self .params_id .config_data .get ('faketime_offset' ) or self .parent_id :
1292+ time_offset_seconds = self .params_id .config_data .get ('faketime_offset' , self .parent_id .build_time )
1293+ time_offset = datetime .timedelta (seconds = time_offset_seconds )
1294+ faketime_params = (parser .parse (faketime_params ) + time_offset ).strftime ('%Y-%m-%d %H:%M %Z' )
12871295 faketime = ['faketime' , faketime_params ]
12881296
12891297 addons_paths = self ._get_addons_path ()
0 commit comments