mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[FIX] pms: fix precommit
This commit is contained in:
committed by
Darío Lodeiros
parent
f403daf78f
commit
e26bf69813
@@ -10,7 +10,10 @@
|
|||||||
<field name="doall" eval="False" />
|
<field name="doall" eval="False" />
|
||||||
<field name="state">code</field>
|
<field name="state">code</field>
|
||||||
<field name="model_id" ref="model_pms_housekeeping_task" />
|
<field name="model_id" ref="model_pms_housekeeping_task" />
|
||||||
<field name="nextcall" eval="(DateTime.now() + timedelta(days=1)).strftime('%Y-%m-%d 05:00:00')" />
|
<field
|
||||||
|
name="nextcall"
|
||||||
|
eval="(DateTime.now() + timedelta(days=1)).strftime('%Y-%m-%d 05:00:00')"
|
||||||
|
/>
|
||||||
<field name="code">model.generate_task_properties()</field>
|
<field name="code">model.generate_task_properties()</field>
|
||||||
</record>
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -245,18 +245,18 @@ class PmsHouseKeepingTask(models.Model):
|
|||||||
else:
|
else:
|
||||||
rec.priority = False
|
rec.priority = False
|
||||||
|
|
||||||
@api.depends('room_id')
|
@api.depends("room_id")
|
||||||
def _compute_allowed_housekeeper_ids(self):
|
def _compute_allowed_housekeeper_ids(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
domain = [('job_id.name', '=', 'Housekeeper')]
|
domain = [("job_id.name", "=", "Housekeeper")]
|
||||||
if rec.room_id:
|
if rec.room_id:
|
||||||
domain = [
|
domain = [
|
||||||
('job_id.name', '=', 'Housekeeper'),
|
("job_id.name", "=", "Housekeeper"),
|
||||||
'|',
|
"|",
|
||||||
('property_ids', 'in', rec.room_id.pms_property_id.ids),
|
("property_ids", "in", rec.room_id.pms_property_id.ids),
|
||||||
('property_ids', '=', False),
|
("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
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ class PmsHouseKeepingTaskType(models.Model):
|
|||||||
string="Properties",
|
string="Properties",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@api.constrains("is_overnight", "days_after_clean_overnight")
|
@api.constrains("is_overnight", "days_after_clean_overnight")
|
||||||
def _check_days_after_clean_overnight(self):
|
def _check_days_after_clean_overnight(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
@@ -77,7 +76,7 @@ class PmsHouseKeepingTaskType(models.Model):
|
|||||||
for record in self:
|
for record in self:
|
||||||
if record.housekeeper_ids:
|
if record.housekeeper_ids:
|
||||||
for employee in record.housekeeper_ids:
|
for employee in record.housekeeper_ids:
|
||||||
if employee.job_id.name != 'Housekeeper':
|
if employee.job_id.name != "Housekeeper":
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
_("The job position should be Housekeeper.")
|
_("The job position should be Housekeeper.")
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -464,9 +464,7 @@ class TestPmsHousekeepingTask(TestPms):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
# ACT & ASSERT
|
# ACT & ASSERT
|
||||||
with self.assertRaises(
|
with self.assertRaises(ValidationError, msg="Grandchild task shouldn´t exist."):
|
||||||
ValidationError, msg="Grandchild task shouldn´t exist."
|
|
||||||
):
|
|
||||||
self.env["pms.housekeeping.task"].create(
|
self.env["pms.housekeeping.task"].create(
|
||||||
{
|
{
|
||||||
"name": "Grandchild Task",
|
"name": "Grandchild Task",
|
||||||
@@ -543,7 +541,7 @@ class TestPmsHousekeepingTask(TestPms):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
#ASSERT
|
# ASSERT
|
||||||
self.assertTrue(self.task, "Housekeeping task should be created")
|
self.assertTrue(self.task, "Housekeeping task should be created")
|
||||||
|
|
||||||
def test_task_housekeeper_room_inconsistency(self):
|
def test_task_housekeeper_room_inconsistency(self):
|
||||||
@@ -581,7 +579,8 @@ class TestPmsHousekeepingTask(TestPms):
|
|||||||
|
|
||||||
# ACT & ASSERT
|
# ACT & ASSERT
|
||||||
with self.assertRaises(
|
with self.assertRaises(
|
||||||
ValidationError, msg="The room and housekeeper should belong to the same property."
|
ValidationError,
|
||||||
|
msg="The room and housekeeper should belong to the same property.",
|
||||||
):
|
):
|
||||||
self.env["pms.housekeeping.task"].create(
|
self.env["pms.housekeeping.task"].create(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from .common import TestPms
|
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
from .common import TestPms
|
||||||
|
|
||||||
|
|
||||||
class TestPmsHousekeepingTask(TestPms):
|
class TestPmsHousekeepingTask(TestPms):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
from .common import TestPms
|
from .common import TestPms
|
||||||
|
|
||||||
|
|
||||||
@@ -54,7 +55,8 @@ class TestPmsHrEmployee(TestPms):
|
|||||||
|
|
||||||
# ASSERT
|
# ASSERT
|
||||||
self.assertTrue(
|
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):
|
def test_employee_pre_assigned_room_consistent_without_properties(self):
|
||||||
@@ -72,7 +74,8 @@ class TestPmsHrEmployee(TestPms):
|
|||||||
|
|
||||||
# ASSERT
|
# ASSERT
|
||||||
self.assertTrue(
|
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):
|
def test_not_pre_assigned_room_no_housekeeper_employee(self):
|
||||||
|
|||||||
@@ -59,10 +59,7 @@
|
|||||||
widget="many2many_tags"
|
widget="many2many_tags"
|
||||||
domain="[('job_id.name', '=', 'Housekeeper')]"
|
domain="[('job_id.name', '=', 'Housekeeper')]"
|
||||||
/>
|
/>
|
||||||
<field
|
<field name="pms_property_ids" widget="many2many_tags" />
|
||||||
name="pms_property_ids"
|
|
||||||
widget="many2many_tags"
|
|
||||||
/>
|
|
||||||
<field name="parent_id" />
|
<field name="parent_id" />
|
||||||
<field name="description" />
|
<field name="description" />
|
||||||
</group>
|
</group>
|
||||||
|
|||||||
@@ -78,7 +78,7 @@
|
|||||||
widget="many2many_tags"
|
widget="many2many_tags"
|
||||||
domain="[('id', 'in', allowed_housekeeper_ids)]"
|
domain="[('id', 'in', allowed_housekeeper_ids)]"
|
||||||
/>
|
/>
|
||||||
<field name="allowed_housekeeper_ids" invisible="1"/>
|
<field name="allowed_housekeeper_ids" invisible="1" />
|
||||||
</group>
|
</group>
|
||||||
<group class="col-12">
|
<group class="col-12">
|
||||||
<field name="parent_id" />
|
<field name="parent_id" />
|
||||||
|
|||||||
Reference in New Issue
Block a user