clean
parent
e122227156
commit
7eff465fd1
|
@ -86,7 +86,8 @@
|
|||
<button string="Confirm" type="success" method="schd_confirm"/>
|
||||
</tab>
|
||||
<tab string="Testing">
|
||||
<button string="Run Script" type="default" method="run_script"/>
|
||||
<button string="Dummy" type="default" method="run_script"/>
|
||||
<button string="Reset Import" icon="repeat" type="default" method="reset_last_import"/>
|
||||
</tab>
|
||||
</tabs>
|
||||
<foot>
|
||||
|
|
|
@ -345,7 +345,6 @@ class HDCase(Model):
|
|||
currency_id=setting.currency_id.id
|
||||
if not currency_id:
|
||||
raise Exception("Currency not found in account settings")
|
||||
account_receivable_id=setting.account_receivable_id.id
|
||||
company_id=get_active_company()
|
||||
uom=get_model("uom").search_browse([['name','ilike','%Unit%']])
|
||||
if not uom:
|
||||
|
@ -359,44 +358,40 @@ class HDCase(Model):
|
|||
is_credit=context.get('is_credit') or False
|
||||
context['type']='out'
|
||||
context['inv_type']='invoice'
|
||||
lines1=[] #yes
|
||||
lines2=[] #no
|
||||
rmb_lines=[] #yes
|
||||
normb_lines=[] #no
|
||||
|
||||
for line in obj.lines:
|
||||
if line.state!='draft':
|
||||
continue
|
||||
prod=line.product_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 line.reimbursable=='yes':
|
||||
lines1.append(('create',{
|
||||
"product_id": line.product_id.id,
|
||||
rmb_lines.append(('create',{
|
||||
"product_id": prod.id,
|
||||
"description": line.description,
|
||||
'product_categ_code': line.product_categ_id.code,
|
||||
"qty": line.qty,
|
||||
"uom_id": line.uom_id.id,
|
||||
"unit_price": line.price,
|
||||
"amount": line.amount,
|
||||
#'account_id': account_id,
|
||||
'account_id': account_id,
|
||||
}))
|
||||
else:
|
||||
vals={
|
||||
"product_id": line.product_id.id,
|
||||
'product_categ_code': line.product_categ_id.code,
|
||||
normb_lines.append(('create',{
|
||||
"product_id": prod.id,
|
||||
"description": line.description,
|
||||
"qty": line.qty,
|
||||
"uom_id": line.uom_id.id,
|
||||
"unit_price": line.price,
|
||||
"amount": line.amount,
|
||||
}
|
||||
prod=line.product_id
|
||||
sale_account=prod.sale_account_id
|
||||
if not sale_account:
|
||||
raise Exception("Not found sale account in product (%s) %s"%(prod.code,prod.name))
|
||||
|
||||
vals['account_id']=sale_account.id
|
||||
lines2.append(('create',vals))
|
||||
'account_id': account_id,
|
||||
}))
|
||||
|
||||
patient=obj.patient_id
|
||||
|
||||
if lines1:
|
||||
if rmb_lines:
|
||||
ptype=patient.type_id
|
||||
partner=ptype.contact_id
|
||||
if not partner:
|
||||
|
@ -418,21 +413,10 @@ class HDCase(Model):
|
|||
"company_id": company_id,
|
||||
}
|
||||
vals["partner_id"]=partner.id
|
||||
for mode,line1 in lines1:
|
||||
categ_code=line1['product_categ_code']
|
||||
if categ_code=='EPO':
|
||||
line1['account_id']=account_mdc_id
|
||||
elif categ_code=='FEE':
|
||||
line1['account_id']=account_fee_id
|
||||
elif categ_code=='SRV':
|
||||
line1['account_id']=account_service_id
|
||||
else:
|
||||
line1['account_id']=account_receivable_id
|
||||
del line1['product_categ_code']
|
||||
vals['lines']=lines1
|
||||
vals['lines']=rmb_lines
|
||||
get_model("account.invoice").create(vals,context)
|
||||
|
||||
if lines2 and is_credit:
|
||||
if normb_lines and is_credit:
|
||||
partner=patient.partner_id
|
||||
if not partner:
|
||||
raise Exception("No contact for this patient %s"%obj.partner.name)
|
||||
|
@ -449,15 +433,9 @@ class HDCase(Model):
|
|||
"company_id": company_id,
|
||||
'partner_id':partner.id,
|
||||
}
|
||||
for mode,line2 in lines2:
|
||||
categ_code=line2['product_categ_code']
|
||||
if not line2.get("account_id"):
|
||||
line2['account_id']=account_receivable_id
|
||||
del line2['product_categ_code'] #XXX
|
||||
vals['lines']=lines2
|
||||
vals['lines']=normb_lines
|
||||
get_model("account.invoice").create(vals,context) # create alway
|
||||
|
||||
|
||||
obj.make_pickings()
|
||||
# prevent douplicate create invoice & picking
|
||||
for line in obj.lines:
|
||||
|
@ -926,7 +904,6 @@ class HDCase(Model):
|
|||
return vals
|
||||
|
||||
def get_invoice_policy(self,vals={},patient_id=None):
|
||||
print('vals ', vals)
|
||||
if patient_id:
|
||||
patient=get_model("clinic.patient").browse(patient_id)
|
||||
st=get_model("clinic.setting").browse(1)
|
||||
|
|
|
@ -52,7 +52,7 @@ class ReportPaymentMatching(Model):
|
|||
'date_to': _get_date_to,
|
||||
'state': 'match',
|
||||
'type_id': _get_type_id,
|
||||
'show_hcode': 0,
|
||||
'show_hcode': 1,
|
||||
}
|
||||
|
||||
def match_invoice(self,ids,context={}):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from netforce.model import Model, fields, get_model
|
||||
from netforce.utils import get_file_path, get_data_path
|
||||
from netforce.access import get_active_company
|
||||
from netforce.database import get_connection
|
||||
|
||||
class ClinicSetting(Model):
|
||||
_name="clinic.setting"
|
||||
|
@ -95,4 +96,25 @@ class ClinicSetting(Model):
|
|||
})
|
||||
print("Done")
|
||||
|
||||
def reset_last_import(self,ids,context={}):
|
||||
res=get_model("clinic.report.payment.matching").search_read([],['date'],order="date desc")
|
||||
if res:
|
||||
db=get_connection()
|
||||
res1=res[0]
|
||||
date1='%s 00:00:00'%res1['date']
|
||||
date2='%s 23:59:59'%res1['date']
|
||||
exp_ids=[x['id'] for x in db.query("select id from clinic_hd_case_expense where write_time>=%s and write_time<=%s",date1,date2)]
|
||||
for exp in get_model("clinic.hd.case.expense").browse(exp_ids):
|
||||
exp.write({
|
||||
'state': 'waiting_matching',
|
||||
'ok': False,
|
||||
})
|
||||
for inv in exp.invoices:
|
||||
payment=inv.payment_id
|
||||
if payment:
|
||||
if payment.state !='draft':
|
||||
payment.to_draft()
|
||||
print("to draft payment ", payment.id)
|
||||
print("Done")
|
||||
|
||||
ClinicSetting.register()
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
=====
|
||||
- get account id by product
|
||||
|
||||
=====
|
||||
create button reset at setting
|
||||
- backup master data
|
||||
- patient
|
||||
|
|
Loading…
Reference in New Issue