From f81c9f2e447cedfffc98cbb759f9bfed3b99343a Mon Sep 17 00:00:00 2001 From: younes Date: Sun, 1 Jun 2025 11:25:33 +0100 Subject: [PATCH] Modifications to the Entities page in the Transactions app and permissions for the Transactions Department Manager --- .../exp_transaction_documents/i18n/ar_001.po | 25 ++---- .../models/entity.py | 27 ++++++- .../models/internal_transaction.py | 24 +++--- .../security/ir.model.access.csv | 2 +- .../views/entity.xml | 81 +++++++++++-------- .../views/internal.xml | 7 +- 6 files changed, 91 insertions(+), 75 deletions(-) diff --git a/odex25_transactions/exp_transaction_documents/i18n/ar_001.po b/odex25_transactions/exp_transaction_documents/i18n/ar_001.po index cd68d2360..dda735070 100644 --- a/odex25_transactions/exp_transaction_documents/i18n/ar_001.po +++ b/odex25_transactions/exp_transaction_documents/i18n/ar_001.po @@ -2122,6 +2122,7 @@ msgid "It has all the powers on internal transactions only" msgstr "وله كافة الصلاحيات على المعاملات الداخلية فقط" #. module: exp_transaction_documents +#: model:ir.model.fields,field_description:exp_transaction_documents.field_cm_entity__job_title #: model:ir.model.fields,field_description:exp_transaction_documents.field_cm_entity__job_title_id #: model:ir.model.fields,field_description:exp_transaction_documents.field_cm_job_title__name msgid "Job Title" @@ -2436,7 +2437,12 @@ msgstr "صفحة: / " #: model:ir.model.fields,field_description:exp_transaction_documents.field_cm_entity__parent_id #: model_terms:ir.ui.view,arch_db:exp_transaction_documents.cm_entity_search msgid "Parent Entity" -msgstr "القسم الرئيسي" +msgstr "الإدارة الرئيسية" + +#. module: exp_transaction_documents +#: model:ir.model.fields,field_description:exp_transaction_documents.field_cm_entity__is_employee +msgid "Is Employee" +msgstr "هل هو موظف؟" #. module: exp_transaction_documents #: model:ir.model.fields,field_description:exp_transaction_documents.field_cm_entity__partner_id @@ -3048,7 +3054,7 @@ msgstr "مدة المعاملة" #. module: exp_transaction_documents #: model:res.groups,name:exp_transaction_documents.group_transaction_manager msgid "Transaction Manager" -msgstr "مدير المعاملة" +msgstr "مدير نظام المعاملات" #. module: exp_transaction_documents #: model:ir.model.fields,field_description:exp_transaction_documents.field_incoming_transaction__name @@ -3653,21 +3659,6 @@ msgstr "فترة إنجاز" msgid "Response Days" msgstr "فترة الإنجاز (أيام)" -#. module: exp_transaction_documents -#: model:ir.model.fields,field_description:exp_transaction_documents.field_internal_transaction__response_hours -msgid "Response Hours" -msgstr "فترة الإنجاز (ساعات)" - -#. module: exp_transaction_documents -#: model:ir.model.fields,field_description:exp_transaction_documents.field_internal_transaction__response_minutes -msgid "Response Minutes" -msgstr "فترة الإنجاز (دقائق)" - -#. module: exp_transaction_documents -#: model:ir.model.fields,field_description:exp_transaction_documents.field_internal_transaction__response_seconds -msgid "Response Seconds" -msgstr "فترة الإنجاز (ثواني)" - #. module: exp_transaction_documents #: code:addons/exp_transaction_documents/models/internal_transaction.py:0 #, python-format diff --git a/odex25_transactions/exp_transaction_documents/models/entity.py b/odex25_transactions/exp_transaction_documents/models/entity.py index 31ee5e6d7..fd66c9040 100644 --- a/odex25_transactions/exp_transaction_documents/models/entity.py +++ b/odex25_transactions/exp_transaction_documents/models/entity.py @@ -71,9 +71,11 @@ class Entity(models.Model): department_id = fields.Many2one('hr.department') manager_id = fields.Many2one(comodel_name='cm.entity', string='Unit Manager') secretary_id = fields.Many2one(comodel_name='cm.entity', string='Employee in charge of transactions') - user_id = fields.Many2one(comodel_name='res.users', string='Related User', related='employee_id.user_id', store=True) + # user_id = fields.Many2one(comodel_name='res.users', string='Related User', related='employee_id.user_id', store=True, readonly=False) + user_id = fields.Many2one('res.users', string='Related User', compute='_compute_user_id',store=True, readonly=False) # job_title_id = fields.Many2one(comodel_name='cm.job.title', string='Job Title') job_title_id = fields.Many2one(comodel_name='hr.job', string='Job Title') + job_title = fields.Char(string='Job Title') need_approve = fields.Boolean(string='Need Aprove') executive_direction = fields.Boolean(string='Executive direction') is_secret = fields.Boolean(string='Is Secret') @@ -81,6 +83,7 @@ class Entity(models.Model): person_id_issue_date = fields.Date(string='Person ID Issue Date') employee_assignment_date = fields.Date(string='Employee Assignment Date') employee_id = fields.Many2one('hr.employee') + is_employee = fields.Boolean(string="Is Employee") phone = fields.Char() email = fields.Char() child_ids = fields.Many2many(comodel_name='cm.entity', relation='employee_entity_rel', column1='employee_id', @@ -98,6 +101,12 @@ class Entity(models.Model): to_date = fields.Datetime(string='Delegation To Date') to_delegate = fields.Boolean(string='To Delegate?', compute="_compute_to_delegate") + @api.depends('employee_id') + def _compute_user_id(self): + for rec in self: + if rec.is_employee: + rec.user_id = rec.employee_id.user_id if rec.employee_id else False + def unlink(self): for rec in self: internal_transaction_id = self.env['internal.transaction'].search(['|','|','|','|','|',('to_ids', '=', rec.id),('cc_ids', 'in', rec.id),('preparation_id', '=', rec.id),('employee_id', '=', rec.id),('entity_id', '=', rec.id),('archive_user_id', '=', rec.id)]).ids @@ -121,15 +130,27 @@ class Entity(models.Model): def onchange_department_id(self): self.name = self.department_id.name - @api.onchange('employee_id') + @api.onchange('is_employee','employee_id') def onchange_employee_id(self): - self.job_title_id = self.employee_id.job_id self.name = self.employee_id.name self.person_id = self.employee_id.iqama_number.iqama_id self.email = self.employee_id.personal_email self.phone = self.employee_id.mobile_phone self.person_id_issue_date = self.employee_id.iqama_number.expiry_date # self.employee_assignment_date = self.employee_id.job_id + if self.is_employee and self.employee_id: + self.job_title_id = self.employee_id.job_id + self.image = self.employee_id.image_1920 + else: + self.job_title_id = False + + used_user_ids = self.env['cm.entity'].search([('user_id', '!=', False),]).mapped('user_id.id') + + return { + 'domain': { + 'user_id': [('id', 'not in', used_user_ids)] + } + } @api.onchange('partner_id') def onchange_partner_id(self): diff --git a/odex25_transactions/exp_transaction_documents/models/internal_transaction.py b/odex25_transactions/exp_transaction_documents/models/internal_transaction.py index 40abe5dbf..788c3bc61 100644 --- a/odex25_transactions/exp_transaction_documents/models/internal_transaction.py +++ b/odex25_transactions/exp_transaction_documents/models/internal_transaction.py @@ -27,9 +27,6 @@ class InternalTransaction(models.Model): last_response_date = fields.Datetime(string="Last Response Date") response_time_str = fields.Char(string="Response Time", compute="_compute_response_time", store=True) response_days = fields.Integer(string="Response Days", compute="_compute_response_time", store=True ,group_operator='avg') - response_hours = fields.Integer(string="Response Hours", compute="_compute_response_time", store=True, group_operator='avg') - response_minutes = fields.Integer(string="Response Minutes", compute="_compute_response_time", store=True, group_operator='avg') - response_seconds = fields.Integer(string="Response Seconds", compute="_compute_response_time", store=True, group_operator='avg') @api.depends('last_response_date', 'create_date') def _compute_response_time(self): @@ -40,28 +37,25 @@ class InternalTransaction(models.Model): rec.response_days = total_seconds // 86400 remainder = total_seconds % 86400 - rec.response_hours = remainder // 3600 + hours = remainder // 3600 remainder = remainder % 3600 - rec.response_minutes = remainder // 60 - rec.response_seconds = remainder % 60 + minutes = remainder // 60 + seconds = remainder % 60 parts = [] if rec.response_days: parts.append(_("%s day") % rec.response_days) - if rec.response_hours: - parts.append(_("%s hour") % rec.response_hours) - if rec.response_minutes: - parts.append(_("%s minute") % rec.response_minutes) - if rec.response_seconds or not parts: - parts.append(_("%s second") % rec.response_seconds) + if hours: + parts.append(_("%s hour") % hours) + if minutes: + parts.append(_("%s minute") % minutes) + if seconds or not parts: + parts.append(_("%s second") % seconds) rec.response_time_str = ", ".join(parts) else: rec.response_time_str = "" rec.response_days = 0 - rec.response_hours = 0 - rec.response_minutes = 0 - rec.response_seconds = 0 # to_ids = fields.Many2one(comodel_name='cm.entity', string='Send To') # delegate_employee_id = fields.Many2one('cm.entity', related='to_ids.delegate_employee_id',store=True) diff --git a/odex25_transactions/exp_transaction_documents/security/ir.model.access.csv b/odex25_transactions/exp_transaction_documents/security/ir.model.access.csv index 9c45fefff..a669204b1 100644 --- a/odex25_transactions/exp_transaction_documents/security/ir.model.access.csv +++ b/odex25_transactions/exp_transaction_documents/security/ir.model.access.csv @@ -75,7 +75,7 @@ cm_job_title_exective_man,excetive_cm_job_title,model_cm_job_title,group_cm_exec cm_entity,employee_cm_entity,model_cm_entity,group_cm_employee_group,1,1,0,0 cm_entity_out,employee_out_cm_entity,model_cm_entity,group_cm_user,1,1,1,0 cm_entity_reviwer,reviwer_cm_entity,model_cm_entity,group_cm_reviewer,1,1,0,0 -cm_entity_manager,manager_cm_entity,model_cm_entity,group_transaction_manager,1,1,0,0 +cm_entity_manager,manager_cm_entity,model_cm_entity,group_transaction_manager,1,1,1,0 cm_entity_dep_man,dep_cm_entity,model_cm_entity,group_cm_department_manager,1,1,0,0 cm_entity_exective_man,excetive_cm_entity,model_cm_entity,group_cm_executive_manager,1,1,0,0 cm_entity_delete,delete_cm_entity,model_cm_entity,group_delete_transactions_configuration,1,1,1,1 diff --git a/odex25_transactions/exp_transaction_documents/views/entity.xml b/odex25_transactions/exp_transaction_documents/views/entity.xml index f9ebb4690..1a5a1d137 100644 --- a/odex25_transactions/exp_transaction_documents/views/entity.xml +++ b/odex25_transactions/exp_transaction_documents/views/entity.xml @@ -24,11 +24,24 @@ + - - - - + + + + + + @@ -39,43 +52,43 @@ attrs="{'invisible': [('type','in',['employee','external'])]}"/> - + - - - - - - + + + - - - - + + + + attrs="{'invisible':['|',('type','not in',['employee']),('is_employee', '=', True)]}"/> + attrs="{'invisible':['|',('type','not in',['employee']),('is_employee', '=', True)]}"/> - - + + + @@ -101,15 +114,15 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/odex25_transactions/exp_transaction_documents/views/internal.xml b/odex25_transactions/exp_transaction_documents/views/internal.xml index 117bf2637..e5993917f 100644 --- a/odex25_transactions/exp_transaction_documents/views/internal.xml +++ b/odex25_transactions/exp_transaction_documents/views/internal.xml @@ -54,8 +54,8 @@ - - + + @@ -122,9 +122,6 @@ - - -