[WIP]14.0-pms_housekeeping: housekeeping task views

This commit is contained in:
braisab
2024-02-12 18:45:46 +01:00
committed by Darío Lodeiros
parent 6f8a2e5653
commit 7753bacd5d
11 changed files with 187 additions and 26 deletions

View File

@@ -21,6 +21,7 @@
"views/pms_housekeeping_task_type_views.xml",
"views/pms_housekeeping_views.xml",
"views/pms_housekeeping_task_views.xml",
"views/pms_room_views.xml",
],
"installable": True,
}

View File

@@ -3,4 +3,10 @@
<field name="name">Housekeeper</field>
<field name="state">open</field>
</record>
<record id="cancellation_type_dont_disturb" model="pms.housekeeping.cancellation.type">
<field name="name">Don´t disturb</field>
</record>
<record id="cancellation_type_promotion" model="pms.housekeeping.cancellation.type">
<field name="name">Promotion</field>
</record>
</odoo>

View File

@@ -4,3 +4,5 @@
from . import hr_employee
from . import pms_housekeeping_task_type
from . import pms_housekeeping_task
from . import pms_housekeeping_cancellation_type
from . import pms_room

View File

@@ -0,0 +1,8 @@
from odoo import fields, models, api
class PmsHousekeepingCancellationType(models.Model):
_name = 'pms.housekeeping.cancellation.type'
name = fields.Char(string="Name", required=True)
description = fields.Text(string="Description")

View File

@@ -1,4 +1,5 @@
from odoo import fields, models
from odoo import fields, models, api
from odoo.exceptions import ValidationError
class PmsHouseKeepingTask(models.Model):
@@ -17,10 +18,10 @@ class PmsHouseKeepingTask(models.Model):
required=True,
ondelete="restrict",
)
task_datetime = fields.Datetime(string="Date")
task_date = fields.Date(string="Date", required=True,)
state = fields.Selection(
selection=[
("holding", "On Holding"),
("pending", "Pending"),
("to_do", "To Do"),
("in_progress", "In Progress"),
("done", "Done"),
@@ -44,5 +45,70 @@ class PmsHouseKeepingTask(models.Model):
string="Parent Task",
help="Indicates that this task is a child of another task",
comodel_name="pms.housekeeping.task",
domain="[('id', '!=', id)]",
)
parent_state = fields.Char(
string="Parent State",
compute="_compute_parent_state",
)
cancellation_type_id = fields.Many2one(
comodel_name="pms.housekeeping.cancellation.type",
string="Cancellation Type",
ondelete="restrict",
)
is_today = fields.Boolean(
string="Is Today",
compute="_compute_is_today",
store=True,
readonly=False,
)
is_future = fields.Boolean(
string="Is Future",
compute="_compute_is_future",
)
@api.constrains("task_date")
def _check_task_date(self):
for rec in self:
if rec.task_date < fields.Date.today():
raise ValidationError("Task Date must be greater than or equal to today")
def action_cancel(self):
for rec in self:
rec.state = "cancel"
def action_to_do(self):
for rec in self:
rec.state = "to_do"
def action_done(self):
for rec in self:
rec.state = "done"
def action_in_progress(self):
for rec in self:
rec.state = "in_progress"
def action_pending(self):
for rec in self:
rec.state = "pending"
@api.depends("parent_id.state")
def _compute_parent_state(self):
for rec in self:
rec.parent_state = rec.parent_id.state if rec.parent_id else False
@api.depends("task_date")
def _compute_is_today(self):
for rec in self:
if rec.task_date:
rec.is_today = rec.task_date == fields.Date.today()
else:
rec.is_today = False
@api.depends("task_date")
def _compute_is_future(self):
for rec in self:
if rec.task_date:
rec.is_future = rec.task_date > fields.Date.today()
else:
rec.is_future = False

View File

@@ -12,8 +12,8 @@ class PmsHouseKeepingTaskType(models.Model):
is_checkin = fields.Boolean(string="Checkin")
is_checkout = fields.Boolean(string="Checkout")
priority = fields.Integer(string="Priority", default=0)
days_after_clean_overnight = fields.Integer(string="Days After Clean",)
days_after_clean_empty = fields.Integer(string="Days After Clean", )
days_after_clean_overnight = fields.Integer(string="Days After Clean Overnight",)
days_after_clean_empty = fields.Integer(string="Days After Clean Empty", )
housekeepers = fields.Many2many(
comodel_name="hr.employee",
relation="pms_housekeeping_task_type_hr_employee_rel",
@@ -22,13 +22,10 @@ class PmsHouseKeepingTaskType(models.Model):
string="Housekeepers",
domain="[('job_id.name', '=', 'Housekeeper')]",
)
parent_id = fields.Many2many(
parent_id = fields.Many2one(
string="Parent Task Type",
help="Indicates that this task type is a child of another task type",
comodel_name="pms.housekeeping.task.type",
relation="pms_housekeeping_task_type_rel",
column1="parent_task_type_id",
column2="child_task_type_id",
ondelete="restrict",
domain="[('id', '!=', id)]",
)
is_inspection = fields.Boolean(string="Inspection")

View File

@@ -0,0 +1,17 @@
from odoo import fields, models, api
class PmsRoom(models.Model):
_inherit = "pms.room"
housekeeping_state = fields.Selection(
selection=[
("dirty", "Dirty"),
("to_inspect", "To Inspect"),
("clean", "Clean"),
],
string="Housekeeping State",
required=True,
default="dirty",
)

View File

@@ -1,3 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
user_access_pms_housekeeping_task_type,user_access_pms_housekeeping_task_type,model_pms_housekeeping_task_type,pms.group_pms_user,1,1,1,1
user_access_pms_housekeeping_task,user_access_pms_housekeeping_task_,model_pms_housekeeping_task,pms.group_pms_user,1,1,1,1
user_access_pms_housekeeping_cancellation_type,user_access_pms_housekeeping_cancellation_type,model_pms_housekeeping_cancellation_type,pms.group_pms_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 user_access_pms_housekeeping_task_type user_access_pms_housekeeping_task_type model_pms_housekeeping_task_type pms.group_pms_user 1 1 1 1
3 user_access_pms_housekeeping_task user_access_pms_housekeeping_task_ model_pms_housekeeping_task pms.group_pms_user 1 1 1 1
4 user_access_pms_housekeeping_cancellation_type user_access_pms_housekeeping_cancellation_type model_pms_housekeeping_cancellation_type pms.group_pms_user 1 1 1 1

View File

@@ -8,8 +8,9 @@
<tree string="Housekeeping Task Type">
<field name="name"/>
<field name="is_automated"/>
<field name="is_inspection"/>
<field name="housekeepers" widget="many2many_tags" />
<field name="parent_id" widget="many2many_tags" />
<field name="parent_id" />
<field name="description" />
<field name="priority" attrs="{'invisible': [('is_automated', '==', False)]}"/>
<field name="is_overnight" attrs="{'invisible': [('is_automated', '==', False)]}"/>
@@ -28,18 +29,26 @@
<field name="arch" type="xml">
<form string="Housekeeping Task Type">
<group>
<field name="name"/>
<field name="is_automated"/>
<field name="housekeepers" widget="many2many_tags" />
<field name="parent_id" widget="many2many_tags" />
<field name="description" />
<field name="priority" attrs="{'invisible': [('is_automated', '==', False)]}"/>
<field name="is_overnight" attrs="{'invisible': [('is_automated', '==', False)]}"/>
<field name="is_empty" attrs="{'invisible': [('is_automated', '==', False)]}"/>
<field name="is_checkin" attrs="{'invisible': [('is_automated', '==', False)]}"/>
<field name="is_checkout" attrs="{'invisible': [('is_automated', '==', False)]}"/>
<field name="days_after_clean_overnight" attrs="{'invisible': [('is_automated', '==', False), ('is_overnight', '==', False)]}"/>
<field name="days_after_clean_empty" attrs="{'invisible': [('is_automated', '==', False), ('is_empty', '==', False)]}"/>
<group>
<field name="name"/>
<field name="is_automated"/>
<field name="is_inspection"/>
<field name="housekeepers" widget="many2many_tags" />
<field name="parent_id" />
<field name="description" />
</group>
<group attrs="{'invisible': [('is_automated', '==', False)]}">
<field name="priority" />
<field name="is_overnight" />
<field name="is_empty" />
<field name="is_checkin" />
<field name="is_checkout" />
<field name="days_after_clean_overnight" attrs="{'invisible': [('is_overnight', '==', False)]}"/>
<field name="days_after_clean_empty" attrs="{'invisible': [('is_empty', '==', False)]}"/>
</group>
</group>
</form>
</field>

View File

@@ -24,22 +24,63 @@
<field name="arch" type="xml">
<form string="Housekeeping Task">
<header>
<field name="state" widget="statusbar" />
<button
name="action_pending"
string="Mark as Pending"
class="oe_highlight"
type="object"
attrs="{'invisible': [('state', '!=', 'cancel'), ('is_today', '=', True)]}"
/>
<button
name="action_to_do"
string="Mark as To Do"
class="oe_highlight"
type="object"
attrs="{'invisible':[('state' ,'=', 'to_do'), ('is_today', '=', False), ('is_future', '=', True)]}"
/>
<button
name="action_in_progress"
string="Mark as In Progress"
class="oe_highlight"
type="object"
attrs="{'invisible':[('state','in', ('done', 'in_progress', 'cancel', 'pending'))]}"
/>
<button
name="action_done"
string="Mark as Done"
class="oe_highlight"
type="object"
attrs="{'invisible':[('state' ,'in', ('done', 'to_do', 'cancel', 'pending'))]}"
/>
<button
name="action_cancel"
string="Cancel Task"
type="object"
attrs="{'invisible':[('state','in', ('done', 'in_progress', 'cancel'))]}"
/>
<field name="state" widget="statusbar"/>
</header>
<group class="col-6">
<field name="name" />
<field name="room_id" />
<field name="task_type_id" />
<field name="parent_state" />
<field name="is_today" />
<field name="is_future" />
</group>
<group class="col-6">
<field name="task_datetime" />
<field name="task_date" />
<field name="priority" />
<field name="employee_ids" widget="many2many_tags"/>
</group>
<group class="col-12">
<field name="parent_id" widget="many2many_tags"/>
<field name="parent_id"/>
<field name="cleaning_comments" />
</group>
<group class="col-12">
<field name="cancellation_type_id" attrs="{'invisible': [('state', '!=', 'cancel')]}"/>
</group>
</form>
</field>
</record>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="pms_housekeeping_room" model="ir.ui.view">
<field name="model">pms.room</field>
<field name="inherit_id" ref="pms.pms_room_view_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='short_name']" position="after">
<field name="housekeeping_state" />
</xpath>
</field>
</record>
</odoo>