if no product in clinic setting, it shold be work too andc credit account will get from account setting -> income account
							parent
							
								
									2c23640475
								
							
						
					
					
						commit
						a6266c9ae1
					
				| 
						 | 
					@ -401,7 +401,10 @@ class HDCase(Model):
 | 
				
			||||||
                        #account_id=sline.account_id.id    
 | 
					                        #account_id=sline.account_id.id    
 | 
				
			||||||
                        account_id=sline.ar_credit_id.id    
 | 
					                        account_id=sline.ar_credit_id.id    
 | 
				
			||||||
                        break
 | 
					                        break
 | 
				
			||||||
                # 3.find in product(tab accounting)
 | 
					                # 3.find account in account setting -> income account
 | 
				
			||||||
 | 
					                if not account_id and not prod:
 | 
				
			||||||
 | 
					                    account_id=setting.income_account_id.id
 | 
				
			||||||
 | 
					                # 4.find in product(tab accounting)
 | 
				
			||||||
                if not account_id:
 | 
					                if not account_id:
 | 
				
			||||||
                    account_id=prod.sale_account_id.id
 | 
					                    account_id=prod.sale_account_id.id
 | 
				
			||||||
                    if not account_id:
 | 
					                    if not account_id:
 | 
				
			||||||
| 
						 | 
					@ -980,29 +983,33 @@ class HDCase(Model):
 | 
				
			||||||
            vals['lines']=[]
 | 
					            vals['lines']=[]
 | 
				
			||||||
            for st_prod in st.products:
 | 
					            for st_prod in st.products:
 | 
				
			||||||
                if patient.type_id.id==st_prod.patient_type_id.id:
 | 
					                if patient.type_id.id==st_prod.patient_type_id.id:
 | 
				
			||||||
                    prod=st_prod.product_id
 | 
					 | 
				
			||||||
                    price=st_prod.price
 | 
					                    price=st_prod.price
 | 
				
			||||||
                    qty=st_prod.qty
 | 
					                    qty=st_prod.qty
 | 
				
			||||||
                    amt=st_prod.amount
 | 
					                    amt=st_prod.amount
 | 
				
			||||||
 | 
					                    categ=st_prod.product_categ_id
 | 
				
			||||||
                    account_id=st_prod.ar_credit_id.id
 | 
					                    account_id=st_prod.ar_credit_id.id
 | 
				
			||||||
                    if not account_id:
 | 
					 | 
				
			||||||
                        account_id=prod.sale_account_id.id
 | 
					 | 
				
			||||||
                        if not account_id:
 | 
					 | 
				
			||||||
                            raise Exception("Please define sale account for product [%s] %s"%(prod.code, prod.name))
 | 
					 | 
				
			||||||
                    if not amt:
 | 
					                    if not amt:
 | 
				
			||||||
                        amt=qty*price
 | 
					                        amt=qty*price
 | 
				
			||||||
                    categ=st_prod.product_categ_id
 | 
					                    line_vals={
 | 
				
			||||||
                    vals['lines'].append(('create',{
 | 
					 | 
				
			||||||
                        'product_id': prod.id,
 | 
					 | 
				
			||||||
                        'uom_id': st_prod.uom_id.id,
 | 
					 | 
				
			||||||
                        'product_categ_id': categ.id,
 | 
					                        'product_categ_id': categ.id,
 | 
				
			||||||
 | 
					                        'uom_id': st_prod.uom_id.id,
 | 
				
			||||||
                        'description': st_prod.description,
 | 
					                        'description': st_prod.description,
 | 
				
			||||||
                        'price': price,
 | 
					                        'price': price,
 | 
				
			||||||
                        'qty': qty,
 | 
					                        'qty': qty,
 | 
				
			||||||
                        'reimbursable':  st_prod.reimbursable,
 | 
					                        'reimbursable':  st_prod.reimbursable,
 | 
				
			||||||
                        'amount': amt,
 | 
					                        'amount': amt,
 | 
				
			||||||
                        'account_id': account_id,
 | 
					                        'account_id': account_id,
 | 
				
			||||||
                    }))
 | 
					                    }
 | 
				
			||||||
 | 
					                    prod=st_prod.product_id
 | 
				
			||||||
 | 
					                    if prod:
 | 
				
			||||||
 | 
					                        line_vals.update({
 | 
				
			||||||
 | 
					                            'product_id': prod.id,
 | 
				
			||||||
 | 
					                        })
 | 
				
			||||||
 | 
					                        if not line_vals['account_id']:
 | 
				
			||||||
 | 
					                            line_vals['account_id']=prod.sale_account_id.id
 | 
				
			||||||
 | 
					                            if not line_vals['account_id']:
 | 
				
			||||||
 | 
					                                raise Exception("Please define sale account for product [%s] %s"%(prod.code, prod.name))
 | 
				
			||||||
 | 
					                    vals['lines'].append(('create',line_vals))
 | 
				
			||||||
        # XXX need to get default
 | 
					        # XXX need to get default
 | 
				
			||||||
        partner=patient.type_id.contact_id
 | 
					        partner=patient.type_id.contact_id
 | 
				
			||||||
        if partner:
 | 
					        if partner:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
from netforce.model import Model, fields
 | 
					from netforce.model import Model, fields, get_model
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Hdcaseline(Model):
 | 
					class Hdcaseline(Model):
 | 
				
			||||||
    _name="clinic.hd.case.line"
 | 
					    _name="clinic.hd.case.line"
 | 
				
			||||||
| 
						 | 
					@ -18,10 +18,18 @@ class Hdcaseline(Model):
 | 
				
			||||||
        "account_id": fields.Many2One("account.account","Account"),
 | 
					        "account_id": fields.Many2One("account.account","Account"),
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    def _get_categ(self,context={}):
 | 
				
			||||||
 | 
					        categ_ids=get_model("product.categ").search([['code','=','EPO']])
 | 
				
			||||||
 | 
					        if categ_ids:
 | 
				
			||||||
 | 
					            return categ_ids[0]
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            return None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _defaults={
 | 
					    _defaults={
 | 
				
			||||||
        'type': 'others',
 | 
					        'type': 'others',
 | 
				
			||||||
        'reimbursable': 'no',
 | 
					        'reimbursable': 'no',
 | 
				
			||||||
        'state': 'draft',
 | 
					        'state': 'draft',
 | 
				
			||||||
 | 
					        'product_categ_id': _get_categ,
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Hdcaseline.register()
 | 
					Hdcaseline.register()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue