conv_bal
watcha.h 2014-12-04 22:26:20 +07:00
parent 2e55c41d64
commit 0332ee9246
6 changed files with 40 additions and 12 deletions

View File

@ -2,5 +2,7 @@
<field name="string">Expenses</field> <field name="string">Expenses</field>
<field name="view_cls">multi_view</field> <field name="view_cls">multi_view</field>
<field name="model">clinic.hd.case.expense</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="menu">clinic_menu</field>
<field name="limit">50</field>
</action> </action>

View File

@ -14,9 +14,10 @@
<group span="6" columns="1"> <group span="6" columns="1">
<field name="patient_id"/> <field name="patient_id"/>
<field name="amount"/> <field name="amount"/>
<field name="match"/>
</group> </group>
<foot> <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> </foot>
</form> </form>

View File

@ -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="date"/>
<field name="invoice_id"/> <field name="invoice_id"/>
<field name="payment_id"/> <field name="payment_id"/>
<field name="patient_id"/> <field name="patient_id"/>
<field name="amount"/> <field name="amount"/>
<field name="match"/>
<field name="state"/> <field name="state"/>
</list> </list>

View File

@ -632,6 +632,7 @@ class HDCase(Model):
'invoice_id': inv.id, 'invoice_id': inv.id,
'hd_case_id': obj.id, 'hd_case_id': obj.id,
'amount': inv.amount_due, 'amount': inv.amount_due,
'state': 'waiting_matching',
})) }))
for pm in obj.payments: for pm in obj.payments:
exp_lines.append(('create',{ exp_lines.append(('create',{
@ -640,6 +641,7 @@ class HDCase(Model):
'payment_id': pm.id, 'payment_id': pm.id,
'hd_case_id': obj.id, 'hd_case_id': obj.id,
'amount': pm.amount_total, 'amount': pm.amount_total,
'state': 'waiting_matching',
})) }))
obj.write({ obj.write({
'expenes': exp_lines, 'expenes': exp_lines,

View File

@ -7,20 +7,18 @@ class HDCaseExpense(Model):
_string="Expense" _string="Expense"
_name_field="date" _name_field="date"
_fields={ _fields={
'date': fields.Date("Date"), 'date': fields.Date("Date",search=True),
'patient_id': fields.Many2One("clinic.patient","Patient"), 'patient_id': fields.Many2One("clinic.patient","Patient",search=True),
'hd_case_id': fields.Many2One("clinic.hd.case","HD Case"), 'hd_case_id': fields.Many2One("clinic.hd.case","HD Case",search=True),
'invoice_id': fields.Many2One("account.invoice","Invoice"), 'invoice_id': fields.Many2One("account.invoice","Invoice",search=True),
'payment_id': fields.Many2One("account.payment","Payment"), 'payment_id': fields.Many2One("account.payment","Payment",search=True),
'amount': fields.Float("Amount"), 'amount': fields.Float("Amount"),
'state': fields.Selection([['draft','Draft'],['approved','Approved']],'State'), 'state': fields.Selection([['draft','Draft'],['waiting_matching','Waiting Matching'],['match','Match'],['unmatch','Unmatch'],['approved','Approved']],'State'),
'match': fields.Boolean("Match"),
} }
_defaults={ _defaults={
'state': 'draft', 'state': 'draft',
'date': time.strftime("%Y-%m-%d"), 'date': time.strftime("%Y-%m-%d"),
'match': False,
} }
_order="date desc" _order="date desc"
@ -37,4 +35,29 @@ class HDCaseExpense(Model):
'state': 'draft', '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() HDCaseExpense.register()

View File

@ -2,6 +2,7 @@ from netforce.model import Model, fields
class HdCaseStaff(Model): class HdCaseStaff(Model):
_name="clinic.hd.case.staff" _name="clinic.hd.case.staff"
_name_field="staff_id"
_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"),
"staff_id": fields.Many2One("clinic.staff","Staff",search=True), "staff_id": fields.Many2One("clinic.staff","Staff",search=True),