diff --git a/base_tier_validation_hr_department/__init__.py b/base_tier_validation_hr_department/__init__.py new file mode 100644 index 0000000000..9a7e03eded --- /dev/null +++ b/base_tier_validation_hr_department/__init__.py @@ -0,0 +1 @@ +from . import models \ No newline at end of file diff --git a/base_tier_validation_hr_department/__manifest__.py b/base_tier_validation_hr_department/__manifest__.py new file mode 100644 index 0000000000..0b1dfc4e4c --- /dev/null +++ b/base_tier_validation_hr_department/__manifest__.py @@ -0,0 +1,14 @@ +{ + 'name': 'Base Tier Validation HR Department', + 'version': '1.0.0', + 'category': 'Human Resources', + 'summary': 'Extend Base Tier Validation with HR Department for reviewers based on users employee department', + 'author': 'SATI', + 'website': 'https://www.sati.com.py', + 'depends': ['base_tier_validation', 'hr'], + 'data': [ + 'views/tier_definition_view.xml', + ], + 'installable': True, + 'application': False, +} diff --git a/base_tier_validation_hr_department/models/__init__.py b/base_tier_validation_hr_department/models/__init__.py new file mode 100644 index 0000000000..03e2818f69 --- /dev/null +++ b/base_tier_validation_hr_department/models/__init__.py @@ -0,0 +1,2 @@ +from . import tier_definition +from . import tier_review \ No newline at end of file diff --git a/base_tier_validation_hr_department/models/tier_definition.py b/base_tier_validation_hr_department/models/tier_definition.py new file mode 100644 index 0000000000..9115a7f1cd --- /dev/null +++ b/base_tier_validation_hr_department/models/tier_definition.py @@ -0,0 +1,8 @@ +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError + +class TierDefinition(models.Model): + _inherit = "tier.definition" + + review_type = fields.Selection(selection_add=[('hr_department', 'HR Department')]) + department_id = fields.Many2one('hr.department', string="Department") diff --git a/base_tier_validation_hr_department/models/tier_review.py b/base_tier_validation_hr_department/models/tier_review.py new file mode 100644 index 0000000000..b333b1c605 --- /dev/null +++ b/base_tier_validation_hr_department/models/tier_review.py @@ -0,0 +1,21 @@ +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError + +class TierReview(models.Model): + _inherit = "tier.review" + + department_id = fields.Many2one(related="definition_id.reviewer_id", readonly=True) + + + def _get_reviewer_fields(self): + fields = super(TierReview, self)._get_reviewer_fields() + fields.append("department_id") + return fields + + def _get_reviewers(self): + reviewers = super(TierReview, self)._get_reviewers() + if self.review_type == 'hr_department' and self.definition_id.department_id: + # Obtener todos los usuarios del departamento especificado + department_users = self.env['res.users'].search([('department_id', '=', self.definition_id.department_id.id)]) + reviewers |= department_users + return reviewers diff --git a/base_tier_validation_hr_department/static/description/icon.png b/base_tier_validation_hr_department/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/base_tier_validation_hr_department/static/description/icon.png differ diff --git a/base_tier_validation_hr_department/views/tier_definition_view.xml b/base_tier_validation_hr_department/views/tier_definition_view.xml new file mode 100644 index 0000000000..bfe260dde6 --- /dev/null +++ b/base_tier_validation_hr_department/views/tier_definition_view.xml @@ -0,0 +1,13 @@ + + + + tier.definition.form.inherit.hr + tier.definition + + + + + + + +