update track to invoice & payment from hdcase & shop

conv_bal
watcha.h@almacom.co.th 2015-08-04 18:05:31 +07:00
parent cbe4923252
commit b6eaefa8af
7 changed files with 55 additions and 9 deletions

View File

@ -9,6 +9,7 @@
<field name="parent_id"/>
<field name="company_id"/>
<field name="active"/>
<field name="track_id"/>
<separator string="Address"/>
<field name="addresses" view="form_list"/>
<related>

View File

@ -1,5 +1,6 @@
from . import clinic_setting
from . import print_labor_cost
from . import update_account_tracking
#from . import print_labor_cost
#from . import hdcase
#from . import remove_conv_bal
#from . import import_acc

View File

@ -0,0 +1,38 @@
from netforce.model import get_model
from netforce import migration
from netforce.access import set_active_user, set_active_company
class Migration(migration.Migration):
_name="clinic.update.account.tracking"
_version="2.10.0"
def migrate(self):
set_active_user(1)
set_active_company(1)
for hdcase in get_model('clinic.hd.case').search_browse([]):
track_id=hdcase.branch_id.track_id.id
for payment in hdcase.payments:
for line in payment.lines:
line.write({
'track_id': track_id,
})
for invoice in hdcase.invoices:
for line in invoice.lines:
line.write({
'track_id': track_id,
})
for shop in get_model('clinic.shop').search_browse([]):
track_id=shop.branch_id.track_id.id
for payment in hdcase.payments:
for line in payment.lines:
line.write({
'track_id': track_id,
})
for invoice in hdcase.invoices:
for line in invoice.lines:
line.write({
'track_id': track_id,
})
Migration.register()

View File

@ -13,6 +13,7 @@ class Branch(Model):
'departments': fields.One2Many("clinic.department","branch_id","Departments"),
'active': fields.Boolean("Active"),
"addresses": fields.One2Many("address","related_id","Addresses"),
"track_id": fields.Many2One("account.track.categ","Track-1",domain=[["type","=","1"]]),
}
_defaults={

View File

@ -528,6 +528,7 @@ class HDCase(Model):
raise Exception("No Patient Type -> Clinic Settings-> RD Shop -> Patient Type")
ptype=shop_type
prod_acc=st.get_product_account
track_id=obj.branch_id.track_id.id
for line in obj.lines:
if line.reimbursable=='no':
if line.amount < 1:
@ -549,6 +550,7 @@ class HDCase(Model):
"unit_price": line.price or 0,
"amount": line.amount or 0,
'account_id': account_id,
'track_id': track_id,
}))
context={
'type': 'in',
@ -608,7 +610,7 @@ class HDCase(Model):
normb_lines=[] #no
cst=get_model('clinic.setting').browse(1)
prod_acc=cst.get_product_account
track_id=obj.branch_id.track_id.id
for line in obj.lines:
if line.state!='draft':
continue
@ -647,6 +649,7 @@ class HDCase(Model):
"amount": line.amount or 0,
'account_id': account_id,
'ar_debit_id': ar_debit_id,
'track_id': track_id,
}))
else:
normb_lines.append(('create',{
@ -658,6 +661,7 @@ class HDCase(Model):
"amount": line.amount or 0,
'account_id': account_id,
'ar_debit_id': ar_debit_id,
'track_id': track_id,
}))
patient=obj.patient_id

View File

@ -164,13 +164,10 @@ class ClinicSetting(Model):
if user_id !=1:
print("Only admin!!")
return
sql=''
for hdcase in get_model("clinic.hd.case").search_browse([]):
for invoice in hdcase.invoices:
print(hdcase.date,' ---> ', invoice.due_date)
sql+="update account_invoice set due_date='%s' where id=%s;"%(hdcase.date,invoice.id)
db=get_connection()
db.execute(sql)
#for payment in get_model("account.payment").search_browse([]):
#related=payment.related_id
#if related:
def merge_staff(self,ids,context={}):
user_id=get_active_user()

View File

@ -335,6 +335,7 @@ class Shop(Model):
'partner_id': partner.id,
"lines": [],
}
track_id=obj.branch_id.track_id.id
for line in obj.lines:
if line.amount < 1:
continue
@ -355,6 +356,7 @@ class Shop(Model):
"amount": line.amount or 0,
'account_id': account_id,
'ar_debit_id': ar_debit_id,
'track_id': track_id,
}))
inv_id=get_model("account.invoice").create(vals,context=context)
inv=get_model("account.invoice").browse(inv_id)
@ -471,6 +473,7 @@ class Shop(Model):
'direct_lines': [],
}
prod_acc=cst.get_product_account
track_id=obj.branch_id.track_id.id
for line in obj.lines:
prod=line.product_id
acc=prod_acc(prod.id,shop_type.id,'cash')
@ -487,6 +490,7 @@ class Shop(Model):
"unit_price": line.price or 0,
"amount": line.amount or 0,
'account_id': account_id,
'track_id': track_id,
}))
context={