order cycle item

conv_bal
watcha.h@almacom.co.th 2015-01-19 08:27:10 +07:00
parent 8f6230e488
commit 48141145b5
3 changed files with 12 additions and 6 deletions

View File

@ -35,8 +35,8 @@ class CycleItem(Model):
'sequence': fields.Char("Sequence",function="_get_all",function_multi=True,store=True), 'sequence': fields.Char("Sequence",function="_get_all",function_multi=True,store=True),
'user_id': fields.Many2One("base.user","Validator"), 'user_id': fields.Many2One("base.user","Validator"),
'company_id': fields.Many2One("company", "Company"), 'company_id': fields.Many2One("company", "Company"),
'branch_id': fields.Many2One("clinic.branch", "Branch"), 'branch_id': fields.Many2One("clinic.branch", "Branch",search=True),
'department_id': fields.Many2One("clinic.department", "Department"), 'department_id': fields.Many2One("clinic.department", "Department",search=True),
"comments": fields.One2Many("message","related_id","Comments"), "company_id": fields.Many2One("company","Company"), "comments": fields.One2Many("message","related_id","Comments"), "company_id": fields.Many2One("company","Company"),
"state": fields.Selection([("draft","Draft"),("validated","Validated")],"Status",required=True), "state": fields.Selection([("draft","Draft"),("validated","Validated")],"Status",required=True),
} }
@ -60,7 +60,7 @@ class CycleItem(Model):
'department_id': _get_department, 'department_id': _get_department,
} }
_order="date desc" _order="date desc,department_id,cycle_id"
_sql_constraints=[ _sql_constraints=[
("cycle_item_uniq","unique (cycle_id,date,company_id,branch_id,department_id)","Cycle item should be unique"), ("cycle_item_uniq","unique (cycle_id,date,company_id,branch_id,department_id)","Cycle item should be unique"),
] ]
@ -219,6 +219,7 @@ class CycleItem(Model):
vs.write({ vs.write({
'cycle_item_id': obj.id, 'cycle_item_id': obj.id,
}) })
return { return {
'next': { 'next': {
'name': 'clinic_cycle_item', 'name': 'clinic_cycle_item',

View File

@ -126,6 +126,11 @@ class ClinicSetting(Model):
}) })
print('update ', item.name) print('update ', item.name)
item.validate() item.validate()
if item.department_id:
print("update department for nurse", nid)
get_model("clinic.staff").browse(nid).write({
'department_id': item.department_id.id,
})
#return #return
############################################# #############################################
print("Done!") print("Done!")

View File

@ -229,7 +229,7 @@ class Visit(Model):
'branch_id': branch.id, 'branch_id': branch.id,
'department_id': department.id, 'department_id': department.id,
'date': date, 'date': date,
'nurses': [], 'lines': [],
} }
item_id=None item_id=None
@ -241,7 +241,7 @@ class Visit(Model):
item=item_obj.browse(item_id) item=item_obj.browse(item_id)
if item.state!='draft': if item.state!='draft':
# reset nurse # reset nurse
for nurse in item.nurses: for nurse in item.lines:
nurse.delete() nurse.delete()
# copy nurse from schedule # copy nurse from schedule
@ -252,7 +252,7 @@ class Visit(Model):
for line in schedule.lines: for line in schedule.lines:
if line.cycle_id.id==cycle.id: if line.cycle_id.id==cycle.id:
nurse=line.nurse_id nurse=line.nurse_id
item_vals['nurses'].append(('create',{ item_vals['lines'].append(('create',{
'nurse_id': nurse.id, 'nurse_id': nurse.id,
'level_id': nurse.level_id.id, 'level_id': nurse.level_id.id,
})) }))