From dcba3065d74a1ff9a82578fe2c8cb1902e2b1057 Mon Sep 17 00:00:00 2001 From: odex Date: Mon, 8 Jul 2024 12:43:32 +0300 Subject: [PATCH] [ADD ] add new task in hr holiday btn resone refuse --- .gitignore | 128 ++++++++++++++++++ odex25_hr/hr_holidays_public/__manifest__.py | 1 + odex25_hr/hr_holidays_public/i18n/ar_001.po | 50 +++++++ .../hr_holidays_public/models/hr_holidays.py | 19 ++- .../security/ir.model.access.csv | 1 + .../views/hr_holidays_view.xml | 3 + .../hr_holidays_public/wizards/__init__.py | 1 + .../wizards/hr_reject_wizard.py | 27 ++++ .../wizards/hr_reject_wizard_view.xml | 22 +++ 9 files changed, 250 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 odex25_hr/hr_holidays_public/wizards/hr_reject_wizard.py create mode 100644 odex25_hr/hr_holidays_public/wizards/hr_reject_wizard_view.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..e3695b424 --- /dev/null +++ b/.gitignore @@ -0,0 +1,128 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +parts/ +sdist/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + + + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# github action +.github/workflows/*yaml diff --git a/odex25_hr/hr_holidays_public/__manifest__.py b/odex25_hr/hr_holidays_public/__manifest__.py index 02f118fa6..9226bf9ee 100644 --- a/odex25_hr/hr_holidays_public/__manifest__.py +++ b/odex25_hr/hr_holidays_public/__manifest__.py @@ -35,6 +35,7 @@ 'wizards/holidays_public_next_year_wizard.xml', 'wizards/holiday_public_leave_report_view.xml', + 'wizards/hr_reject_wizard_view.xml', 'report/public_leave_report_template.xml', 'report/public_leave_cost_template.xml', diff --git a/odex25_hr/hr_holidays_public/i18n/ar_001.po b/odex25_hr/hr_holidays_public/i18n/ar_001.po index ef9e453e8..dc609b8b9 100644 --- a/odex25_hr/hr_holidays_public/i18n/ar_001.po +++ b/odex25_hr/hr_holidays_public/i18n/ar_001.po @@ -3582,3 +3582,53 @@ msgstr "" #: model:ir.model.fields.selection,name:hr_holidays_public.selection__hr_holidays_status__leave_type__death msgid "وفـاة" msgstr "" + +#. module: hr_holidays_public +#: code:addons/hr_holidays_public/models/hr_holidays.py:0 +#, python-format +msgid "Specify Reject Reason" +msgstr "سبب الرفض" + +#. module: hr_holidays_public +#: model_terms:ir.ui.view,arch_db:hr_holidays_public.pubic_leave_report_wizard_view +#: model_terms:ir.ui.view,arch_db:hr_holidays_public.reject_wizard +msgid "or" +msgstr "او" + +#. module: hr_holidays_public +#: code:addons/hr_holidays_public/wizards/hr_reject_wizard.py:0 +#, python-format +msgid "Sorry This object have no field named Selection Reason" +msgstr "لابد من ادخال سبب الرفض" + +#. module: hr_holidays_public +#: model_terms:ir.ui.view,arch_db:hr_holidays_public.reject_wizard +msgid "Reject" +msgstr "رفض" + +#. module: hr_holidays_public +#: model:ir.model.fields,field_description:hr_holidays_public.field_hr_holidays__reject_reason +#: model:ir.model.fields,field_description:hr_holidays_public.field_hr_reject_wizard__reject_reason +#: model_terms:ir.ui.view,arch_db:hr_holidays_public.hr_holidays_ext_form_view +msgid "Reject Reason" +msgstr "سبب الرفض" + +#. module: hr_holidays_public +#: model:ir.model.fields,field_description:hr_holidays_public.field_hr_reject_wizard__origin +msgid "Origin" +msgstr "الاصل" + +#. module: hr_holidays_public +#: model:ir.model.fields,field_description:hr_holidays_public.field_hr_reject_wizard__origin_name +msgid "Origin Name" +msgstr "اسم الحقل" + +#. module: hr_holidays_public +#: model:ir.model,name:hr_holidays_public.model_hr_reject_wizard +msgid "HR Reject Wizard" +msgstr "سبب الرفض للاجازات" + +#. module: hr_holidays_public +#: model_terms:ir.ui.view,arch_db:hr_holidays_public.reject_wizard +msgid "Close" +msgstr "إغلاق" \ No newline at end of file diff --git a/odex25_hr/hr_holidays_public/models/hr_holidays.py b/odex25_hr/hr_holidays_public/models/hr_holidays.py index 6f7871157..a9051f2e6 100644 --- a/odex25_hr/hr_holidays_public/models/hr_holidays.py +++ b/odex25_hr/hr_holidays_public/models/hr_holidays.py @@ -30,7 +30,7 @@ class HRHolidays(models.Model): start_date = fields.Date(string="Start Date", default=fields.Datetime.now()) end_date = fields.Date(string="End Date") notes = fields.Text() - + reject_reason = fields.Text(string='Reject Reason') issuing_exit_return = fields.Selection(selection=[('yes', _('Yes')), ('no', _('No'))], default='no') check_allocation_view = fields.Selection(selection=[('allocation', _('Allocation')), ('balance', _('Balance'))]) exit_return_duration = fields.Float(related='number_of_days_temp') @@ -1184,6 +1184,21 @@ class HRHolidays(models.Model): balance.write({'remaining_leaves': balance.remaining_leaves - allocation.number_of_days_temp, }) def refuse(self): + action_name = _('Specify Reject Reason') + reject_reason = self.env.context.get('reject_reason') + if reject_reason: + return self.action_refuse(reject_reason) + return { + 'type': 'ir.actions.act_window', + 'name': action_name, + 'res_model': 'hr.reject.wizard', + 'view_type': 'form', + 'view_mode': 'form', + 'target': 'new', + 'context': {'default_origin': self.id, 'default_origin_name': self._name} + } + + def action_refuse(self,reject_reason=""): for item in self: have_cancel_request = self.env['leave.cancellation'].search( [('leave_request_id', '=', item.id), ('state', 'not in', ('draft', 'refuse'))]) @@ -1213,7 +1228,7 @@ class HRHolidays(models.Model): item.remove_delegated_access() item.call_cron_function() self.check_allocation_balance_annual('addition') - item.write({'state': 'refuse'}) + item.write({'state': 'refuse','reject_reason':reject_reason}) @api.onchange('holiday_status_id') def _get_holiday_related_date(self): diff --git a/odex25_hr/hr_holidays_public/security/ir.model.access.csv b/odex25_hr/hr_holidays_public/security/ir.model.access.csv index 4c3378479..08dcf850b 100644 --- a/odex25_hr/hr_holidays_public/security/ir.model.access.csv +++ b/odex25_hr/hr_holidays_public/security/ir.model.access.csv @@ -28,3 +28,4 @@ access_hr_holidays_status_duration,access_hr_holidays_duration,model_holiday_sta access_public_leave_report_user,access_public_leave_report,model_public_leave_report,base.group_user,1,1,1,0 access_public_holidays_next_year_wizard_user,access_public_holidays_next_year_wizard,model_public_holidays_next_year_wizard,base.group_user,1,1,1,0 access_zfp_hr_custom_buy_vacation,zfp_hr_custom.buy_vacation,model_buy_vacation,base.group_user,1,1,1,1 +access_hr_reject_wizard,access_hr_reject_wizard,model_hr_reject_wizard,base.group_user,1,1,1,1 \ No newline at end of file diff --git a/odex25_hr/hr_holidays_public/views/hr_holidays_view.xml b/odex25_hr/hr_holidays_public/views/hr_holidays_view.xml index 97a2f1eb9..5f8a07e6d 100644 --- a/odex25_hr/hr_holidays_public/views/hr_holidays_view.xml +++ b/odex25_hr/hr_holidays_public/views/hr_holidays_view.xml @@ -112,6 +112,9 @@ + + +
diff --git a/odex25_hr/hr_holidays_public/wizards/__init__.py b/odex25_hr/hr_holidays_public/wizards/__init__.py index 110a0808b..ca46090e1 100644 --- a/odex25_hr/hr_holidays_public/wizards/__init__.py +++ b/odex25_hr/hr_holidays_public/wizards/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- from . import holidays_public_next_year_wizard from . import holiday_public_leave_report_wiz +from . import hr_reject_wizard diff --git a/odex25_hr/hr_holidays_public/wizards/hr_reject_wizard.py b/odex25_hr/hr_holidays_public/wizards/hr_reject_wizard.py new file mode 100644 index 000000000..e036ae2db --- /dev/null +++ b/odex25_hr/hr_holidays_public/wizards/hr_reject_wizard.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Expert Co. Ltd. +# Copyright (C) 2018 (). +# +############################################################################## + + +from odoo import api, fields, models, _ +from odoo.exceptions import Warning, ValidationError + + + +class RejectWizard(models.TransientModel): + _name = 'hr.reject.wizard' + _description = 'HR Reject Wizard' + origin = fields.Integer('') + reject_reason = fields.Text(string='Reject Reason') + origin_name = fields.Char('') + + def action_reject(self): + origin_rec = self.env[self.origin_name].sudo().browse(self.origin) + if dict(self._fields).get('reject_reason') is None: + raise ValidationError(_('Sorry This object have no field named Selection Reason')) + else: + return origin_rec.action_refuse(self.reject_reason) \ No newline at end of file diff --git a/odex25_hr/hr_holidays_public/wizards/hr_reject_wizard_view.xml b/odex25_hr/hr_holidays_public/wizards/hr_reject_wizard_view.xml new file mode 100644 index 000000000..79c7c36d5 --- /dev/null +++ b/odex25_hr/hr_holidays_public/wizards/hr_reject_wizard_view.xml @@ -0,0 +1,22 @@ + + + + + Reject Reason + hr.reject.wizard + +
+ + + + + +
+
+
\ No newline at end of file