diff --git a/netforce_clinic/actions/clinic_schedule.xml b/netforce_clinic/actions/clinic_schedule.xml
new file mode 100644
index 0000000..cea37f8
--- /dev/null
+++ b/netforce_clinic/actions/clinic_schedule.xml
@@ -0,0 +1,6 @@
+
+ Schedule
+ multi_view
+ clinic.schedule
+ clinic_menu
+
diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml
index d85373a..58de40f 100644
--- a/netforce_clinic/layouts/clinic_menu.xml
+++ b/netforce_clinic/layouts/clinic_menu.xml
@@ -7,6 +7,7 @@
-
+
diff --git a/netforce_clinic/layouts/clinic_patient_form.xml b/netforce_clinic/layouts/clinic_patient_form.xml
index f043fe4..af25ed4 100644
--- a/netforce_clinic/layouts/clinic_patient_form.xml
+++ b/netforce_clinic/layouts/clinic_patient_form.xml
@@ -11,14 +11,12 @@
-
-
-
-
+
+
@@ -29,6 +27,8 @@
+
+
@@ -82,6 +82,9 @@
+
+
+
diff --git a/netforce_clinic/layouts/clinic_schedule_form.xml b/netforce_clinic/layouts/clinic_schedule_form.xml
new file mode 100644
index 0000000..42c87c2
--- /dev/null
+++ b/netforce_clinic/layouts/clinic_schedule_form.xml
@@ -0,0 +1,4 @@
+
diff --git a/netforce_clinic/layouts/clinic_schedule_list.xml b/netforce_clinic/layouts/clinic_schedule_list.xml
new file mode 100644
index 0000000..101cf88
--- /dev/null
+++ b/netforce_clinic/layouts/clinic_schedule_list.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/netforce_clinic/layouts/clinic_setting.xml b/netforce_clinic/layouts/clinic_setting.xml
index 9c9ba1f..3e67092 100644
--- a/netforce_clinic/layouts/clinic_setting.xml
+++ b/netforce_clinic/layouts/clinic_setting.xml
@@ -1,14 +1,21 @@
diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py
index 7f4efd7..d74d01e 100644
--- a/netforce_clinic/models/__init__.py
+++ b/netforce_clinic/models/__init__.py
@@ -6,7 +6,9 @@ from . import graduation
from . import nation
from . import race
from . import cause_chronic
+from . import schedule
from . import patient
+from . import patient_schedule
from . import patient_cause_line
from . import patient_comorbidity_line
from . import patient_morbidity_line
diff --git a/netforce_clinic/models/import_payment.py b/netforce_clinic/models/import_payment.py
index 24ede0d..a84e474 100644
--- a/netforce_clinic/models/import_payment.py
+++ b/netforce_clinic/models/import_payment.py
@@ -36,6 +36,7 @@ class ImportPayment(Model):
'nhso_move_id': fields.Many2One("account.move","Journal Entry"),
"state": fields.Selection([("draft","Draft"),("success","Succes"),("fail","Fail"),('close','Close')],"Status"),
'note': fields.Text("Note"),
+ 'partner_id': fields.Many2One("partner","Contact"),
}
_order="date_import desc"
@@ -157,6 +158,7 @@ class ImportPayment(Model):
dom.append(['partner_id','=',partner_id])
invoice_lines=[]
for invoice in get_model("account.invoice").search_browse(dom):
+ print(invoice)
line={
'invoice_id': invoice.id,
'amount': invoice.amount_total,
@@ -190,12 +192,18 @@ class ImportPayment(Model):
"account_id": account_id,
'lines': [], # TODO find invoice matching
}
+ #db=get_connection()
if obj.type=='sc':
if not obj.sc_payment_id:
payment_id=get_model("account.payment").create(vals,context={'type': 'in'})
obj.write({
'sc_payment_id': payment_id,
})
+ ## XX
+ #sql="update clinic_import_payment set sc_payment_id=%s where id = %s" % (payment_id,obj.id)
+ #import pdb; pdb.set_trace()
+ #db.query(sql)
+ #db.commit()
invoice_lines=obj.find_invoice()
print("="*30)
for line in invoice_lines:
@@ -204,9 +212,10 @@ class ImportPayment(Model):
# TODO update payment
# remove invoice, udpate invoice
if invoice_lines:
- # clear old invoice lines
- for line in obj.sc_payment_id.invoice_lines:
- line.delete()
+ if obj.sc_payment_id.invoice_lines:
+ # clear old invoice lines
+ for line in obj.sc_payment_id.invoice_lines:
+ line.delete()
# update new
obj.sc_payment_id.write({
'invoice_lines': invoice_lines,
@@ -224,8 +233,9 @@ class ImportPayment(Model):
print("="*30)
if invoice_lines:
# clear old invoice lines
- for line in obj.mg_payment_id.invoice_lines:
- line.delete()
+ if obj.mg_payment_id.invoice_lines:
+ for line in obj.mg_payment_id.invoice_lines:
+ line.delete()
# update new
obj.mg_payment_id.write({
'invoice_lines': invoice_lines,
@@ -239,9 +249,10 @@ class ImportPayment(Model):
invoice_lines=obj.find_invoice()
if invoice_lines:
# clear old invoice lines
- for line in obj.nhso_payment_id.invoice_lines:
- line.delete()
- # update new
+ if obj.nhso_payment_id.invoice_lines:
+ for line in obj.nhso_payment_id.invoice_lines:
+ line.delete()
+ # update new
obj.nhso_payment_id.write({
'invoice_lines': invoice_lines,
})
@@ -403,5 +414,10 @@ class ImportPayment(Model):
def to_draft(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({'state': 'draft'})
+
+ def onchange_type(self,context={}):
+ data=context['data']
+ # find partner and set to partner_id
+ return data
ImportPayment.register()
diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py
index 76aba07..038937d 100644
--- a/netforce_clinic/models/patient.py
+++ b/netforce_clinic/models/patient.py
@@ -76,6 +76,7 @@ class Patient(Model):
"hd_cases": fields.One2Many("clinic.hd.case","patient_id","HD Cases"),
"partner_id": fields.Many2One("partner","Contact"),
"dialyzers": fields.One2Many("clinic.dialyzer","patient_id","Dialyzers"),
+ 'schedules': fields.Many2Many("clinic.schedule","Schedule"),
}
def _get_number(self,context={}):
diff --git a/netforce_clinic/models/patient_schedule.py b/netforce_clinic/models/patient_schedule.py
new file mode 100644
index 0000000..aa80530
--- /dev/null
+++ b/netforce_clinic/models/patient_schedule.py
@@ -0,0 +1,15 @@
+import time
+
+from netforce.model import Model, fields
+
+class PatientSchedule(Model):
+ _name="clinic.patient.schedule"
+ _string="Patient Schedule"
+ _fields={
+ "patient_id": fields.Many2One("clinic.patient","Patient",required=True,on_delete="cascade"),
+ }
+
+ _defaults={
+ }
+
+PatientSchedule.register()
diff --git a/netforce_clinic/models/schedule.py b/netforce_clinic/models/schedule.py
new file mode 100644
index 0000000..8f1e3ba
--- /dev/null
+++ b/netforce_clinic/models/schedule.py
@@ -0,0 +1,13 @@
+from netforce.model import Model, fields
+
+class Schedule(Model):
+ _name="clinic.schedule"
+ _string="Schedule"
+ _fields={
+ 'name': fields.Char("Name"),
+ 'code': fields.Char("Code"),
+ 'patients': fields.Many2Many("clinic.patient","Patients"),
+ }
+
+
+Schedule.register()
diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt
index 7012eda..5507997 100644
--- a/netforce_clinic/todo.txt
+++ b/netforce_clinic/todo.txt
@@ -1,5 +1,8 @@
-
===== todo
+ monday:
+ - A, B, C, D
+ tueday:
+ ========
Account Receivable -> invoice
find account id
1. partner
@@ -7,7 +10,8 @@
3. settings
Account Payable -> payment
- !!! import
+ !!! import data
+ - remove payment
set account payable
issue: