invoices with state waitting payment
parent
ab985439eb
commit
200f9e4476
|
@ -23,9 +23,9 @@
|
||||||
</group>
|
</group>
|
||||||
<foot>
|
<foot>
|
||||||
<button string="Confirm" type="success" states="new" method="confirm"/>
|
<button string="Confirm" type="success" states="new" method="confirm"/>
|
||||||
<button string="Drop" type="warning" states="active" method="drop"/>
|
<button string="Drop" type="danger" states="active" method="drop"/>
|
||||||
<button string="Cancel" type="danger" states="active" method="cancel"/>
|
<button string="Cancel" type="default" states="active" method="cancel"/>
|
||||||
<button string="Renew" type="success" states="cancelled" method="renew"/>
|
<button string="Renew" type="primary" states="cancelled" method="renew"/>
|
||||||
</foot>
|
</foot>
|
||||||
<related>
|
<related>
|
||||||
<field name="pickings" click_action="view_picking"/>
|
<field name="pickings" click_action="view_picking"/>
|
||||||
|
|
|
@ -19,7 +19,20 @@
|
||||||
<field name="nurse_id"/>
|
<field name="nurse_id"/>
|
||||||
</group>
|
</group>
|
||||||
<tabs>
|
<tabs>
|
||||||
<tab string="Treatment Information">
|
<tab string="Dialyzer">
|
||||||
|
<field name="dialyzers" nolabel="1">
|
||||||
|
<list>
|
||||||
|
<field name="dialyzer_id"/>
|
||||||
|
<field name="use_time"/>
|
||||||
|
<field name="max_use_time"/>
|
||||||
|
<field name="member_type"/>
|
||||||
|
<field name="dialyzer_type"/>
|
||||||
|
<field name="bid_flow_rate"/>
|
||||||
|
<field name="ultrafittration"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
</tab>
|
||||||
|
<tab string="Healthy Information">
|
||||||
<field name="wh_start"/>
|
<field name="wh_start"/>
|
||||||
<field name="wh_stop"/>
|
<field name="wh_stop"/>
|
||||||
<field name="bp_start"/>
|
<field name="bp_start"/>
|
||||||
|
@ -29,33 +42,21 @@
|
||||||
<field name="hct"/>
|
<field name="hct"/>
|
||||||
</tab>
|
</tab>
|
||||||
</tabs>
|
</tabs>
|
||||||
<field name="dialyzers" count="1" nolabel="1">
|
<separator string="Others Payment"/>
|
||||||
<list>
|
|
||||||
<field name="dialyzer_id" onchange="onchange_dialyzer"/>
|
|
||||||
<field name="description"/>
|
|
||||||
<field name="member_type"/>
|
|
||||||
<field name="dialyzer_type"/>
|
|
||||||
<field name="bid_flow_rate"/>
|
|
||||||
<field name="ultrafittration"/>
|
|
||||||
<field name="use_time"/>
|
|
||||||
<field name="max_use_time"/>
|
|
||||||
<field name="state"/>
|
|
||||||
</list>
|
|
||||||
</field>
|
|
||||||
<field name="lines" count="4" nolabel="1">
|
<field name="lines" count="4" nolabel="1">
|
||||||
<list>
|
<list>
|
||||||
<field name="product_id" onchange="onchange_product"/>
|
<field name="product_id" onchange="onchange_product"/>
|
||||||
<field name="detail"/>
|
<field name="description"/>
|
||||||
<field name="qty" onchange="onchange_product"/>
|
<field name="qty" onchange="onchange_line"/>
|
||||||
<field name="uom_id"/>
|
<field name="uom_id"/>
|
||||||
<field name="price" onchange="onchange_product"/>
|
<field name="price" onchange="onchange_line"/>
|
||||||
<field name="total"/>
|
<field name="amount"/>
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
<group span="4" columns="1">
|
<group span="4" columns="1">
|
||||||
<field name="fee"/>
|
<field name="fee"/>
|
||||||
<!--<field name="fee_type" onchange="onchange_fee_type"/>-->
|
<!--<field name="fee_type" onchange="onchange_fee_type"/>-->
|
||||||
<field name="fee_partner_id" attrs='{"required":[["fee","!=",0]]}'/>
|
<field name="fee_partner_id" domain="[['type','=','org']]" attrs='{"required":[["fee","!=",0]]}'/>
|
||||||
</group>
|
</group>
|
||||||
<group span="4" columns="1">
|
<group span="4" columns="1">
|
||||||
</group>
|
</group>
|
||||||
|
@ -65,9 +66,9 @@
|
||||||
</group>
|
</group>
|
||||||
<foot>
|
<foot>
|
||||||
<button string="Confirm" type="success" method="confirm" states="draft" />
|
<button string="Confirm" type="success" method="confirm" states="draft" />
|
||||||
<button string="Approve" type="success" method="approve" states="confirmed"/>
|
<button string="Validate" type="success" method="approve" states="confirmed"/>
|
||||||
<button string="Validate" type="success" method="validate" states="approved" />
|
<!--<button string="Validate" type="success" method="validate" states="confirmed" />-->
|
||||||
<button string="Pay" type="success" method="paid" states="validated" />
|
<button string="Pay" type="success" method="paid" states="approved" />
|
||||||
</foot>
|
</foot>
|
||||||
<related>
|
<related>
|
||||||
<field name="invoices" click_action="view_invoice"/>
|
<field name="invoices" click_action="view_invoice"/>
|
||||||
|
|
|
@ -83,8 +83,9 @@
|
||||||
</tab>
|
</tab>
|
||||||
</tabs>
|
</tabs>
|
||||||
<related>
|
<related>
|
||||||
<field name="hd_cases"/>
|
|
||||||
<field name="visits"/>
|
<field name="visits"/>
|
||||||
|
<field name="hd_cases"/>
|
||||||
|
<field name="dialyzers"/>
|
||||||
<field name="comments"/>
|
<field name="comments"/>
|
||||||
</related>
|
</related>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -43,7 +43,7 @@ class HDcase(Model):
|
||||||
"comments": fields.One2Many("message","related_id","Comments"),
|
"comments": fields.One2Many("message","related_id","Comments"),
|
||||||
"company_id": fields.Many2One("company","Company"),
|
"company_id": fields.Many2One("company","Company"),
|
||||||
"fee": fields.Float("HD Fee"),
|
"fee": fields.Float("HD Fee"),
|
||||||
"amount": fields.Float("Amount",function="get_total",readonly=True,function_multi=True),
|
"amount": fields.Float("Due Amount",function="get_total",readonly=True,function_multi=True),
|
||||||
"total": fields.Float("Total",function="get_total",readonly=True,function_multi=True),
|
"total": fields.Float("Total",function="get_total",readonly=True,function_multi=True),
|
||||||
"reconcile_id": fields.Many2One("account.reconcile","Reconcile Id",readonly=True),
|
"reconcile_id": fields.Many2One("account.reconcile","Reconcile Id",readonly=True),
|
||||||
"invoices": fields.One2Many("account.invoice","related_id","Invoices"),
|
"invoices": fields.One2Many("account.invoice","related_id","Invoices"),
|
||||||
|
@ -120,14 +120,116 @@ class HDcase(Model):
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def onchange_product(self,context={}):
|
||||||
|
data=context['data']
|
||||||
|
path=context["path"]
|
||||||
|
line=get_data_path(data,path,parent=True)
|
||||||
|
product_id=line.get('product_id')
|
||||||
|
if not product_id:
|
||||||
|
return
|
||||||
|
prod=get_model("product").browse(product_id)
|
||||||
|
line['uom_id']=prod.uom_id.id
|
||||||
|
line['description']=prod.name
|
||||||
|
line['qty']=1
|
||||||
|
line['price']=prod.sale_price or 0.0
|
||||||
|
line['amount']=prod.sale_price or 0.0
|
||||||
|
self.onchange_line(context)
|
||||||
|
return data
|
||||||
|
|
||||||
|
def onchange_line(self,context={}):
|
||||||
|
data=context['data']
|
||||||
|
total=0.0
|
||||||
|
for line in data['lines']:
|
||||||
|
price=line.get('price') or 0
|
||||||
|
qty=line.get('qty') or 0
|
||||||
|
amt=qty * price
|
||||||
|
product_id=line.get("product_id")
|
||||||
|
if product_id:
|
||||||
|
line['amount']=amt
|
||||||
|
total+=amt
|
||||||
|
data['total']=total
|
||||||
|
return data
|
||||||
|
|
||||||
def cancelled(self,ids,context={}):
|
def cancelled(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
obj.write({"state":"cancelled"})
|
obj.write({"state":"cancelled"})
|
||||||
|
|
||||||
def make_invoice(self,ids,context={}):
|
def make_invoices(self,ids,context={}):
|
||||||
for obj in self.browse(ids):
|
setting=get_model("settings").browse(1)
|
||||||
|
currency_id=setting.currency_id.id
|
||||||
|
account_receivable_id=setting.account_receivable_id.id
|
||||||
|
company_id=get_active_company()
|
||||||
|
uom=get_model("uom").search_browse([['name','ilike','%Unit%']])
|
||||||
|
if not uom:
|
||||||
|
raise Exception("Unit not found in uom")
|
||||||
|
obj=self.browse(ids[0])
|
||||||
|
due_date=obj.date_start[0:10]
|
||||||
|
# XXX
|
||||||
|
context['type']='out'
|
||||||
|
context['inv_type']='invoice'
|
||||||
|
if obj.lines:
|
||||||
|
# XXX need to split function prepare invoice
|
||||||
|
vals={
|
||||||
|
"type": "out",
|
||||||
|
"inv_type": "invoice",
|
||||||
|
"tax_type": "tax_in",
|
||||||
|
'due_date': due_date,
|
||||||
|
"ref": obj.number,
|
||||||
|
"related_id": "clinic.hd.case,%s"%obj.id,
|
||||||
|
"currency_id": currency_id,
|
||||||
|
"company_id": company_id,
|
||||||
|
"lines": [],
|
||||||
|
"company_id": company_id,
|
||||||
|
}
|
||||||
|
partner=obj.patient_id.partner_id
|
||||||
|
if not partner:
|
||||||
|
raise Exception("No contact for patient %s"%obj.patient_id.name)
|
||||||
|
vals["partner_id"]=partner.id
|
||||||
|
for line in obj.lines:
|
||||||
|
line={
|
||||||
|
"product_id": line.product_id.id,
|
||||||
|
"description": line.description,
|
||||||
|
"qty": line.qty,
|
||||||
|
"uom_id": line.uom_id.id,
|
||||||
|
"unit_price": line.price,
|
||||||
|
"amount": line.amount,
|
||||||
|
'account_id': line.product_id.sale_account_id.id or account_receivable_id,
|
||||||
|
}
|
||||||
|
vals['lines'].append(('create',line))
|
||||||
|
inv_id=get_model("account.invoice").create(vals,context)
|
||||||
if obj.fee:
|
if obj.fee:
|
||||||
pass
|
vals={
|
||||||
|
"type": "out",
|
||||||
|
"inv_type": "invoice",
|
||||||
|
"tax_type": "tax_in",
|
||||||
|
'due_date': due_date,
|
||||||
|
"ref": obj.number,
|
||||||
|
"related_id": "clinic.hd.case,%s"%obj.id,
|
||||||
|
"currency_id": currency_id,
|
||||||
|
"company_id": company_id,
|
||||||
|
"lines": [],
|
||||||
|
"company_id": company_id,
|
||||||
|
}
|
||||||
|
vals["partner_id"]=obj.fee_partner_id.id
|
||||||
|
if obj.fee_partner_id.account_payable_id:
|
||||||
|
account_receivable_id=obj.fee_partner_id.account_payable_id.id
|
||||||
|
line={
|
||||||
|
"product_id": None,
|
||||||
|
"description": "Fee",
|
||||||
|
"qty": 1,
|
||||||
|
"uom_id": uom[0].id,
|
||||||
|
"unit_price": obj.fee,
|
||||||
|
"amount": obj.fee,
|
||||||
|
'account_id': account_receivable_id,
|
||||||
|
}
|
||||||
|
vals['lines'].append(('create',line))
|
||||||
|
inv_id=get_model("account.invoice").create(vals,context)
|
||||||
|
|
||||||
|
def post_invoices(self,ids,context={}):
|
||||||
|
obj=self.browse(ids[0])
|
||||||
|
for inv in obj.invoices:
|
||||||
|
inv.post()
|
||||||
|
print("Post!")
|
||||||
|
|
||||||
def confirm(self,ids,context={}):
|
def confirm(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
|
@ -139,8 +241,17 @@ class HDcase(Model):
|
||||||
|
|
||||||
def approve(self,ids,context={}):
|
def approve(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
obj.make_invoice()
|
obj.make_invoices()
|
||||||
|
obj.post_invoices()
|
||||||
obj.write({"state":"approved"})
|
obj.write({"state":"approved"})
|
||||||
|
return {
|
||||||
|
'next': {
|
||||||
|
'name': 'clinic_hd_case',
|
||||||
|
'mode': 'form',
|
||||||
|
'active_id': obj.id,
|
||||||
|
},
|
||||||
|
'flash': '%s has been approved'%obj.number,
|
||||||
|
}
|
||||||
|
|
||||||
def approved(self,ids,context={}):
|
def approved(self,ids,context={}):
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
|
@ -248,7 +359,7 @@ class HDcase(Model):
|
||||||
amt=0
|
amt=0
|
||||||
fee=obj.fee or 0
|
fee=obj.fee or 0
|
||||||
for line in obj.lines:
|
for line in obj.lines:
|
||||||
total+=line.total or 0
|
total+=line.amount or 0
|
||||||
fee=0 # XXX
|
fee=0 # XXX
|
||||||
amt=total+fee
|
amt=total+fee
|
||||||
vals[obj.id]={
|
vals[obj.id]={
|
||||||
|
@ -265,21 +376,6 @@ class HDcase(Model):
|
||||||
'active_id': ids[0],
|
'active_id': ids[0],
|
||||||
}
|
}
|
||||||
|
|
||||||
def onchange_product(self,context={}):
|
|
||||||
data=context['data']
|
|
||||||
all_total=0.0
|
|
||||||
for line in data['lines']:
|
|
||||||
qty=line['qty'] or 0
|
|
||||||
price=line['price'] or 0.0
|
|
||||||
total=qty*price
|
|
||||||
line['total']=total
|
|
||||||
all_total+=total
|
|
||||||
fee_amt=data['fee'] or 0.0
|
|
||||||
fee_amt=0.0 # XXX
|
|
||||||
data['total']=all_total
|
|
||||||
data['amount']=all_total+fee_amt
|
|
||||||
return data
|
|
||||||
|
|
||||||
def delete(self,ids,context={}):
|
def delete(self,ids,context={}):
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
if obj.state != 'draft':
|
if obj.state != 'draft':
|
||||||
|
|
|
@ -5,11 +5,11 @@ class Hdcaseline(Model):
|
||||||
_fields={
|
_fields={
|
||||||
"hd_case_id": fields.Many2One("clinic.hd.case","HdCase",required=True,on_delete="cascade"),
|
"hd_case_id": fields.Many2One("clinic.hd.case","HdCase",required=True,on_delete="cascade"),
|
||||||
"product_id": fields.Many2One("product","Product",search=True),
|
"product_id": fields.Many2One("product","Product",search=True),
|
||||||
"detail": fields.Char("Description",search=True),
|
"description": fields.Char("Description",search=True),
|
||||||
"qty":fields.Integer("QTY"),
|
"qty":fields.Integer("QTY"),
|
||||||
"uom_id": fields.Many2One("uom","UOM",required=True,search=True),
|
"uom_id": fields.Many2One("uom","UOM",required=True,search=True),
|
||||||
"price":fields.Float("Price"),
|
"price":fields.Float("Price"),
|
||||||
"total":fields.Float("Total"),
|
"amount":fields.Float("Amount"),
|
||||||
}
|
}
|
||||||
|
|
||||||
Hdcaseline.register()
|
Hdcaseline.register()
|
||||||
|
|
|
@ -74,6 +74,7 @@ class Patient(Model):
|
||||||
"visits": fields.One2Many("clinic.visit","patient_id","Visits"),
|
"visits": fields.One2Many("clinic.visit","patient_id","Visits"),
|
||||||
"hd_cases": fields.One2Many("clinic.hd.case","patient_id","HD Cases"),
|
"hd_cases": fields.One2Many("clinic.hd.case","patient_id","HD Cases"),
|
||||||
"partner_id": fields.Many2One("partner","Contact"),
|
"partner_id": fields.Many2One("partner","Contact"),
|
||||||
|
"dialyzers": fields.One2Many("clinic.dialyzer","patient_id","Dialyzers"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_number(self,context={}):
|
def _get_number(self,context={}):
|
||||||
|
@ -185,7 +186,8 @@ class Patient(Model):
|
||||||
|
|
||||||
def write(self,ids,vals,**kw):
|
def write(self,ids,vals,**kw):
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
if not obj.partner_id:
|
partner_id=obj.partner_id
|
||||||
|
if not partner_id:
|
||||||
for partner in get_model("partner").search_browse([['name', '=', obj.name]]):
|
for partner in get_model("partner").search_browse([['name', '=', obj.name]]):
|
||||||
if partner.name==obj.name:
|
if partner.name==obj.name:
|
||||||
partner_id=partner.id
|
partner_id=partner.id
|
||||||
|
@ -193,6 +195,7 @@ class Patient(Model):
|
||||||
if not partner_id:
|
if not partner_id:
|
||||||
partner_id=get_model("partner").create({
|
partner_id=get_model("partner").create({
|
||||||
'name': obj.name,
|
'name': obj.name,
|
||||||
|
'last_name': obj.name,
|
||||||
'type': 'person',
|
'type': 'person',
|
||||||
})
|
})
|
||||||
vals['partner_id']=partner_id
|
vals['partner_id']=partner_id
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
sequence (support multi company) -> ok
|
sequence (support multi company) -> ok
|
||||||
- visit
|
- visit
|
||||||
- hd case
|
- hd case
|
||||||
|
- create invoice after validate ->ok
|
||||||
|
- create stock picking -> no
|
||||||
- doctor
|
- doctor
|
||||||
- nurse
|
- nurse
|
||||||
- patient
|
- patient
|
||||||
create new hd case after confirm visit
|
create new hd case after confirm visit ->ok
|
||||||
question?
|
question?
|
||||||
- how cycle running?
|
- how cycle running?
|
||||||
- treatment
|
- treatment
|
||||||
|
|
Loading…
Reference in New Issue