improve
parent
400c56e2cf
commit
c230331660
|
@ -1,6 +1,6 @@
|
|||
<record model="action">
|
||||
<field name="name">clinic_setting</field>
|
||||
<field name="view">form_view</field>
|
||||
<field name="view_cls">form_view</field>
|
||||
<field name="model">clinic.setting</field>
|
||||
<field name="active_id">1</field>
|
||||
<field name="view_xml">clinic_setting</field>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from . import clinic_setting
|
||||
from . import remove_conv_bal
|
||||
from . import import_acc
|
||||
#from . import remove_conv_bal
|
||||
#from . import update_labor_cost_line
|
||||
|
|
|
@ -1,38 +1,40 @@
|
|||
from netforce.model import get_model
|
||||
from netforce import migration
|
||||
from netforce.access import set_active_user, get_active_user
|
||||
from netforce.access import set_active_user, get_active_user, set_active_company
|
||||
|
||||
class Migration(migration.Migration):
|
||||
_name="import.acc"
|
||||
_version="2.11.0"
|
||||
|
||||
def migrate(self):
|
||||
set_active_company(1)
|
||||
cbv_id=24
|
||||
cbv=get_model("conv.bal").browse(cbv_id)
|
||||
cbv.write({
|
||||
'file': 'tb.csv',
|
||||
})
|
||||
print("import acc file (step 1) running ...")
|
||||
get_model("conv.bal").import_acc([cbv.id],context={})
|
||||
#cbv.write({
|
||||
#'file': 'tb.csv',
|
||||
#})
|
||||
#print("import acc file (step 1) running ...")
|
||||
#get_model("conv.bal").import_acc([cbv.id],context={})
|
||||
|
||||
cbv.write({
|
||||
'file': 'ar.csv',
|
||||
})
|
||||
print("import sale file (step 2)running ...")
|
||||
get_model("conv.bal").import_sale_file([cbv.id],context={})
|
||||
#cbv.write({
|
||||
#'file': 'ar.csv',
|
||||
#})
|
||||
#print("import sale file (step 2)running ...")
|
||||
#get_model("conv.bal").import_sale_file([cbv.id],context={})
|
||||
|
||||
print("import purch file (step 3) running ...")
|
||||
cbv.write({
|
||||
'file': 'ap.csv',
|
||||
})
|
||||
get_model("conv.bal").import_purch([cbv.id],context={})
|
||||
print("create invoice from setep 1 to 3 is running...")
|
||||
print("create_open_entry...")
|
||||
cbv.create_open_entry()
|
||||
print("create_sale_invoices...")
|
||||
cbv.create_sale_invoices()
|
||||
print("create_purch_invoices...")
|
||||
cbv.create_purch_invoices()
|
||||
#print("import purch file (step 3) running ...")
|
||||
#cbv.write({
|
||||
#'file': 'ap.csv',
|
||||
#})
|
||||
#get_model("conv.bal").import_purch([cbv.id],context={})
|
||||
#print("create invoice from setep 1 to 3 is running...")
|
||||
#print("create_open_entry...")
|
||||
#print('Done!')
|
||||
#cbv.create_open_entry()
|
||||
#print("create_sale_invoices...")
|
||||
#cbv.create_sale_invoices()
|
||||
#print("create_purch_invoices...")
|
||||
#cbv.create_purch_invoices()
|
||||
print("Done!")
|
||||
return True
|
||||
|
||||
|
|
|
@ -15,6 +15,19 @@ class Migration(migration.Migration):
|
|||
select id, amount_due, state,date from account_invoice where extract(year from date)=2014;
|
||||
""")
|
||||
inv_ids=[r['id'] for r in res]
|
||||
|
||||
res=db.query("""
|
||||
select id, amount_due, state,date from account_invoice where extract(year from date)=2013;
|
||||
""")
|
||||
for r in res:
|
||||
inv_ids.append(r['id'])
|
||||
|
||||
res=db.query("""
|
||||
select id, amount_due, state,date from account_invoice where extract(year from date)=2012;
|
||||
""")
|
||||
for r in res:
|
||||
inv_ids.append(r['id'])
|
||||
|
||||
for inv in get_model("account.invoice").browse(inv_ids):
|
||||
inv.to_draft()
|
||||
print('%s is deleted'%(inv.number))
|
||||
|
|
|
@ -36,11 +36,15 @@ class AccountInvoice(Model):
|
|||
elif obj.type=="in":
|
||||
desc="Purchase; "+partner.name
|
||||
if obj.type=="out":
|
||||
journal_id=obj.journal_id.id or settings.sale_journal_id.id
|
||||
journal_id=settings.sale_journal_id.id
|
||||
if obj.journal_id:
|
||||
journal_id=obj.journal_id.id
|
||||
if not journal_id:
|
||||
raise Exception("Sales journal not found")
|
||||
elif obj.type=="in":
|
||||
journal_id=obj.journal_id.id or settings.purchase_journal_id.id
|
||||
journal_id=settings.purchase_journal_id.id
|
||||
if obj.journal_id:
|
||||
journal_id=obj.journal_id.id
|
||||
if not journal_id:
|
||||
raise Exception("Purchases journal not found")
|
||||
if obj.type=="out":
|
||||
|
|
|
@ -655,7 +655,6 @@ class HDCase(Model):
|
|||
def post_invoices(self,ids,context={}):
|
||||
obj=self.browse(ids[0])
|
||||
for inv in obj.invoices:
|
||||
#XXX
|
||||
if inv.amount_total<1:
|
||||
continue
|
||||
inv.post()
|
||||
|
@ -916,12 +915,16 @@ class HDCase(Model):
|
|||
def done(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
obj.update_usetime()
|
||||
obj.write({
|
||||
'state': 'completed',
|
||||
})
|
||||
#FIXME allow user to write sickbed status
|
||||
user_id=get_active_user()
|
||||
set_active_user(1)
|
||||
nurse_id=None
|
||||
for st in get_model("clinic.staff").search_browse([['user_id','=',user_id]]):
|
||||
nurse_id=st.id
|
||||
obj.write({
|
||||
'state': 'completed',
|
||||
'nurse_id': nurse_id,
|
||||
})
|
||||
obj.sickbed_id.write({
|
||||
'state': 'available',
|
||||
})
|
||||
|
|
|
@ -110,6 +110,59 @@ class ClinicSetting(Model):
|
|||
if user_id !=1:
|
||||
print("Only admin!!")
|
||||
return
|
||||
cbv_id=24
|
||||
cbv=get_model("conv.bal").browse(cbv_id)
|
||||
cbv.write({
|
||||
'file': 'ap.csv',
|
||||
})
|
||||
fname=get_file_path(cbv.file)
|
||||
f=open(fname,"r")
|
||||
rows=f.read().split("\n")
|
||||
db=get_connection()
|
||||
print("Done!")
|
||||
|
||||
def update_staff_contact(self,ids,context={}):
|
||||
user_id=get_active_user()
|
||||
if user_id !=1:
|
||||
print("Only admin!!")
|
||||
return
|
||||
pids=[]
|
||||
for st in get_model("clinic.staff").search_browse([]):
|
||||
code=st.number
|
||||
partner=st.partner_id
|
||||
if partner:
|
||||
partner.write({
|
||||
'code': code,
|
||||
'is_staff': True,
|
||||
})
|
||||
pids.append(partner.id)
|
||||
for pt in get_model("clinic.patient").search_browse([]):
|
||||
code=pt.hn_no or ""
|
||||
partner=pt.partner_id
|
||||
if partner:
|
||||
partner.write({
|
||||
'code': code,
|
||||
'is_patient': True,
|
||||
})
|
||||
pids.append(partner.id)
|
||||
|
||||
for ptype in get_model('clinic.patient.type').search_browse([]):
|
||||
partner=ptype.contact_id
|
||||
if partner:
|
||||
pids.append(partner.id)
|
||||
|
||||
#pids='(%s)'%(','.join([str(x) for x in pids]))
|
||||
db=get_connection()
|
||||
if pids:
|
||||
res=db.query("select id, name from partner where id not in %s", tuple(pids))
|
||||
pids=[r['id'] for r in res]
|
||||
for pt in get_model("partner").browse(pids):
|
||||
pt.write({
|
||||
'active': False,
|
||||
})
|
||||
#for partner in get_model("partner").search_browse([]):
|
||||
#pass
|
||||
|
||||
print("Done!")
|
||||
|
||||
def update_name(self,ids,context={}):
|
||||
|
|
|
@ -188,8 +188,9 @@ class Staff(Model):
|
|||
_sql_constraints=("clinic_staff_key_uniq","unique(name_check,branch_id)","name should be unique"),
|
||||
_order="date desc,number desc"
|
||||
|
||||
def create_contact(self,name):
|
||||
def create_contact(self,code,name):
|
||||
partner_id=get_model("partner").create({
|
||||
'code': code,
|
||||
'name': name,
|
||||
'last_name': name,
|
||||
'type': 'person',
|
||||
|
@ -242,17 +243,26 @@ class Staff(Model):
|
|||
return emp_id
|
||||
|
||||
def create(self,vals,**kw):
|
||||
name=vals['name']
|
||||
title_id=vals['title_id']
|
||||
title=get_model("clinic.name.title").browse(title_id)
|
||||
title_name=title.name or ""
|
||||
vals['name']=''
|
||||
if title_name.lower()=='notitle':
|
||||
vals['name']='%s%s %s'%(title_name,vals['first_name'],vals['last_name'])
|
||||
else:
|
||||
vals['name']='%s %s'%(vals['first_name'],vals['last_name'])
|
||||
employee_id=vals.get('employee_id')
|
||||
name=vals['name']
|
||||
emp_id=self.check_emp(name,employee_id)
|
||||
if emp_id:
|
||||
vals['employee_id']=emp_id
|
||||
partner_id=get_model("clinic.staff").check_contact(name)
|
||||
address_id=None
|
||||
if not partner_id:
|
||||
vals['partner_id'],address_id=self.create_contact(name)
|
||||
vals['partner_id'],address_id=self.create_contact(vals['number'],name)
|
||||
new_id=super().create(vals,**kw)
|
||||
self.function_store([new_id])
|
||||
for obj in self.browse([new_id]):
|
||||
if address_id:
|
||||
addr=get_model('address').browse(address_id)
|
||||
addr.write({
|
||||
|
|
Loading…
Reference in New Issue