@@ -533,22 +533,35 @@ def create_production_plan(settings, prod_plan_from_doc):
533533
534534 pp .make_work_order ()
535535 wos = frappe .get_all ("Work Order" , {"production_plan" : pp .name })
536+ start_time = datetime .datetime (settings .day .year , settings .day .month , settings .day .day , 0 , 0 )
536537 for wo in wos :
537538 wo = frappe .get_doc ("Work Order" , wo )
538539 wo .wip_warehouse = "Kitchen - APC"
540+ wo .actual_start_date = wo .planned_start_date = start_time
541+ wo .required_items = sorted (wo .required_items , key = lambda x : x .get ("item_code" ))
542+ for idx , w in enumerate (wo .required_items , start = 1 ):
543+ w .idx = idx
539544 wo .save ()
540545 wo .submit ()
546+ frappe .db .set_value ("Work Order" , wo .name , "creation" , start_time )
541547 job_cards = frappe .get_all ("Job Card" , {"work_order" : wo .name })
542548 for job_card in job_cards :
543549 job_card = frappe .get_doc ("Job Card" , job_card )
550+ batch_size , total_operation_time = frappe .get_value (
551+ "Operation" , job_card .operation , ["batch_size" , "total_operation_time" ]
552+ )
553+ time_in_mins = (total_operation_time / batch_size ) * wo .qty
544554 job_card .append (
545555 "time_logs" ,
546556 {
547- "completed_qty" : wo .qty ,
557+ "from_time" : start_time ,
558+ "to_time" : start_time + datetime .timedelta (minutes = time_in_mins ),
559+ "time_in_mins" : time_in_mins ,
560+ "remaining_time_in_mins" : time_in_mins ,
548561 },
549562 )
550563 job_card .save ()
551- job_card .submit ( )
564+ start_time = job_card .time_logs [ 0 ]. to_time + datetime . timedelta ( minutes = 2 )
552565
553566
554567def create_purchase_receipt_for_received_qty_test (settings ):
0 commit comments