recompute labor cost
							parent
							
								
									091e327db3
								
							
						
					
					
						commit
						68a5621d4b
					
				|  | @ -2,8 +2,8 @@ | |||
|     <head> | ||||
|         <field name="state"/> | ||||
|         <button string="Options" dropdown="1"> | ||||
|             <item string="Copy" method="copy" states="active"/> | ||||
|             <item string="To Draft" method="to_draft" states="drop,active,expire"/> | ||||
|             <item string="Copy" method="copy" states="active,drop,expire"/> | ||||
|             <item string="To Draft" method="to_draft" states="active"/> | ||||
|         </button> | ||||
|     </head> | ||||
|     <group span="6" columns="1"> | ||||
|  |  | |||
|  | @ -914,9 +914,6 @@ class HDCase(Model): | |||
|                 use_time=dlz_line.use_time or 0 | ||||
|                 max_use_time=dlz_line.max_use_time or 0 | ||||
|                 desc=dlz_line.description or '' | ||||
|                 #TODO when we to draft after approve hdcase it will update the wrong use time | ||||
|                 #if use_time > (dlz.use_time or 0): | ||||
|                     #continue | ||||
|                 if is_decrease: | ||||
|                     use_time-=1 | ||||
|                 vals={ | ||||
|  | @ -957,7 +954,7 @@ class HDCase(Model): | |||
|             cycle_item_ids=cycle_item.search(dom) | ||||
|             cycle_item_id=None | ||||
|             if cycle_item_ids: | ||||
|                 cycle_item_id=cycle_item_ids[0] | ||||
|                 cycle_item_id=cycle_item_ids[-1] | ||||
|             else: | ||||
|                 cycle_item_id=cycle_item.create({ | ||||
|                     'date': obj.date, | ||||
|  | @ -1013,7 +1010,6 @@ class HDCase(Model): | |||
|         obj.make_invoices(context=context) | ||||
|         obj.post_invoices(context=context) | ||||
|         obj.create_cycle_item() | ||||
|         #obj.do_expense(context=context) | ||||
|         vals={ | ||||
|             "state":"waiting_payment", # for government | ||||
|         } | ||||
|  | @ -1023,6 +1019,7 @@ class HDCase(Model): | |||
|             date=obj.date | ||||
|             vals['time_stop']='%s %s'%(date,timenow) | ||||
|         obj.write(vals) | ||||
|         obj.recompute_labor_cost() | ||||
|         if context.get("called"): | ||||
|             return obj.id | ||||
|         return { | ||||
|  | @ -1058,12 +1055,10 @@ class HDCase(Model): | |||
| 
 | ||||
|     def undo(self,ids,context={}): | ||||
|         obj=self.browse(ids)[0] | ||||
|         # recompute labor cost | ||||
|         lc=get_model("clinic.labor.cost").search_browse([['cycle_item_id','=',obj.cycle_item_id.id]]) | ||||
|         if lc: | ||||
|             lc.compute() | ||||
|         context['is_decrease']=True | ||||
|         # in case to draft | ||||
|         # should not reset use time if not the day of treatment is not today | ||||
|         datenow=time.strftime("%Y-%m-%d") | ||||
|         if obj.date==datenow: | ||||
|             obj.update_usetime(context=context) | ||||
|         for line in obj.lines: | ||||
|             line.write({ | ||||
|  | @ -1087,7 +1082,7 @@ class HDCase(Model): | |||
|             payment.delete() | ||||
|         for pm_line in obj.payment_lines: | ||||
|             pm_line.delete() | ||||
| 
 | ||||
|         #XXX remove | ||||
|         for exp in obj.expenes: | ||||
|             exp.delete() | ||||
| 
 | ||||
|  | @ -1100,7 +1095,7 @@ class HDCase(Model): | |||
|             obj.sickbed_id.write({ | ||||
|                 'available': False, | ||||
|             }) | ||||
| 
 | ||||
|         obj.recompute_labor_cost() | ||||
|         return { | ||||
|             'next': { | ||||
|                 'name': 'clinic_hd_case', | ||||
|  | @ -1110,6 +1105,15 @@ class HDCase(Model): | |||
|             'flash': '%s has been undo'%obj.number, | ||||
|         } | ||||
| 
 | ||||
|     def recompute_labor_cost(self,ids,context={}): | ||||
|         for obj in self.browse(ids): | ||||
|                 cit=obj.cycle_item_id | ||||
|                 # recompute labor cost | ||||
|                 if cit.state=='validated': | ||||
|                     for lc in get_model("clinic.labor.cost").search_browse([['cycle_item_id','=',cit.id]]): | ||||
|                         lc.compute() | ||||
|          | ||||
| 
 | ||||
|     def view_payment(self,ids,context={}): | ||||
|         print("clinic_view_payment") | ||||
|         return { | ||||
|  |  | |||
|  | @ -31,7 +31,7 @@ class HDCaseDialyzerLine(Model): | |||
|         "membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"), | ||||
|         'hdcase_date': fields.Date('Date', function="_get_all",function_multi=True), | ||||
|         "hdcase_state": fields.Selection([("draft","Draft"),('waiting_treatment','Waiting Treatment'),("in_progress","In Progress"),("completed","Finish Treatment"),('paid','Paid'),("waiting_payment","Waiting Payment"),("discountinued","Discountinued"),("cancelled","Cancelled")],"Status",required=True,function="_get_all",function_multi=True), | ||||
|         'nurse_id': fields.Many2One('clinic.staff', 'Nurse',function="_get_all",function_multi=True), | ||||
|         'nurse_id': fields.Many2One('clinic.staff', 'Use by',function="_get_all",function_multi=True), | ||||
|         "state": fields.Selection([("new","New"),("active","Active"),("drop","Drop"),("expire","Expire"),('cancelled','Cancelled')],"Status",function="_get_dlz_state"), | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -65,6 +65,7 @@ class HDCasePayment(Model): | |||
|         obj.write({ | ||||
|             'pay_amount': hd_case.amount, | ||||
|         }) | ||||
|         hd_case.recompute_labor_cost() | ||||
|         return { | ||||
|             'next': { | ||||
|                 'name': 'clinic_hd_case', | ||||
|  | @ -85,6 +86,7 @@ class HDCasePayment(Model): | |||
|             'state': 'waiting_payment', | ||||
|             'req_fee': 0, # force to hide button pay! | ||||
|         }) | ||||
|         hd_case.recompute_labor_cost() | ||||
|         inv_number=[] | ||||
|         for inv in hd_case.invoices: | ||||
|             inv_number.append(inv.number or "") | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue