diff --git a/pms_hr_property/__manifest__.py b/pms_hr_property/__manifest__.py index 35d8ad8ae..842831c9a 100644 --- a/pms_hr_property/__manifest__.py +++ b/pms_hr_property/__manifest__.py @@ -14,8 +14,6 @@ "hr", "pms", ], - "data": [ - "views/hr_employee_view.xml", - ], + "data": ["views/hr_employee_view.xml", "views/pms_hr_property_view.xml"], "installable": True, } diff --git a/pms_hr_property/models/__init__.py b/pms_hr_property/models/__init__.py index e11a62f98..8a3d3ba90 100644 --- a/pms_hr_property/models/__init__.py +++ b/pms_hr_property/models/__init__.py @@ -1 +1,2 @@ from . import hr_employee +from . import pms_hr_property diff --git a/pms_hr_property/models/pms_hr_property.py b/pms_hr_property/models/pms_hr_property.py new file mode 100644 index 000000000..7e74bcb88 --- /dev/null +++ b/pms_hr_property/models/pms_hr_property.py @@ -0,0 +1,35 @@ +# Copyright 2024 OsoTranquilo - José Luis Algara +# Copyright 2024 Irlui Ramírez +# From Consultores Hoteleros Integrales (ALDA Hotels) - 2024 +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import api, fields, models + + +class PmsHrProperty(models.Model): + _inherit = "pms.property" + + employee_ids = fields.Many2many( + comodel_name="hr.employee", + string="Assigned Employees", + compute="_compute_employee_ids", + ) + + # @api.depends('employee_ids') + # def _compute_employee_ids(self): + # specific_job_names = ['Regional Manager','Revenue Manager', 'TAZ', 'TMZ'] + # for record in self: + # specific_jobs = self.env['hr.job'].search([('name', 'in', specific_job_names)]) + # specific_job_ids = specific_jobs.ids + # employees = self.env['hr.employee'].search([ + # ('property_ids', 'in', record.id), + # ('job_id', 'in', specific_job_ids) + # ]) + # record.employee_ids = employees + + @api.depends("employee_ids") + def _compute_employee_ids(self): + for record in self: + employees = self.env["hr.employee"].search( + [("property_ids", "in", record.id)] + ) + record.employee_ids = employees diff --git a/pms_hr_property/static/description/index.html b/pms_hr_property/static/description/index.html index 06f6842f7..6fa573edb 100644 --- a/pms_hr_property/static/description/index.html +++ b/pms_hr_property/static/description/index.html @@ -1,4 +1,3 @@ -
diff --git a/pms_hr_property/views/pms_hr_property_view.xml b/pms_hr_property/views/pms_hr_property_view.xml new file mode 100644 index 000000000..64ce24776 --- /dev/null +++ b/pms_hr_property/views/pms_hr_property_view.xml @@ -0,0 +1,22 @@ + +