Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added logic to extend base_tier_validation module with hr department #727

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions base_tier_validation_hr_department/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions base_tier_validation_hr_department/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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,
}
2 changes: 2 additions & 0 deletions base_tier_validation_hr_department/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import tier_definition
from . import tier_review
8 changes: 8 additions & 0 deletions base_tier_validation_hr_department/models/tier_definition.py
Original file line number Diff line number Diff line change
@@ -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")
21 changes: 21 additions & 0 deletions base_tier_validation_hr_department/models/tier_review.py
Original file line number Diff line number Diff line change
@@ -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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions base_tier_validation_hr_department/views/tier_definition_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_tier_definition_form_hr" model="ir.ui.view">
<field name="name">tier.definition.form.inherit.hr</field>
<field name="model">tier.definition</field>
<field name="inherit_id" ref="base_tier_validation.tier_definition_view_form"/>
<field name="arch" type="xml">
<field name="reviewer_id" position="after">
<field name="department_id" attrs="{'invisible': [('review_type', '!=', 'hr_department')], 'required': [('review_type', '=', 'hr_department')]}"/>
</field>
</field>
</record>
</odoo>
Loading