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,11 +401,14 @@ class HDCase(Model):
|
|||
#account_id=sline.account_id.id
|
||||
account_id=sline.ar_credit_id.id
|
||||
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:
|
||||
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 account_id:
|
||||
raise Exception("Please define sale account for product [%s] %s"%(prod.code, prod.name))
|
||||
if line.reimbursable=='yes':
|
||||
rmb_lines.append(('create',{
|
||||
"product_id": prod.id,
|
||||
|
@ -980,29 +983,33 @@ class HDCase(Model):
|
|||
vals['lines']=[]
|
||||
for st_prod in st.products:
|
||||
if patient.type_id.id==st_prod.patient_type_id.id:
|
||||
prod=st_prod.product_id
|
||||
price=st_prod.price
|
||||
qty=st_prod.qty
|
||||
amt=st_prod.amount
|
||||
categ=st_prod.product_categ_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:
|
||||
amt=qty*price
|
||||
categ=st_prod.product_categ_id
|
||||
vals['lines'].append(('create',{
|
||||
'product_id': prod.id,
|
||||
'uom_id': st_prod.uom_id.id,
|
||||
line_vals={
|
||||
'product_categ_id': categ.id,
|
||||
'uom_id': st_prod.uom_id.id,
|
||||
'description': st_prod.description,
|
||||
'price': price,
|
||||
'qty': qty,
|
||||
'reimbursable': st_prod.reimbursable,
|
||||
'amount': amt,
|
||||
'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
|
||||
partner=patient.type_id.contact_id
|
||||
if partner:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from netforce.model import Model, fields
|
||||
from netforce.model import Model, fields, get_model
|
||||
|
||||
class Hdcaseline(Model):
|
||||
_name="clinic.hd.case.line"
|
||||
|
@ -18,10 +18,18 @@ class Hdcaseline(Model):
|
|||
"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={
|
||||
'type': 'others',
|
||||
'reimbursable': 'no',
|
||||
'state': 'draft',
|
||||
'product_categ_id': _get_categ,
|
||||
}
|
||||
|
||||
Hdcaseline.register()
|
||||
|
|
Loading…
Reference in New Issue