diff --git a/netforce_clinic/layouts/clinic_branch_form.xml b/netforce_clinic/layouts/clinic_branch_form.xml
index 13f8088..0fc5ec2 100644
--- a/netforce_clinic/layouts/clinic_branch_form.xml
+++ b/netforce_clinic/layouts/clinic_branch_form.xml
@@ -9,6 +9,7 @@
+
diff --git a/netforce_clinic/migrations/__init__.py b/netforce_clinic/migrations/__init__.py
index 5406aaa..204e2c6 100644
--- a/netforce_clinic/migrations/__init__.py
+++ b/netforce_clinic/migrations/__init__.py
@@ -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
diff --git a/netforce_clinic/migrations/update_account_tracking.py b/netforce_clinic/migrations/update_account_tracking.py
new file mode 100644
index 0000000..feaeb38
--- /dev/null
+++ b/netforce_clinic/migrations/update_account_tracking.py
@@ -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()
diff --git a/netforce_clinic/models/branch.py b/netforce_clinic/models/branch.py
index c393c45..1035d81 100644
--- a/netforce_clinic/models/branch.py
+++ b/netforce_clinic/models/branch.py
@@ -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={
diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py
index ef785fe..82f00a1 100644
--- a/netforce_clinic/models/hd_case.py
+++ b/netforce_clinic/models/hd_case.py
@@ -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
diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py
index d051964..10ee472 100644
--- a/netforce_clinic/models/setting.py
+++ b/netforce_clinic/models/setting.py
@@ -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()
diff --git a/netforce_clinic/models/shop.py b/netforce_clinic/models/shop.py
index dec7369..028d799 100644
--- a/netforce_clinic/models/shop.py
+++ b/netforce_clinic/models/shop.py
@@ -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={