xxx
parent
62df3b9d59
commit
1b452435d7
|
@ -8,7 +8,7 @@ class Department(Model):
|
|||
|
||||
_fields={
|
||||
"name": fields.Char("Name",required=True,search=True),
|
||||
"code": fields.Char("Code",search=True),
|
||||
"code": fields.Char("Code",required=True,search=True),
|
||||
"parent_id": fields.Many2One("clinic.department", "Parent"),
|
||||
'company_id': fields.Many2One("company","Company"),
|
||||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||
|
@ -31,27 +31,33 @@ class Department(Model):
|
|||
|
||||
_order="code"
|
||||
|
||||
def create_profile(self,ids,context={}):
|
||||
for obj in self.browse(ids):
|
||||
code=obj.code or ''
|
||||
pf_ids=get_model('profile').search(['code','=',code])
|
||||
if pf_ids:
|
||||
raise Exception("Profile %s is already exist"%(code))
|
||||
return
|
||||
except_perms=['Clinic Menu Settings','Clinic Staff Tab Accounting']
|
||||
other_perms=[]
|
||||
for otp in get_model('permission').search(['name','ilike','clinic'],['name']):
|
||||
name=otp['name']
|
||||
if name in except_perms:
|
||||
continue
|
||||
other_perms.append(otp['id'])
|
||||
get_model('profile').create({
|
||||
'code': code,
|
||||
'name': code,
|
||||
'other_perms': [('set',other_perms)],
|
||||
})
|
||||
print("create profile %s"%(code))
|
||||
|
||||
def share_access(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
model_name='clinic.department'
|
||||
model_id=None
|
||||
for model in get_model("model").search_read([['name',model_name]],['name']):
|
||||
model_id=model['id']
|
||||
if not model_id:
|
||||
model_id=get_model("model").create({'name': model_name,'string': 'Clinic Deparment'}),
|
||||
share_id=None
|
||||
for share in get_model('share.access').search_read([['model_id','=', model_id]],['name']):
|
||||
share_id=share['id']
|
||||
if not share_id:
|
||||
share_id=get_model('share.access').create({
|
||||
'model_id': model_id,
|
||||
'default_accesss': 'custom',
|
||||
'filter_type': 'rw',
|
||||
'select_profile': [],
|
||||
})
|
||||
obj.create_profile()
|
||||
return {
|
||||
'next': {
|
||||
'action': 'clinic_department',
|
||||
'name': 'clinic_department',
|
||||
'active_id': obj.id,
|
||||
'mode': 'form',
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue