diff --git a/pms_housekeeping/data/cron_jobs.xml b/pms_housekeeping/data/cron_jobs.xml index 2abe2f446b..b3f2f09708 100644 --- a/pms_housekeeping/data/cron_jobs.xml +++ b/pms_housekeeping/data/cron_jobs.xml @@ -10,7 +10,10 @@ code - + model.generate_task_properties() diff --git a/pms_housekeeping/models/pms_housekeeping_task.py b/pms_housekeeping/models/pms_housekeeping_task.py index 0f913ef107..0b646491d4 100644 --- a/pms_housekeeping/models/pms_housekeeping_task.py +++ b/pms_housekeeping/models/pms_housekeeping_task.py @@ -245,18 +245,18 @@ def _compute_priority(self): else: rec.priority = False - @api.depends('room_id') + @api.depends("room_id") def _compute_allowed_housekeeper_ids(self): for rec in self: - domain = [('job_id.name', '=', 'Housekeeper')] + domain = [("job_id.name", "=", "Housekeeper")] if rec.room_id: domain = [ - ('job_id.name', '=', 'Housekeeper'), - '|', - ('property_ids', 'in', rec.room_id.pms_property_id.ids), - ('property_ids', '=', False), + ("job_id.name", "=", "Housekeeper"), + "|", + ("property_ids", "in", rec.room_id.pms_property_id.ids), + ("property_ids", "=", False), ] - rec.allowed_housekeeper_ids = self.env['hr.employee'].search(domain).ids + rec.allowed_housekeeper_ids = self.env["hr.employee"].search(domain).ids @api.model def create(self, vals): diff --git a/pms_housekeeping/models/pms_housekeeping_task_type.py b/pms_housekeeping/models/pms_housekeeping_task_type.py index 0d3c3ca511..d7a998b93f 100644 --- a/pms_housekeeping/models/pms_housekeeping_task_type.py +++ b/pms_housekeeping/models/pms_housekeeping_task_type.py @@ -47,7 +47,6 @@ class PmsHouseKeepingTaskType(models.Model): string="Properties", ) - @api.constrains("is_overnight", "days_after_clean_overnight") def _check_days_after_clean_overnight(self): for record in self: @@ -77,7 +76,7 @@ def _check_housekeeper_ids(self): for record in self: if record.housekeeper_ids: for employee in record.housekeeper_ids: - if employee.job_id.name != 'Housekeeper': + if employee.job_id.name != "Housekeeper": raise ValidationError( _("The job position should be Housekeeper.") ) diff --git a/pms_housekeeping/tests/test_pms_housekeeping_task.py b/pms_housekeeping/tests/test_pms_housekeeping_task.py index 7647b07b93..d99e28510d 100644 --- a/pms_housekeeping/tests/test_pms_housekeeping_task.py +++ b/pms_housekeeping/tests/test_pms_housekeeping_task.py @@ -464,9 +464,7 @@ def test_no_create_grandchild_task(self): } ) # ACT & ASSERT - with self.assertRaises( - ValidationError, msg="Grandchild task shouldn´t exist." - ): + with self.assertRaises(ValidationError, msg="Grandchild task shouldn´t exist."): self.env["pms.housekeeping.task"].create( { "name": "Grandchild Task", @@ -543,56 +541,57 @@ def test_create_task_with_housekeeper(self): } ) - #ASSERT + # ASSERT self.assertTrue(self.task, "Housekeeping task should be created") def test_task_housekeeper_room_inconsistency(self): - # ARRANGE - self.pms_property2 = self.env["pms.property"].create( - { - "name": "Property 2", - "company_id": self.company1.id, - "default_pricelist_id": self.pricelist1.id, - } - ) - self.room2 = self.env["pms.room"].create( - { - "name": "Room 202", - "pms_property_id": self.pms_property2.id, - "room_type_id": self.room_type1.id, - } - ) - self.employee = self.env["hr.employee"].create( - { - "name": "Test Employee", - "company_id": self.company1.id, - "job_id": self.env.ref("pms_housekeeping.housekeeping_job_id").id, - "property_ids": [(6, 0, [self.pms_property1.id])], - } - ) - # create task type - self.task_type = self.env["pms.housekeeping.task.type"].create( + # ARRANGE + self.pms_property2 = self.env["pms.property"].create( + { + "name": "Property 2", + "company_id": self.company1.id, + "default_pricelist_id": self.pricelist1.id, + } + ) + self.room2 = self.env["pms.room"].create( + { + "name": "Room 202", + "pms_property_id": self.pms_property2.id, + "room_type_id": self.room_type1.id, + } + ) + self.employee = self.env["hr.employee"].create( + { + "name": "Test Employee", + "company_id": self.company1.id, + "job_id": self.env.ref("pms_housekeeping.housekeeping_job_id").id, + "property_ids": [(6, 0, [self.pms_property1.id])], + } + ) + # create task type + self.task_type = self.env["pms.housekeeping.task.type"].create( + { + "name": "Task Type 1", + "is_checkout": True, + } + ) + + # ACT & ASSERT + with self.assertRaises( + ValidationError, + msg="The room and housekeeper should belong to the same property.", + ): + self.env["pms.housekeeping.task"].create( { - "name": "Task Type 1", - "is_checkout": True, + "name": "Task", + "room_id": self.room2.id, + "task_type_id": self.task_type.id, + "task_date": datetime.today(), + "housekeeper_ids": [(6, 0, [self.employee.id])], } ) - # ACT & ASSERT - with self.assertRaises( - ValidationError, msg="The room and housekeeper should belong to the same property." - ): - self.env["pms.housekeeping.task"].create( - { - "name": "Task", - "room_id": self.room2.id, - "task_type_id": self.task_type.id, - "task_date": datetime.today(), - "housekeeper_ids": [(6, 0, [self.employee.id])], - } - ) - def test_task_housekeeper_room_consistency(self): # ARRANGE self.employee = self.env["hr.employee"].create( diff --git a/pms_housekeeping/tests/test_pms_housekeeping_task_type.py b/pms_housekeeping/tests/test_pms_housekeeping_task_type.py index 246a3dfd19..a905c2c772 100644 --- a/pms_housekeeping/tests/test_pms_housekeeping_task_type.py +++ b/pms_housekeeping/tests/test_pms_housekeeping_task_type.py @@ -1,6 +1,7 @@ -from .common import TestPms from odoo.exceptions import ValidationError +from .common import TestPms + class TestPmsHousekeepingTask(TestPms): def setUp(self): diff --git a/pms_housekeeping/tests/test_pms_hr_employee.py b/pms_housekeeping/tests/test_pms_hr_employee.py index 8c6a98ecc7..4fa21130ff 100644 --- a/pms_housekeeping/tests/test_pms_hr_employee.py +++ b/pms_housekeeping/tests/test_pms_hr_employee.py @@ -1,4 +1,5 @@ from odoo.exceptions import ValidationError + from .common import TestPms @@ -54,7 +55,8 @@ def test_employee_pre_assigned_room_consistent_with_property(self): # ASSERT self.assertTrue( - self.hr_employee.pre_assigned_room_ids, "Pre assigned room is not consistent with property" + self.hr_employee.pre_assigned_room_ids, + "Pre assigned room is not consistent with property", ) def test_employee_pre_assigned_room_consistent_without_properties(self): @@ -72,7 +74,8 @@ def test_employee_pre_assigned_room_consistent_without_properties(self): # ASSERT self.assertTrue( - self.hr_employee.pre_assigned_room_ids, "Pre assigned room is not consistent without properties" + self.hr_employee.pre_assigned_room_ids, + "Pre assigned room is not consistent without properties", ) def test_not_pre_assigned_room_no_housekeeper_employee(self): diff --git a/pms_housekeeping/views/pms_housekeeping_task_type_views.xml b/pms_housekeeping/views/pms_housekeeping_task_type_views.xml index 16c9624b52..799eebb77a 100644 --- a/pms_housekeeping/views/pms_housekeeping_task_type_views.xml +++ b/pms_housekeeping/views/pms_housekeeping_task_type_views.xml @@ -59,10 +59,7 @@ widget="many2many_tags" domain="[('job_id.name', '=', 'Housekeeper')]" /> - + diff --git a/pms_housekeeping/views/pms_housekeeping_task_views.xml b/pms_housekeeping/views/pms_housekeeping_task_views.xml index 99c5a45304..15e6efc1c9 100644 --- a/pms_housekeeping/views/pms_housekeeping_task_views.xml +++ b/pms_housekeeping/views/pms_housekeeping_task_views.xml @@ -78,7 +78,7 @@ widget="many2many_tags" domain="[('id', 'in', allowed_housekeeper_ids)]" /> - +