cycle dialy

conv_bal
watcha.h 2014-11-23 20:44:25 +07:00
parent 096cbcbb13
commit e129ccf370
8 changed files with 48 additions and 5 deletions

View File

@ -1,4 +1,4 @@
<list model="clinic.cycle.dialy"> <list model="clinic.cycle.dialy" colors='{"#cfc":[["state","=","confirmed"]],"#dbdbdb":[["state","=","cancelled"]]}'>
<field name="name"/> <field name="name"/>
<field name="state"/> <field name="state"/>
</list> </list>

View File

@ -41,6 +41,7 @@
<field name="prof_license_expiry" attrs='{"invisible":[["type","in",["personal"]]]}'/> <field name="prof_license_expiry" attrs='{"invisible":[["type","in",["personal"]]]}'/>
<field name="cycle_id"/> <field name="cycle_id"/>
<field name="base"/> <field name="base"/>
<field name="max_cycle"/>
</tab> </tab>
<tab string="Note"> <tab string="Note">
<field name="note" nolabel="1"/> <field name="note" nolabel="1"/>
@ -69,7 +70,8 @@
<field name="to_company_id"/> <field name="to_company_id"/>
<field name="hire_date"/> <field name="hire_date"/>
<field name="resign_date"/> <field name="resign_date"/>
<!--<field name="wage"/>--> <field name="max_cycle"/>
<field name="wage"/>
<field name="note"/> <field name="note"/>
</list> </list>
</field> </field>

View File

@ -6,5 +6,6 @@
<field name="hire_date"/> <field name="hire_date"/>
<field name="resign_date"/> <field name="resign_date"/>
<field name="wage"/> <field name="wage"/>
<field name="max_cycle"/>
<field name="note"/> <field name="note"/>
</form> </form>

View File

@ -5,6 +5,7 @@
<field name="to_company_id"/> <field name="to_company_id"/>
<field name="hire_date"/> <field name="hire_date"/>
<field name="resign_date"/> <field name="resign_date"/>
<field name="max_cycle"/>
<field name="wage"/> <field name="wage"/>
<field name="note"/> <field name="note"/>
</list> </list>

View File

@ -168,6 +168,32 @@ class CycleItem(Model):
if obj.cycle_id.id==cycle.id: # only own cycle if obj.cycle_id.id==cycle.id: # only own cycle
line.delete() line.delete()
# group personal and cycle date
glines={}
for line in lines:
mode,vals=line
cycle_id=vals['cycle_id']
personal_id=vals['personal_id']
paid_amount=vals['paid_amount'] or 0
key=(cycle_id,personal_id)
if not key in glines.keys():
glines[key]={
'paid_amount': paid_amount,
'type': vals['type'],
}
continue
glines[key]['paid_amount']+=paid_amount
lines=[]
for key,vals in glines.items():
cycle_id,personal_id=key
line={
'cycle_id': cycle_id,
'personal_id': personal_id,
}
line.update(vals)
lines.append(('create',line))
cycle_dialy.write({ cycle_dialy.write({
'lines': lines, 'lines': lines,
}) })

View File

@ -43,9 +43,14 @@ class Personal(Model):
res={} res={}
for obj in self.browse(ids): for obj in self.browse(ids):
base=0 base=0
max_cycle=0
for mv in obj.moves: for mv in obj.moves:
base=mv.wage base=mv.wage
res[obj.id]=base max_cycle=mv.max_cycle
res[obj.id]={
'base': base,
'max_cycle': max_cycle,
}
return res return res
_fields={ _fields={
@ -83,7 +88,8 @@ class Personal(Model):
'level_id': fields.Many2One("clinic.personal.level", "Personal Level", function="_get_level"), 'level_id': fields.Many2One("clinic.personal.level", "Personal Level", function="_get_level"),
'active': fields.Boolean("Active"), 'active': fields.Boolean("Active"),
'date': fields.Date("Register Date"), 'date': fields.Date("Register Date"),
'base': fields.Float("Base Amount", function="_get_base"), 'base': fields.Float("Base Amount", function="_get_base",function_multi=True),
'max_cycle': fields.Integer("Max Cycle", function="_get_base",function_multi=True),
'hire_date': fields.Date("Hire Date"), 'hire_date': fields.Date("Hire Date"),
'resign_date': fields.Date("Resign Date"), 'resign_date': fields.Date("Resign Date"),
"documents": fields.One2Many("document","related_id","Documents"), "documents": fields.One2Many("document","related_id","Documents"),

View File

@ -13,6 +13,7 @@ class PersonalMove(Model):
"hire_date": fields.Date("Hire Date", search=True), "hire_date": fields.Date("Hire Date", search=True),
"resign_date": fields.Date("Resign Date", search=True), "resign_date": fields.Date("Resign Date", search=True),
"wage": fields.Float("Wage"), "wage": fields.Float("Wage"),
"max_cycle": fields.Integer("Max Cycle"),
"note": fields.Text("Note"), "note": fields.Text("Note"),
'company_id': fields.Many2One("company","Company"), 'company_id': fields.Many2One("company","Company"),
} }

View File

@ -1,3 +1,5 @@
import time
from netforce.model import Model from netforce.model import Model
from netforce.database import get_connection from netforce.database import get_connection
from netforce.access import get_active_company from netforce.access import get_active_company
@ -9,6 +11,10 @@ class Report(Model):
def cycle_recent_widget(self,context={}): def cycle_recent_widget(self,context={}):
db=get_connection() db=get_connection()
company_id=get_active_company() company_id=get_active_company()
#datenow=time.strftime("%Y-%m-%d")
#time_start='%s 00:00:00'%(datenow)
#time_stop='%s 23:59:59'%(datenow)
#res=db.query("select count(cycle_id) as count, c.name from clinic_hd_case as hd inner join clinic_cycle as c on c.id=hd.cycle_id where hd.company_id =%s and hd.date >= %s and hd.date <= %s group by c.name",company_id,time_start,time_stop)
res=db.query("select count(cycle_id) as count, c.name from clinic_hd_case as hd inner join clinic_cycle as c on c.id=hd.cycle_id where hd.company_id =%s group by c.name",company_id) res=db.query("select count(cycle_id) as count, c.name from clinic_hd_case as hd inner join clinic_cycle as c on c.id=hd.cycle_id where hd.company_id =%s group by c.name",company_id)
data=[] data=[]
for r in res: for r in res: