diff --git a/netforce_clinic/layouts/clinic_hd_case_form.xml b/netforce_clinic/layouts/clinic_hd_case_form.xml index e38c8a4..c67ba1c 100644 --- a/netforce_clinic/layouts/clinic_hd_case_form.xml +++ b/netforce_clinic/layouts/clinic_hd_case_form.xml @@ -2,7 +2,7 @@ diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py index 342b8d4..71a28cf 100644 --- a/netforce_clinic/models/__init__.py +++ b/netforce_clinic/models/__init__.py @@ -7,6 +7,7 @@ from . import graduation from . import morbidity from . import nation from . import nurse +from . import address from . import patient from . import patient_cause_line from . import patient_comorbidity_line diff --git a/netforce_clinic/models/address.py b/netforce_clinic/models/address.py new file mode 100644 index 0000000..304a456 --- /dev/null +++ b/netforce_clinic/models/address.py @@ -0,0 +1,10 @@ +from netforce.model import Model, fields + +class Address(Model): + _inherit="address" + + _fields={ + "patient_id": fields.Many2One("clinic.patient","Patient"), + } + +Address.register() diff --git a/netforce_clinic/models/dialyzer.py b/netforce_clinic/models/dialyzer.py index 9e405a1..7795d5f 100644 --- a/netforce_clinic/models/dialyzer.py +++ b/netforce_clinic/models/dialyzer.py @@ -66,12 +66,13 @@ class Dialyzer(Model): _defaults={ "state": "new", "date": lambda *a: time.strftime("%Y-%m-%d"), - #"number": _get_number, 'number': '/', "max_use_time": 10, "use_time": 0, "company_id": lambda *a: get_active_company(), 'product_id': _get_product, + 'dialyzer_type': 'low', + 'member_type': 'unsub', } _order="date desc,number desc" diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index cbddf46..48b8ea6 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -620,5 +620,37 @@ class HDCase(Model): data['amount_total']=payment.amount_total or 0.0 return data + + def new_dialyzer(self,ids,context={}): + obj=self.browse(ids)[0] + dlz_id=get_model('clinic.dialyzer').create({ + 'patient_id': obj.patient_id.id, + }) + dialyzer=get_model("clinic.dialyzer").browse(dlz_id) + dialyzer.confirm() + vals={ + 'dlz_id': dlz_id, + 'dialyzers': [], + } + vals['dialyzers'].append(('create',{ + 'dialyzer_id': dlz_id, + 'description': dialyzer.description or "", + 'use_time': 1, + 'max_use_time': dialyzer.max_use_time, + 'member_type': dialyzer.member_type, + 'dialyzer_type': dialyzer.dialyzer_type, + 'bid_flow_rate': dialyzer.bid_flow_rate, + 'ultrafittration': dialyzer.ultrafittration, + 'state': dialyzer.state, + })) + obj.write(vals) + return { + 'next': { + 'name': 'clinic_hd_case', + 'mode': 'form', + 'active_id': obj.id, + }, + 'flash': 'Create new dialyzer successfully', + } HDCase.register() diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py index 1b5f1dd..fb7c1d4 100644 --- a/netforce_clinic/models/patient.py +++ b/netforce_clinic/models/patient.py @@ -48,7 +48,7 @@ class Patient(Model): 'card_exp' : fields.Date("Card Expiry"), "app_no": fields.Char("Application No."), "salary": fields.Selection([["20000","5,001-20,000"],["50000","20,001-50,000"],["100000","50,001-100,000"],["100001","100,000+"]], "Salary"), - "addresses": fields.One2Many("address","related_id","Addresses"), + "addresses": fields.One2Many("address","patient_id","Addresses"), "gender": fields.Selection([("male","Male"),("female","Female")],"Gender",required=False), "marital_status": fields.Selection([("single","Single"),("marry","Marry"),("divorce","Divorce"),("separated","Saparated"),("widowed","Widowed")],"Marital Status",required=False), "nation_id": fields.Many2One("clinic.nation","Nationality"), @@ -203,6 +203,26 @@ class Patient(Model): 'type': 'person', }) vals['partner_id']=partner_id + + # XXX + if not isinstance(partner_id,int): + partner_id=partner_id.id + if obj.addresses: + addr=obj.addresses[0] + get_model("address").browse(addr.id).write({ + 'partner_id': partner_id, + }) + else: + if vals.get("addresses"): + # in case no address in patient + addr_vals=vals.get("addresses")[0][1] + addr_id=get_model("address").create(addr_vals) + get_model("address").browse(addr_id).write({ + 'patient_id': obj.id, + 'partner_id': partner_id, + }) + del vals['addresses'] + print("create address for %s"%obj.name) super().write(ids,vals,**kw) def name_get(self,ids,context={}): diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt index 881e19b..7bd8216 100644 --- a/netforce_clinic/todo.txt +++ b/netforce_clinic/todo.txt @@ -1,4 +1,6 @@ ==== + question: + - can filter field in related find dialyzer automatic after confirm visit ==== - import data