commit
be41df14d4
|
|
@ -195,7 +195,7 @@ class LeaveController(http.Controller):
|
|||
attach = http.request.env['ir.attachment'].create({
|
||||
'name': body['attachment'].filename,
|
||||
'datas': base64.b64encode(body['attachment'].read()),
|
||||
'datas_fname': body['attachment'].filename,
|
||||
'store_fname': body['attachment'].filename,
|
||||
'res_model': 'hr.holidays',
|
||||
'res_id': holidays.id,
|
||||
})
|
||||
|
|
@ -261,7 +261,7 @@ class LeaveController(http.Controller):
|
|||
attach = http.request.env['ir.attachment'].create({
|
||||
'name': body['attachment'].filename,
|
||||
'datas': base64.b64encode(body['attachment'].read()),
|
||||
'datas_fname': body['attachment'].filename,
|
||||
'store_fname': body['attachment'].filename,
|
||||
'res_model': 'hr.holidays',
|
||||
'res_id': holidays.id,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ class PermissionController(http.Controller):
|
|||
attach = http.request.env['ir.attachment'].sudo().create({
|
||||
'name': body['attachment'].filename,
|
||||
'datas': base64.b64encode(body['attachment'].read()),
|
||||
'datas_fname': body['attachment'].filename,
|
||||
'store_fname': body['attachment'].filename,
|
||||
'res_model': 'hr.personal.permission',
|
||||
'res_id': permission.id,
|
||||
'personal_permission_id': permission.id,
|
||||
|
|
@ -165,7 +165,7 @@ class PermissionController(http.Controller):
|
|||
attach = http.request.env['ir.attachment'].create({
|
||||
'name': body['attachment'].filename,
|
||||
'datas': base64.b64encode(body['attachment'].read()),
|
||||
'datas_fname': body['attachment'].filename,
|
||||
'store_fname': body['attachment'].filename,
|
||||
'res_model': 'hr.personal.permission',
|
||||
'res_id': permission.id,
|
||||
'personal_permission_id': permission.id,
|
||||
|
|
|
|||
|
|
@ -314,7 +314,6 @@ class AttendanceController(http.Controller):
|
|||
"You are not allowed to perform this operation. please check with one of your team admins"),
|
||||
success=False)
|
||||
try:
|
||||
print("******************employee.message_sent:",employee.message_sent)
|
||||
if json.loads(body['in_zone']):
|
||||
records = employee.attendance_log_ids.sudo().filtered(lambda r: str(r.date) == str(datetime.today().date()) and r.old == False)
|
||||
for r in records:
|
||||
|
|
@ -382,7 +381,6 @@ class AttendanceController(http.Controller):
|
|||
return http_helper.errcode(code=403, message=message)
|
||||
|
||||
def send_msg(self, emp, msg, subject):
|
||||
print("*****************************send")
|
||||
if emp.user_id.partner_id:
|
||||
partner_id = emp.user_id.partner_id
|
||||
partner_id.send_notification(subject, msg, data=None, all_device=True)
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ class LeaveController(http.Controller):
|
|||
attach = http.request.env['ir.attachment'].sudo().create({
|
||||
'name': body['attachment'].filename,
|
||||
'datas': base64.b64encode(body['attachment'].read()),
|
||||
'datas_fname': body['attachment'].filename,
|
||||
'store_fname': body['attachment'].filename,
|
||||
'res_model': 'hr.holidays',
|
||||
'res_id': holidays.id,
|
||||
})
|
||||
|
|
@ -296,7 +296,7 @@ class LeaveController(http.Controller):
|
|||
attach = http.request.env['ir.attachment'].sudo().create({
|
||||
'name': body['attachment'].filename,
|
||||
'datas': base64.b64encode(body['attachment'].read()),
|
||||
'datas_fname': body['attachment'].filename,
|
||||
'store_fname': body['attachment'].filename,
|
||||
'res_model': 'hr.holidays',
|
||||
'res_id': holidays.id,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ class PermissionController(http.Controller):
|
|||
attach = http.request.env['ir.attachment'].sudo().create({
|
||||
'name': body['attachment'].filename,
|
||||
'datas': base64.b64encode(body['attachment'].read()),
|
||||
'datas_fname': body['attachment'].filename,
|
||||
'store_fname': body['attachment'].filename,
|
||||
'res_model': 'hr.personal.permission',
|
||||
'res_id': permission.id,
|
||||
'personal_permission_id': permission.id,
|
||||
|
|
@ -162,7 +162,7 @@ class PermissionController(http.Controller):
|
|||
attach = http.request.env['ir.attachment'].sudo().create({
|
||||
'name': body['attachment'].filename,
|
||||
'datas': base64.b64encode(body['attachment'].read()),
|
||||
'datas_fname': body['attachment'].filename,
|
||||
'store_fname': body['attachment'].filename,
|
||||
'res_model': 'hr.personal.permission',
|
||||
'res_id': permission.id,
|
||||
'personal_permission_id': permission.id,
|
||||
|
|
@ -203,7 +203,7 @@ class PermissionController(http.Controller):
|
|||
attach = http.request.env['ir.attachment'].sudo().create({
|
||||
'name': body['attachment'].filename,
|
||||
'datas': base64.b64encode(body['attachment'].read()),
|
||||
'datas_fname': body['attachment'].filename,
|
||||
'store_fname': body['attachment'].filename,
|
||||
'res_model': 'hr.personal.permission',
|
||||
'res_id': permission.id,
|
||||
'personal_permission_id': permission.id,
|
||||
|
|
|
|||
|
|
@ -20,6 +20,5 @@ class Base(models.AbstractModel):
|
|||
_inherit = 'base'
|
||||
|
||||
def firebase_notification(self,users=None):
|
||||
print("******************************firebase_notification******************************")
|
||||
return True
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ class FirebaseNotification(models.Model):
|
|||
|
||||
#@api.multi
|
||||
def send(self, **kwargs):
|
||||
# print("**********************************************")
|
||||
if kwargs is None:
|
||||
kwargs = {}
|
||||
for notif in self:
|
||||
|
|
|
|||
|
|
@ -60,11 +60,11 @@ class FirebaseRegistration(models.Model):
|
|||
"message_title"), self.env.context.get("message_body")
|
||||
)
|
||||
|
||||
|
||||
#@api.multi
|
||||
def send_message(self, message_title, message_body, data=None):
|
||||
if data is None:
|
||||
data = {}
|
||||
|
||||
if not firebase_app:
|
||||
_logger.error(
|
||||
"google_application_credentials is not correctly "
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ class HrHolidays(models.Model):
|
|||
partner = users.mapped('partner_id')
|
||||
for part in partner:
|
||||
part.send_notification(_("Employee %s Leave Waiting Your Approve") % (self.employee_id.name),
|
||||
" %s - %s" % (self.date_from, self.date_to),data=data, all_device=True)
|
||||
" %s - %s" % (str(self.date_from), str(self.date_to)), data=data, all_device=True)
|
||||
self.employee_id.user_id.partner_id.send_notification(
|
||||
_("Leave Request Has Been Updated to %s") % (validator.get_state_name(self, self.state)),
|
||||
" %s - %s " % (self.date_from, self.date_to),
|
||||
|
|
@ -116,6 +116,7 @@ class HrHolidays(models.Model):
|
|||
li.append(url)
|
||||
return li
|
||||
|
||||
|
||||
class Overtime(models.Model):
|
||||
_inherit = 'employee.overtime.request'
|
||||
|
||||
|
|
@ -163,10 +164,10 @@ class Overtime(models.Model):
|
|||
_("Overtime Request has been Updated to %s ") % (validator.get_state_name(self, self.state)), " %s - %s" % (self.date_from, self.date_to),
|
||||
data=data, all_device=True)
|
||||
|
||||
|
||||
class HrPersonalPermission(models.Model):
|
||||
_inherit = 'hr.personal.permission'
|
||||
|
||||
|
||||
# @api.multi
|
||||
def firebase_notification(self, users=None):
|
||||
# def permission_notification(self,users=None):
|
||||
|
|
@ -202,6 +203,8 @@ class HrPersonalPermission(models.Model):
|
|||
url = url_base + "/web/content/%s" % (att.id)
|
||||
li.append(url)
|
||||
return li
|
||||
|
||||
|
||||
#
|
||||
class HrSalaryAdvance(models.Model):
|
||||
_inherit = 'hr.loan.salary.advance'
|
||||
|
|
|
|||
|
|
@ -12,6 +12,16 @@ class Partner(models.Model):
|
|||
"firebase.registration", "partner_id", readonly=True
|
||||
)
|
||||
|
||||
def send_msg(self, partner_ids, msg, subject):
|
||||
emp = self.env['hr.employee'].sudo().search([('user_id', 'in', partner_ids.user_ids.ids)])
|
||||
if emp.user_id.partner_id:
|
||||
partner_id = emp.user_id.partner_id
|
||||
# partner_id.send_notification(subject, msg, data=None, all_device=True)
|
||||
data = {
|
||||
'title':subject,
|
||||
'body':msg,
|
||||
}
|
||||
emp.user_push_notification(data)
|
||||
def send_notification(self, message_title, message_body, data=None, all_device=True):
|
||||
notification_data = {
|
||||
"title": str(message_title),
|
||||
|
|
@ -22,7 +32,9 @@ class Partner(models.Model):
|
|||
"sent": True,
|
||||
}
|
||||
notification = self.env['firebase.notification'].sudo().create(notification_data)
|
||||
|
||||
if all_device:
|
||||
self.send_msg(notification.partner_ids,str(message_title),str(message_body))
|
||||
for reg in self.firebase_registration_ids:
|
||||
reg.with_context(lang=self.lang).send_message(
|
||||
message_title,
|
||||
|
|
|
|||
|
|
@ -110,7 +110,6 @@ class Validator:
|
|||
algorithm='HS256'
|
||||
)
|
||||
# payload = jwt.decode(token, SECRET_KEY ,algorithms='HS256')
|
||||
print(token)
|
||||
self.save_token(token, user['id'], exp)
|
||||
|
||||
return token
|
||||
|
|
|
|||
|
|
@ -110,7 +110,6 @@ class Validator:
|
|||
algorithm='HS256'
|
||||
)
|
||||
# payload = jwt.decode(token, SECRET_KEY ,algorithms='HS256')
|
||||
print(token)
|
||||
self.save_token(token, user['id'], exp)
|
||||
|
||||
return token
|
||||
|
|
|
|||
|
|
@ -247,22 +247,11 @@ class RestApi(Controller):
|
|||
btn.with_context(context)._run_code(active_id, btn.model, request.env)
|
||||
res = obj.read(["id", "state"])[0]
|
||||
state = res["state"]
|
||||
btn_new = (
|
||||
request.env[BTN]
|
||||
.sudo()
|
||||
.search(
|
||||
[
|
||||
("workflow_id", "=", int(btn.workflow_id.id)),
|
||||
(("node_id.node_name", "=", state)),
|
||||
],
|
||||
[],
|
||||
)
|
||||
)
|
||||
btn_new = request.env[BTN].sudo().search([("workflow_id", "=", int(btn.workflow_id.id)), (("node_id.node_name", "=", state)), ], [],)
|
||||
group_ids = btn_new.mapped("group_ids")
|
||||
users = group_ids.mapped("users") or None
|
||||
print("***************************************users", users)
|
||||
users_list = self.access_users(group_ids, btn)
|
||||
print("***************************************users_list", users_list)
|
||||
rule_groups = btn_new.mapped("group_ids").mapped("rule_groups").filtered(lambda rec:rec.model_id.model == obj._name)
|
||||
users_list = self.access_users(group_ids, obj)
|
||||
users = request.env['res.users'].sudo().search([('id', 'in', users_list)])
|
||||
if reject_reason:
|
||||
obj.write({"reason": reject_reason})
|
||||
obj.firebase_notification(users)
|
||||
|
|
@ -276,17 +265,16 @@ class RestApi(Controller):
|
|||
|
||||
def has_access(self, user_id, record, mode='read'):
|
||||
try:
|
||||
access = record.with_user(user_id).check_access_rule(mode)
|
||||
print("-----------------------",access)
|
||||
record.with_user(user_id).check_access_rule(mode)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
def access_users(self, groups, record):
|
||||
users = []
|
||||
print(groups,record)
|
||||
for group in groups:
|
||||
for user in group.users:
|
||||
if self.has_access(user_id=user.id, record=record, mode='read'):
|
||||
users.append(user)
|
||||
users.append(int(user.id))
|
||||
return users
|
||||
|
||||
|
|
|
|||
|
|
@ -251,12 +251,10 @@ class OdooWorkflow(models.Model):
|
|||
|
||||
def firebase_notification(self):
|
||||
super(OdooWorkflow,self).firebase_notification()
|
||||
print("abzuar")
|
||||
|
||||
# @api.multi
|
||||
def btn_nodes(self):
|
||||
for rec in self:
|
||||
print("**************************************************")
|
||||
rec.firebase_notification()
|
||||
act = {
|
||||
'name': _('Nodes'),
|
||||
|
|
@ -522,7 +520,6 @@ class OdooWorkflowBtnWizard(models.Model):
|
|||
if not rec.invisible_attrs:
|
||||
return True
|
||||
cx = self.env.context.copy() or {}
|
||||
# print(cx)
|
||||
obj = rec.env[cx.get('active_model', False)].browse(cx.get('active_id', 0))
|
||||
locals_dict = {
|
||||
'env': rec.env,
|
||||
|
|
|
|||
Loading…
Reference in New Issue