conv_bal
watcha.h 2014-11-27 13:04:20 +07:00
parent 719389f5f6
commit 5673bc37f2
7 changed files with 35 additions and 11 deletions

View File

@ -4,6 +4,7 @@
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">
<item string="To Draft" method="to_draft" states="confirmed"/> <item string="To Draft" method="to_draft" states="confirmed"/>
<item string="Recheck Item" method="recheck_item" states="draft"/> <item string="Recheck Item" method="recheck_item" states="draft"/>
<item string="View Cycle Monthly" method="view_cycle_monthly" states="confirmed"/>
</button> </button>
</head> </head>
<tabs> <tabs>

View File

@ -5,20 +5,21 @@
<item string="Copy"/> <item string="Copy"/>
</button> </button>
</head> </head>
<field name="number"/>
<field name="type" required="1"/>
<field name="name"/>
<field name="name_eng"/>
<field name="nick_name"/>
<field name="department_id"/>
<field name="branch_id"/>
<tabs> <tabs>
<tab string="General"> <tab string="General">
<group span="6" columns="1"> <group span="6" columns="1">
<field name="type" required="1"/>
<field name="number"/>
<field name="name"/>
<field name="name_eng"/>
<field name="nick_name"/>
<field name="identification"/> <field name="identification"/>
<field name="expiry_card"/> <field name="expiry_card"/>
<field name="gender"/> <field name="gender"/>
<field name="birthday"/> <field name="birthday"/>
<field name="nation_id"/> <field name="nation_id"/>
<field name="department_id"/>
<field name="categ_id" domain="[['type','=',type]]"/> <field name="categ_id" domain="[['type','=',type]]"/>
<field name="state"/> <field name="state"/>
</group> </group>

View File

@ -1,6 +1,8 @@
<list model="clinic.staff"> <list model="clinic.staff">
<field name="number"/> <field name="number"/>
<field name="name"/> <field name="name"/>
<field name="branch_id"/>
<field name="department_id"/>
<field name="level_id"/> <field name="level_id"/>
<field name="categ_id"/> <field name="categ_id"/>
<field name="type"/> <field name="type"/>

View File

@ -24,6 +24,7 @@ class CycleDaily(Model):
"name": fields.Char("Name"), "name": fields.Char("Name"),
'date': fields.Date("Date", required=True, search=True), 'date': fields.Date("Date", required=True, search=True),
'cycle_items': fields.One2Many("clinic.cycle.item","cycle_daily_id", "Cycle Items"), 'cycle_items': fields.One2Many("clinic.cycle.item","cycle_daily_id", "Cycle Items"),
'cycle_monthly_id': fields.Many2One("clinic.cycle.monthly","Monthly"),
'lines': fields.One2Many("clinic.cycle.daily.line","cycle_daily_id", "Lines"), 'lines': fields.One2Many("clinic.cycle.daily.line","cycle_daily_id", "Lines"),
"state": fields.Selection([("draft","Draft"),('confirmed','Confirmed')],"Status",required=True), "state": fields.Selection([("draft","Draft"),('confirmed','Confirmed')],"Status",required=True),
'company_id': fields.Many2One("company","Company"), 'company_id': fields.Many2One("company","Company"),
@ -50,7 +51,8 @@ class CycleDaily(Model):
obj.write({ obj.write({
'state': 'confirmed', 'state': 'confirmed',
}) })
# TODO create cycle monthly
# TODO create/update cycle monthly
all_vals={} all_vals={}
for line in obj.lines: for line in obj.lines:
staff=line.staff_id staff=line.staff_id
@ -61,6 +63,7 @@ class CycleDaily(Model):
all_vals[staff.id]={ all_vals[staff.id]={
'level_id': level.id, 'level_id': level.id,
'type': line.type, 'type': line.type,
'date': obj.date,
'qty': 0, 'qty': 0,
'amount': 0, 'amount': 0,
} }
@ -81,7 +84,8 @@ class CycleDaily(Model):
mid=res[0]['id'] mid=res[0]['id']
monthly=mobj.browse(mid) monthly=mobj.browse(mid)
for line in monthly.lines: for line in monthly.lines:
line.delete() if line.date==obj.date:
line.delete()
monthly.write({ monthly.write({
'lines': lines, 'lines': lines,
}) })
@ -152,5 +156,16 @@ class CycleDaily(Model):
total+=qty*rate total+=qty*rate
data['total']=total data['total']=total
return data return data
def view_cycle_monthly(self,ids,context):
obj=self.browse(ids)[0]
monthly=obj.cycle_monthly_id
return {
'next': {
'name': 'clinic_monthly',
'mode': 'form',
'active_id': monthly.id,
},
}
CycleDaily.register() CycleDaily.register()

View File

@ -1,3 +1,5 @@
import time
from netforce.model import Model, fields from netforce.model import Model, fields
from netforce.access import get_active_company from netforce.access import get_active_company
@ -9,6 +11,7 @@ class CycleMonthlyLine(Model):
"cycle_monthly_id": fields.Many2One("clinic.cycle.monthly","Cycle Monthly"), "cycle_monthly_id": fields.Many2One("clinic.cycle.monthly","Cycle Monthly"),
'staff_id': fields.Many2One("clinic.staff", "Staff"), 'staff_id': fields.Many2One("clinic.staff", "Staff"),
'level_id': fields.Many2One("clinic.staff.level", "Level"), 'level_id': fields.Many2One("clinic.staff.level", "Level"),
'date': fields.Date("Date"),
'qty': fields.Integer("Qty"), 'qty': fields.Integer("Qty"),
'rate': fields.Float("Rate"), 'rate': fields.Float("Rate"),
'amount': fields.Float("Amount"), 'amount': fields.Float("Amount"),
@ -18,6 +21,7 @@ class CycleMonthlyLine(Model):
_defaults={ _defaults={
'company_id': lambda *a: get_active_company(), 'company_id': lambda *a: get_active_company(),
'date': lambda *a: time.strftime("%Y-%m-%d"),
} }

View File

@ -14,7 +14,7 @@ class Patient(Model):
_string="Patient" _string="Patient"
_audit_log=True _audit_log=True
_multi_company=True _multi_company=True
_key=["number,name"] _key=['name']
def _get_age(self,ids,context): def _get_age(self,ids,context):
res={} res={}

View File

@ -8,7 +8,7 @@ class Staff(Model):
_string="Staff" _string="Staff"
_audit_log=True _audit_log=True
_multi_company=True _multi_company=True
_key=["name"] _key=["number","name"]
def _get_age(self,ids,context={}): def _get_age(self,ids,context={}):
res={} res={}
@ -56,7 +56,7 @@ class Staff(Model):
_fields={ _fields={
'employee_id': fields.Many2One("hr.employee","Employee"), 'employee_id': fields.Many2One("hr.employee","Employee"),
"number": fields.Char("Ref.",required=True,search=True), "number": fields.Char("Number",required=True,search=True),
"name": fields.Char("Name",required=True,search=True), "name": fields.Char("Name",required=True,search=True),
"name_eng": fields.Char("Eng Name",search=True), "name_eng": fields.Char("Eng Name",search=True),
"nick_name": fields.Char("Nick Name",search=True), "nick_name": fields.Char("Nick Name",search=True),
@ -98,6 +98,7 @@ class Staff(Model):
"rotations": fields.One2Many("clinic.staff.rotation","staff_id","Staff Rotation"), "rotations": fields.One2Many("clinic.staff.rotation","staff_id","Staff Rotation"),
"cycles": fields.One2Many("clinic.staff.cycle","staff_id","Cycles"), "cycles": fields.One2Many("clinic.staff.cycle","staff_id","Cycles"),
'cycle_id': fields.Many2One('clinic.cycle','Last Cycle',function="_get_cycle"), 'cycle_id': fields.Many2One('clinic.cycle','Last Cycle',function="_get_cycle"),
'branch_id': fields.Many2One("clinic.branch","Branch"),
} }
def _get_number(self,context={}): def _get_number(self,context={}):