mirror of
https://github.com/bringout/oca-hr.git
synced 2026-04-25 12:32:06 +02:00
Move all OCA HR modules from oca-technical to dedicated oca-hr submodule
Reorganized 67 HR-related modules for better structure: - Moved all odoo-bringout-oca-hr-* packages from packages/oca-technical/ - Now organized in dedicated packages/oca-hr/ submodule - Includes attendance, expense, holiday, employee, and contract modules - Maintains all module functionality while improving project organization This creates a cleaner separation between general technical modules and HR-specific functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
f672249949
commit
dfcda4100c
2456 changed files with 120722 additions and 0 deletions
|
|
@ -0,0 +1,3 @@
|
|||
from . import hr_personal_equipment
|
||||
from . import product_template
|
||||
from . import hr_personal_equipment_request
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
# Copyright 2020 Escodoo
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from datetime import date
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
from odoo.addons.base.models.ir_cron import _intervalTypes
|
||||
|
||||
|
||||
class HrPersonalEquipment(models.Model):
|
||||
|
||||
_name = "hr.personal.equipment"
|
||||
_inherit = ["hr.personal.equipment"]
|
||||
|
||||
is_ppe = fields.Boolean()
|
||||
indications = fields.Text(
|
||||
help="Situations in which the employee should use this equipment.",
|
||||
)
|
||||
expire_ppe = fields.Boolean(help="True if the PPE expires")
|
||||
certification = fields.Char(
|
||||
string="Certification Number", help="Certification Number"
|
||||
)
|
||||
issued_by = fields.Many2one(comodel_name="res.users")
|
||||
|
||||
def _accept_request_vals(self):
|
||||
res = super()._accept_request_vals()
|
||||
res["issued_by"] = self.env.user.id
|
||||
return res
|
||||
|
||||
@api.onchange("product_id")
|
||||
def _compute_fields(self):
|
||||
for rec in self:
|
||||
if rec.product_id.is_ppe:
|
||||
rec.is_ppe = rec.product_id.is_ppe
|
||||
if rec.product_id.expirable_ppe:
|
||||
rec.expire_ppe = rec.product_id.expirable_ppe
|
||||
if rec.product_id.indications:
|
||||
rec.indications = rec.product_id.indications
|
||||
|
||||
def _validate_allocation_vals(self):
|
||||
res = super()._validate_allocation_vals()
|
||||
if self.start_date:
|
||||
start_date = self.start_date
|
||||
else:
|
||||
start_date = date.today()
|
||||
if not self.expiry_date and self.product_id.expirable_ppe:
|
||||
res["expiry_date"] = start_date + _intervalTypes[
|
||||
self.product_id.ppe_interval_type
|
||||
](self.product_id.ppe_duration)
|
||||
return res
|
||||
|
||||
def validate_allocation(self):
|
||||
res = super().validate_allocation()
|
||||
self._check_dates()
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def cron_ppe_expiry_verification(self, date_ref=None):
|
||||
if not date_ref:
|
||||
date_ref = fields.Date.context_today(self)
|
||||
domain = []
|
||||
domain.extend([("expiry_date", "<", date_ref)])
|
||||
ppes_to_check_expiry = self.search(domain)
|
||||
for record in ppes_to_check_expiry:
|
||||
record.state = "expired"
|
||||
|
||||
def _check_dates(self):
|
||||
for record in self:
|
||||
if record.expire_ppe:
|
||||
start_date = record.start_date if record.start_date else date.today()
|
||||
if record.expiry_date < start_date:
|
||||
raise ValidationError(
|
||||
_("End date cannot occur earlier than start date.")
|
||||
)
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
# Copyright 2021 Creu Blanca
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class HrPersonalEquipmentRequest(models.Model):
|
||||
|
||||
_inherit = "hr.personal.equipment.request"
|
||||
|
||||
contains_ppe = fields.Boolean(compute="_compute_contains_ppe")
|
||||
|
||||
def _compute_contains_ppe(self):
|
||||
for rec in self:
|
||||
contains_ppe = False
|
||||
for line in rec.line_ids:
|
||||
if line.is_ppe:
|
||||
contains_ppe = True
|
||||
break
|
||||
rec.contains_ppe = contains_ppe
|
||||
|
||||
def action_view_ppe_report(self):
|
||||
report = self.env["ir.actions.report"]._get_report_from_name(
|
||||
"hr_employee_ppe.hr_employee_ppe_report_template"
|
||||
)
|
||||
return report.report_action(self)
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
# Copyright 2020 Escodoo
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
|
||||
_name = "product.template"
|
||||
_inherit = ["product.template"]
|
||||
|
||||
is_ppe = fields.Boolean(default=False)
|
||||
indications = fields.Text(
|
||||
help="Situations in which the employee should use this equipment. Only for ppe",
|
||||
)
|
||||
expirable_ppe = fields.Boolean(
|
||||
help="Select this option if the PPE has expiry date.", default=False
|
||||
)
|
||||
ppe_duration = fields.Integer(string="PPE duration")
|
||||
ppe_interval_type = fields.Selection(
|
||||
[
|
||||
("minutes", "Minutes"),
|
||||
("hours", "Hours"),
|
||||
("days", "Days"),
|
||||
("weeks", "Weeks"),
|
||||
("months", "Months"),
|
||||
],
|
||||
string="Interval Unit",
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue