expense
parent
2e55c41d64
commit
0332ee9246
|
@ -2,5 +2,7 @@
|
|||
<field name="string">Expenses</field>
|
||||
<field name="view_cls">multi_view</field>
|
||||
<field name="model">clinic.hd.case.expense</field>
|
||||
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Waiting Matching",[["state","=","waiting_matching"]]],["Match",[["state","=","match"]]],["Unmatch",[["state","=","unmatch"]]],["Approved",[["state","=","approved"]]]]</field>
|
||||
<field name="menu">clinic_menu</field>
|
||||
<field name="limit">50</field>
|
||||
</action>
|
||||
|
|
|
@ -14,9 +14,10 @@
|
|||
<group span="6" columns="1">
|
||||
<field name="patient_id"/>
|
||||
<field name="amount"/>
|
||||
<field name="match"/>
|
||||
</group>
|
||||
<foot>
|
||||
<button string="Approve" type="success" method="approve" icon="ok" states="draft"/>
|
||||
<button string="Approve" type="success" icon="ok" method="approve" states="match"/>
|
||||
<button string="Match" type="success" icon="ok" method="do_match" states="waiting_matching,unmatch,draft"/>
|
||||
<button string="Unmatch" type="danger" icon="remove" method="do_unmatch" states="waiting_matching,match,draft"/>
|
||||
</foot>
|
||||
</form>
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
<list model="clinic.hd.case.expense" colors='{"#cfc":[["state","=","approved"]],"#dbdbdb":[["state","=","cancelled"]]}'>
|
||||
<list model="clinic.hd.case.expense" colors='{"#cfc":[["state","=","approved"]],"#ACD1E9":[["state","=","match"]],"#cccccc":[["state","=","unmatch"]],"#f9e37d":[["state","=","waiting_matching"]],"#bcbbb9":[["state","=","cancelled"]]}'>
|
||||
<field name="date"/>
|
||||
<field name="invoice_id"/>
|
||||
<field name="payment_id"/>
|
||||
<field name="patient_id"/>
|
||||
<field name="amount"/>
|
||||
<field name="match"/>
|
||||
<field name="state"/>
|
||||
</list>
|
||||
|
|
|
@ -632,6 +632,7 @@ class HDCase(Model):
|
|||
'invoice_id': inv.id,
|
||||
'hd_case_id': obj.id,
|
||||
'amount': inv.amount_due,
|
||||
'state': 'waiting_matching',
|
||||
}))
|
||||
for pm in obj.payments:
|
||||
exp_lines.append(('create',{
|
||||
|
@ -640,6 +641,7 @@ class HDCase(Model):
|
|||
'payment_id': pm.id,
|
||||
'hd_case_id': obj.id,
|
||||
'amount': pm.amount_total,
|
||||
'state': 'waiting_matching',
|
||||
}))
|
||||
obj.write({
|
||||
'expenes': exp_lines,
|
||||
|
|
|
@ -7,20 +7,18 @@ class HDCaseExpense(Model):
|
|||
_string="Expense"
|
||||
_name_field="date"
|
||||
_fields={
|
||||
'date': fields.Date("Date"),
|
||||
'patient_id': fields.Many2One("clinic.patient","Patient"),
|
||||
'hd_case_id': fields.Many2One("clinic.hd.case","HD Case"),
|
||||
'invoice_id': fields.Many2One("account.invoice","Invoice"),
|
||||
'payment_id': fields.Many2One("account.payment","Payment"),
|
||||
'date': fields.Date("Date",search=True),
|
||||
'patient_id': fields.Many2One("clinic.patient","Patient",search=True),
|
||||
'hd_case_id': fields.Many2One("clinic.hd.case","HD Case",search=True),
|
||||
'invoice_id': fields.Many2One("account.invoice","Invoice",search=True),
|
||||
'payment_id': fields.Many2One("account.payment","Payment",search=True),
|
||||
'amount': fields.Float("Amount"),
|
||||
'state': fields.Selection([['draft','Draft'],['approved','Approved']],'State'),
|
||||
'match': fields.Boolean("Match"),
|
||||
'state': fields.Selection([['draft','Draft'],['waiting_matching','Waiting Matching'],['match','Match'],['unmatch','Unmatch'],['approved','Approved']],'State'),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
'state': 'draft',
|
||||
'date': time.strftime("%Y-%m-%d"),
|
||||
'match': False,
|
||||
}
|
||||
|
||||
_order="date desc"
|
||||
|
@ -37,4 +35,29 @@ class HDCaseExpense(Model):
|
|||
'state': 'draft',
|
||||
})
|
||||
|
||||
def delete(self,ids,context={}):
|
||||
for obj in self.browse(ids):
|
||||
if obj.state!='draft':
|
||||
raise Exception("Status is not draft!")
|
||||
super().delete(ids,context)
|
||||
|
||||
def do_match(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
obj.write({
|
||||
'state': 'match',
|
||||
})
|
||||
|
||||
def do_unmatch(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
obj.write({
|
||||
'state': 'unmatch',
|
||||
})
|
||||
|
||||
def cancel(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
obj.write({
|
||||
'state': 'cancelled',
|
||||
})
|
||||
|
||||
|
||||
HDCaseExpense.register()
|
||||
|
|
|
@ -2,6 +2,7 @@ from netforce.model import Model, fields
|
|||
|
||||
class HdCaseStaff(Model):
|
||||
_name="clinic.hd.case.staff"
|
||||
_name_field="staff_id"
|
||||
_fields={
|
||||
"hd_case_id": fields.Many2One("clinic.hd.case","HdCase",required=True,on_delete="cascade"),
|
||||
"staff_id": fields.Many2One("clinic.staff","Staff",search=True),
|
||||
|
|
Loading…
Reference in New Issue