mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms_hr_property: add list of employees on the property card
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
from . import hr_employee
|
||||
from . import pms_hr_property
|
||||
|
||||
35
pms_hr_property/models/pms_hr_property.py
Normal file
35
pms_hr_property/models/pms_hr_property.py
Normal file
@@ -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
|
||||
@@ -1,4 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
22
pms_hr_property/views/pms_hr_property_view.xml
Normal file
22
pms_hr_property/views/pms_hr_property_view.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="pms_hr_property_form" model="ir.ui.view">
|
||||
<field name="name">pms.hr.property.form</field>
|
||||
<field name="model">pms.property</field>
|
||||
<field name="inherit_id" ref="pms.pms_property_views_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//notebook" position="inside">
|
||||
<page name="team_alda2" string="Regional Staff">
|
||||
<field name="employee_ids">
|
||||
<tree string="Employees">
|
||||
<field name="job_id" />
|
||||
<field name="name" />
|
||||
<field name="work_email" />
|
||||
<field name="work_phone" />
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user