new & drop dlz on hd case option
							parent
							
								
									1a408090c3
								
							
						
					
					
						commit
						d8fcfdb126
					
				| 
						 | 
					@ -6,6 +6,7 @@
 | 
				
			||||||
    <field name="membrane_type" required="1" span="6"/>
 | 
					    <field name="membrane_type" required="1" span="6"/>
 | 
				
			||||||
    <field name="exp_date" span="6"/>
 | 
					    <field name="exp_date" span="6"/>
 | 
				
			||||||
    <field name="note" span="6"/>
 | 
					    <field name="note" span="6"/>
 | 
				
			||||||
 | 
					    <field name="drop_old" span="6"/>
 | 
				
			||||||
    <foot>
 | 
					    <foot>
 | 
				
			||||||
        <button string="Validate" type="success" method="new_dlz"/>
 | 
					        <button string="Validate" type="success" method="new_dlz"/>
 | 
				
			||||||
    </foot>
 | 
					    </foot>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -56,6 +56,7 @@
 | 
				
			||||||
                        <field name="use_time"/>
 | 
					                        <field name="use_time"/>
 | 
				
			||||||
                        <field name="max_use_time"/>
 | 
					                        <field name="max_use_time"/>
 | 
				
			||||||
                        <field name="description"/>
 | 
					                        <field name="description"/>
 | 
				
			||||||
 | 
					                        <field name="state"/>
 | 
				
			||||||
                    </list>
 | 
					                    </list>
 | 
				
			||||||
                </field>
 | 
					                </field>
 | 
				
			||||||
                <field name="note"/>
 | 
					                <field name="note"/>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1305,7 +1305,20 @@ class HDCase(Model):
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def new_dialyzer(self,ids,context={}):
 | 
					    def new_dialyzer(self,ids,context={}):
 | 
				
			||||||
 | 
					        '''
 | 
				
			||||||
 | 
					            drop old one and create new dlz
 | 
				
			||||||
 | 
					        '''
 | 
				
			||||||
        obj=self.browse(ids)[0]
 | 
					        obj=self.browse(ids)[0]
 | 
				
			||||||
 | 
					        if context.get('drop_old'):
 | 
				
			||||||
 | 
					            for dlz_line in obj.dialyzers:
 | 
				
			||||||
 | 
					                dlz=dlz_line.dialyzer_id
 | 
				
			||||||
 | 
					                dlz_line.write({
 | 
				
			||||||
 | 
					                    'use_time': dlz.use_time,
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					                dlz.write({
 | 
				
			||||||
 | 
					                    'state': 'drop',
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        is_wiz=context.get("is_wiz")
 | 
					        is_wiz=context.get("is_wiz")
 | 
				
			||||||
        dlz_vals={}
 | 
					        dlz_vals={}
 | 
				
			||||||
        if is_wiz:
 | 
					        if is_wiz:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,6 +14,13 @@ class HDCaseDialyzerLine(Model):
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        return res
 | 
					        return res
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def _get_dlz_state(self,ids,context={}):
 | 
				
			||||||
 | 
					        res={}
 | 
				
			||||||
 | 
					        for obj in self.browse(ids):
 | 
				
			||||||
 | 
					            dlz=obj.dialyzer_id
 | 
				
			||||||
 | 
					            res[obj.id]=dlz.state
 | 
				
			||||||
 | 
					        return res
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _fields={
 | 
					    _fields={
 | 
				
			||||||
        "hd_case_id": fields.Many2One("clinic.hd.case","HDCase",on_delete="cascade"),
 | 
					        "hd_case_id": fields.Many2One("clinic.hd.case","HDCase",on_delete="cascade"),
 | 
				
			||||||
        "dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type"),
 | 
					        "dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type"),
 | 
				
			||||||
| 
						 | 
					@ -25,6 +32,7 @@ class HDCaseDialyzerLine(Model):
 | 
				
			||||||
        'hdcase_date': fields.Date('Date', function="_get_all",function_multi=True),
 | 
					        '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),
 | 
					        "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', 'Nurse',function="_get_all",function_multi=True),
 | 
				
			||||||
 | 
					        "state": fields.Selection([("new","New"),("active","Active"),("drop","Drop"),("expire","Expire"),('cancelled','Cancelled')],"Status",function="_get_dlz_state"),
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _order="hd_case_id.date desc"
 | 
					    _order="hd_case_id.date desc"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,6 +12,7 @@ class HDCasePopupDlz(Model):
 | 
				
			||||||
        "exp_date": fields.Date("Expiry Date"),
 | 
					        "exp_date": fields.Date("Expiry Date"),
 | 
				
			||||||
        "note": fields.Text("Note"),
 | 
					        "note": fields.Text("Note"),
 | 
				
			||||||
        "membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
 | 
					        "membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
 | 
				
			||||||
 | 
					        'drop_old': fields.Boolean("Drop Old Dialyzer"),
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def __get_hd_case_id(self,context={}):
 | 
					    def __get_hd_case_id(self,context={}):
 | 
				
			||||||
| 
						 | 
					@ -45,6 +46,7 @@ class HDCasePopupDlz(Model):
 | 
				
			||||||
            'membrane_type': membrane_type,
 | 
					            'membrane_type': membrane_type,
 | 
				
			||||||
            'max_use_time': max_use_time,
 | 
					            'max_use_time': max_use_time,
 | 
				
			||||||
            'product_id': product_id,
 | 
					            'product_id': product_id,
 | 
				
			||||||
 | 
					            'drop_old': True,
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        print('res', res)
 | 
					        print('res', res)
 | 
				
			||||||
        return res
 | 
					        return res
 | 
				
			||||||
| 
						 | 
					@ -56,6 +58,7 @@ class HDCasePopupDlz(Model):
 | 
				
			||||||
        if hd_case:
 | 
					        if hd_case:
 | 
				
			||||||
            context['is_wiz']=True
 | 
					            context['is_wiz']=True
 | 
				
			||||||
            context['pop_id']=obj.id
 | 
					            context['pop_id']=obj.id
 | 
				
			||||||
 | 
					            context['drop_old']=obj.drop_old
 | 
				
			||||||
            res=hd_case.new_dialyzer(context=context)
 | 
					            res=hd_case.new_dialyzer(context=context)
 | 
				
			||||||
        print('res ', res)
 | 
					        print('res ', res)
 | 
				
			||||||
        return res
 | 
					        return res
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue