From a5038cf60a35bc987cd80351321e38c1f2a2e33d Mon Sep 17 00:00:00 2001 From: eslamabady Date: Mon, 7 Oct 2024 01:50:34 +0300 Subject: [PATCH 1/2] updtate-workflow --- .../controllers/controllers.py | 10 ++++++++++ .../odoo_dynamic_workflow_mobile/i18n/ar_001.po | 6 ++++++ .../models/odoo_workflow_mobile.py | 1 + .../views/odoo_workflow_view.xml | 1 + 4 files changed, 18 insertions(+) diff --git a/odex25_mobile/odoo_dynamic_workflow_mobile/controllers/controllers.py b/odex25_mobile/odoo_dynamic_workflow_mobile/controllers/controllers.py index 1d19503c3..4a560ced8 100644 --- a/odex25_mobile/odoo_dynamic_workflow_mobile/controllers/controllers.py +++ b/odex25_mobile/odoo_dynamic_workflow_mobile/controllers/controllers.py @@ -248,6 +248,10 @@ class RestApi(Controller): 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)), ], [],) + if btn_new.send_manager: + emp_manager = self.get_emp_manager(obj) + obj.firebase_notification(emp_manager.user_id) + return http_helper.response(message="Successful", data=res) group_ids = btn_new.mapped("group_ids") 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) @@ -270,6 +274,12 @@ class RestApi(Controller): except: return False + def get_emp_manager(self, record): + try: + return record.employee_id.parent_id + except: + return False + def access_users(self, groups, record): users = [] for group in groups: diff --git a/odex25_mobile/odoo_dynamic_workflow_mobile/i18n/ar_001.po b/odex25_mobile/odoo_dynamic_workflow_mobile/i18n/ar_001.po index 575d551c1..c56afecdc 100644 --- a/odex25_mobile/odoo_dynamic_workflow_mobile/i18n/ar_001.po +++ b/odex25_mobile/odoo_dynamic_workflow_mobile/i18n/ar_001.po @@ -103,6 +103,12 @@ msgstr "" msgid "Button String" msgstr "" +#. module: odoo_dynamic_workflow_mobile +#: model:ir.model.fields,field_description:odoo_dynamic_workflow_mobile.field_workflow_mobile_node_button__send_manager +#: model:ir.model.fields,help:odoo_dynamic_workflow_mobile.field_workflow_mobile_node_button__send_manager +msgid "Send Direct Manager" +msgstr "ارسال المدير المباشر" + #. module: odoo_dynamic_workflow_mobile #: code:addons/odoo_dynamic_workflow_mobile/models/odoo_workflow_mobile.py:0 #: model:ir.model.fields,field_description:odoo_dynamic_workflow_mobile.field_workflow_mobile_node__button_ids diff --git a/odex25_mobile/odoo_dynamic_workflow_mobile/models/odoo_workflow_mobile.py b/odex25_mobile/odoo_dynamic_workflow_mobile/models/odoo_workflow_mobile.py index 3f25dd905..03a3d65cb 100644 --- a/odex25_mobile/odoo_dynamic_workflow_mobile/models/odoo_workflow_mobile.py +++ b/odex25_mobile/odoo_dynamic_workflow_mobile/models/odoo_workflow_mobile.py @@ -387,6 +387,7 @@ class OdooWorkflowBtnWizard(models.Model): btn_key = fields.Char(string='Button Key', default=_generate_key,readonly=True) btn_hide = fields.Boolean(string="Hide Button if Condition isn't fulfilled", help="If condition is false the button will be hidden.",readonly=True) condition_code = fields.Text(string='Condition Code', default=CONDITION_CODE_TEMP, help="Enter condition to execute button action.",readonly=True) + send_manager = fields.Boolean(string="Send Direct Manager", help="Send Direct Manager") action_type = fields.Selection([ ('link', 'Trigger Link'), ('code', 'Python Code'), diff --git a/odex25_mobile/odoo_dynamic_workflow_mobile/views/odoo_workflow_view.xml b/odex25_mobile/odoo_dynamic_workflow_mobile/views/odoo_workflow_view.xml index fbbf06e47..c5d493a14 100644 --- a/odex25_mobile/odoo_dynamic_workflow_mobile/views/odoo_workflow_view.xml +++ b/odex25_mobile/odoo_dynamic_workflow_mobile/views/odoo_workflow_view.xml @@ -234,6 +234,7 @@ sell it under their names. ###--> domain="[('type','=','form'),('model','=',model)]" /> + From 906fdb4aa817630c0ae24a5fedffbd03c750e5b8 Mon Sep 17 00:00:00 2001 From: eslamabady Date: Mon, 7 Oct 2024 01:51:27 +0300 Subject: [PATCH 2/2] fix-duplicate --- odex25_mobile/odex_mobile/controllers/rest_api_v2/attendance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odex25_mobile/odex_mobile/controllers/rest_api_v2/attendance.py b/odex25_mobile/odex_mobile/controllers/rest_api_v2/attendance.py index a37a0fce9..c7b626425 100644 --- a/odex25_mobile/odex_mobile/controllers/rest_api_v2/attendance.py +++ b/odex25_mobile/odex_mobile/controllers/rest_api_v2/attendance.py @@ -488,7 +488,7 @@ class AttendanceController(http.Controller): 'title':subject, 'body':msg, } - emp.user_push_notification(data) + # emp.user_push_notification(data) def create_log(self, employee, longitude, latitude): with request.env.cr.savepoint():