mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[UPD]pms_hr_property: update structure DB
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
"name": "PMS Hr Property",
|
"name": "PMS Hr Property",
|
||||||
"summary": """
|
"summary": """
|
||||||
Adds to the employee the property on which he works.""",
|
Adds to the employee the property on which he works.""",
|
||||||
"version": "14.0.1.0.0",
|
"version": "14.0.2.0.0",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"author": "OsoTranquilo,Odoo Community Association (OCA)",
|
"author": "OsoTranquilo,Odoo Community Association (OCA)",
|
||||||
"website": "https://github.com/OCA/pms",
|
"website": "https://github.com/OCA/pms",
|
||||||
|
|||||||
24
pms_hr_property/migrations/14.0.2.0.0/pre_migration.py
Normal file
24
pms_hr_property/migrations/14.0.2.0.0/pre_migration.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
from openupgradelib import openupgrade
|
||||||
|
|
||||||
|
|
||||||
|
@openupgrade.migrate()
|
||||||
|
def migrate(env, version):
|
||||||
|
openupgrade.logged_query(
|
||||||
|
env.cr,
|
||||||
|
"""
|
||||||
|
UPDATE pms_ rl
|
||||||
|
SET sale_channel_id = r.sale_channel_origin_id
|
||||||
|
FROM pms_reservation r
|
||||||
|
WHERE r.id = rl.reservation_id
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
|
||||||
|
openupgrade.logged_query(
|
||||||
|
env.cr,
|
||||||
|
"""
|
||||||
|
UPDATE pms_service ser
|
||||||
|
SET sale_channel_origin_id = fol.sale_channel_origin_id
|
||||||
|
FROM pms_folio fol
|
||||||
|
WHERE fol.id = ser.folio_id
|
||||||
|
""",
|
||||||
|
)
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
from . import hr_employee
|
from . import hr_employee
|
||||||
from . import pms_hr_property
|
from . import pms_property
|
||||||
|
|||||||
@@ -9,4 +9,10 @@ class HrEmployeeBase(models.AbstractModel):
|
|||||||
|
|
||||||
_inherit = "hr.employee.base"
|
_inherit = "hr.employee.base"
|
||||||
|
|
||||||
property_ids = fields.Many2many("pms.property", string="Workplaces asigned")
|
property_ids = fields.Many2many(
|
||||||
|
comodel_name="pms.property",
|
||||||
|
string="Workplaces asigned",
|
||||||
|
relation="hr_employee_pms_property_rel",
|
||||||
|
column1="hr_employee_id",
|
||||||
|
column2="pms_property_id",
|
||||||
|
)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Copyright 2024 Irlui Ramírez
|
# Copyright 2024 Irlui Ramírez
|
||||||
# From Consultores Hoteleros Integrales (ALDA Hotels) - 2024
|
# From Consultores Hoteleros Integrales (ALDA Hotels) - 2024
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
from odoo import api, fields, models
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
class PmsHrProperty(models.Model):
|
class PmsHrProperty(models.Model):
|
||||||
@@ -11,13 +11,7 @@ class PmsHrProperty(models.Model):
|
|||||||
employee_ids = fields.Many2many(
|
employee_ids = fields.Many2many(
|
||||||
comodel_name="hr.employee",
|
comodel_name="hr.employee",
|
||||||
string="Assigned Employees",
|
string="Assigned Employees",
|
||||||
compute="_compute_employee_ids",
|
relation="hr_employee_pms_property_rel",
|
||||||
|
column1="pms_property_id",
|
||||||
|
column2="hr_employee_id",
|
||||||
)
|
)
|
||||||
|
|
||||||
@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
|
|
||||||
Reference in New Issue
Block a user