[IMP]14.0-pms_housekeeping: housekeeping task

This commit is contained in:
braisab
2024-02-13 13:28:47 +01:00
committed by Darío Lodeiros
parent 7753bacd5d
commit ade0673c81
12 changed files with 366 additions and 199 deletions

View File

@@ -7,7 +7,7 @@ Housekeeping
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:de773807356222adab5ee772d075d86a64a8a09828b1e137748c9562380fe750
!! source digest: sha256:4807e347dd2088e7cfafc8201f1105b6162c3f0793e9b87f570b6ba38c1756e7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png

View File

@@ -3,7 +3,10 @@
<field name="name">Housekeeper</field>
<field name="state">open</field>
</record>
<record id="cancellation_type_dont_disturb" model="pms.housekeeping.cancellation.type">
<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">

View File

@@ -1,7 +1,7 @@
# Copyright 2020 Jose Luis Algara (Alda Hotels <https://www.aldahotels.es>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
from odoo import api, fields, models
class HrEmployee(models.Model):
@@ -12,3 +12,10 @@ class HrEmployee(models.Model):
string="Pre Assigned Rooms",
help="Rooms pre assigned to this employee",
)
job_name = fields.Char(string="Job Name", compute="_compute_job_name")
@api.depends("job_id")
def _compute_job_name(self):
for record in self:
record.job_name = record.job_id.name

View File

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

View File

@@ -1,4 +1,4 @@
from odoo import fields, models, api
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
@@ -18,7 +18,10 @@ class PmsHouseKeepingTask(models.Model):
required=True,
ondelete="restrict",
)
task_date = fields.Date(string="Date", required=True,)
task_date = fields.Date(
string="Date",
required=True,
)
state = fields.Selection(
selection=[
("pending", "Pending"),
@@ -29,9 +32,15 @@ class PmsHouseKeepingTask(models.Model):
],
string="State",
required=True,
default="to_do",
default="pending",
)
priority = fields.Integer(
string="Priority",
default=0,
computed="_compute_priority",
store=True,
readonly=False,
)
priority = fields.Integer(string="Priority", default=0)
cleaning_comments = fields.Text(string="Cleaning Comments")
employee_ids = fields.Many2many(
comodel_name="hr.employee",
@@ -40,6 +49,9 @@ class PmsHouseKeepingTask(models.Model):
column2="employee_id",
string="Employees",
domain="[('job_id.name', '=', 'Housekeeper')]",
compute="_compute_employee_ids",
store=True,
readonly=False,
)
parent_id = fields.Many2one(
string="Parent Task",
@@ -51,27 +63,45 @@ class PmsHouseKeepingTask(models.Model):
string="Parent State",
compute="_compute_parent_state",
)
child_ids = fields.One2many(
string="Child Tasks",
help="Indicates that this task has child tasks",
comodel_name="pms.housekeeping.task",
inverse_name="parent_id",
)
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,
pending_allowed = fields.Boolean(
string="Is pending allowed",
compute="_compute_pending_allowed",
)
is_future = fields.Boolean(
string="Is Future",
compute="_compute_is_future",
to_do_allowed = fields.Boolean(
string="Is To Do Allowed",
compute="_compute_to_do_allowed",
)
cancel_allowed = fields.Boolean(
string="Is Cancel Allowed",
compute="_compute_cancel_allowed",
)
in_progress_allowed = fields.Boolean(
string="Is In Progress Allowed",
compute="_compute_in_progress_allowed",
)
done_allowed = fields.Boolean(
string="Is Done Allowed",
compute="_compute_done_allowed",
)
@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")
raise ValidationError(
_("Task Date must be greater than or equal to today")
)
def action_cancel(self):
for rec in self:
@@ -80,35 +110,128 @@ class PmsHouseKeepingTask(models.Model):
def action_to_do(self):
for rec in self:
rec.state = "to_do"
rec.cancellation_type_id = False
def action_done(self):
for rec in self:
rec.state = "done"
rec.cancellation_type_id = False
def action_in_progress(self):
for rec in self:
rec.state = "in_progress"
rec.cancellation_type_id = False
def action_pending(self):
for rec in self:
rec.state = "pending"
rec.cancellation_type_id = False
@api.onchange("state")
def _onchange_state(self):
for rec in self:
if rec.state == "cancel":
rec.child_ids.state = "cancel"
elif rec.state != "done":
rec.child_ids.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):
@api.depends("task_date", "state")
def _compute_pending_allowed(self):
for rec in self:
if rec.task_date:
rec.is_today = rec.task_date == fields.Date.today()
if (
rec.task_date
and rec.state == "cancel"
and (
rec.task_date > fields.Date.today()
or (
(rec.parent_state and rec.parent_state != "done")
or not rec.parent_state
)
)
):
rec.pending_allowed = True
else:
rec.is_today = False
@api.depends("task_date")
def _compute_is_future(self):
rec.pending_allowed = False
@api.depends("task_date", "state")
def _compute_to_do_allowed(self):
for rec in self:
if rec.task_date:
rec.is_future = rec.task_date > fields.Date.today()
if (
rec.task_date
and rec.task_date == fields.Date.today()
and rec.state in ("cancel", "pending", "done", "in_progress")
and (
(rec.parent_state and rec.parent_state == "done")
or not rec.parent_state
)
):
rec.to_do_allowed = True
else:
rec.is_future = False
rec.to_do_allowed = False
@api.depends("state")
def _compute_cancel_allowed(self):
for rec in self:
if rec.state in ("to_do", "pending"):
rec.cancel_allowed = True
else:
rec.cancel_allowed = False
@api.depends("state")
def _compute_in_progress_allowed(self):
for rec in self:
if rec.state == "to_do":
rec.in_progress_allowed = True
else:
rec.in_progress_allowed = False
@api.depends("state")
def _compute_done_allowed(self):
for rec in self:
if rec.state == "in_progress":
rec.done_allowed = True
else:
rec.done_allowed = False
@api.depends("room_id", "task_type_id")
def _compute_employee_ids(self):
for rec in self:
employee_ids = False
if rec.room_id or rec.task_type_id:
employee_ids = self.env["hr.employee"].search(
[("pre_assigned_room_ids", "in", [rec.room_id.id])]
)
if not employee_ids:
employee_ids = (
self.env["pms.housekeeping.task.type"]
.search([("id", "=", rec.task_type_id.id)])
.housekeeper_ids
)
rec.employee_ids = employee_ids
@api.depends("task_type_id")
def _compute_priority(self):
for rec in self:
if rec.task_type_id:
rec.priority = rec.task_type_id.priority
else:
rec.priority = False
@api.model
def create(self, vals):
task_type_id = vals.get("task_type_id")
pms_housekeeping_task_type = self.env["pms.housekeeping.task.type"].browse(
task_type_id
)
room_id = vals.get("room_id")
pms_room = self.env["pms.room"].browse(room_id)
pms_room.housekeeping_state = (
"to_inspect" if pms_housekeeping_task_type.is_inspection else "dirty"
)
return super(PmsHouseKeepingTask, self).create(vals)

View File

@@ -12,9 +12,13 @@ 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 Overnight",)
days_after_clean_empty = fields.Integer(string="Days After Clean Empty", )
housekeepers = fields.Many2many(
days_after_clean_overnight = fields.Integer(
string="Days After Clean Overnight",
)
days_after_clean_empty = fields.Integer(
string="Days After Clean Empty",
)
housekeeper_ids = fields.Many2many(
comodel_name="hr.employee",
relation="pms_housekeeping_task_type_hr_employee_rel",
column1="task_type_id",

View File

@@ -1,4 +1,4 @@
from odoo import fields, models, api
from odoo import fields, models
class PmsRoom(models.Model):
@@ -14,4 +14,3 @@ class PmsRoom(models.Model):
required=True,
default="dirty",
)

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:de773807356222adab5ee772d075d86a64a8a09828b1e137748c9562380fe750
!! source digest: sha256:4807e347dd2088e7cfafc8201f1105b6162c3f0793e9b87f570b6ba38c1756e7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/pms/tree/14.0/pms_housekeeping"><img alt="OCA/pms" src="https://img.shields.io/badge/github-OCA%2Fpms-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/pms-14-0/pms-14-0-pms_housekeeping"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/pms&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds housekeeping feature to property management system (PMS).</p>

View File

@@ -5,7 +5,12 @@
<field name="inherit_id" ref="hr.view_employee_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='work_location']" position="after">
<field name="pre_assigned_room_ids" widget="many2many_tags" />
<field
name="pre_assigned_room_ids"
widget="many2many_tags"
attrs="{'invisible': [('job_name', '!=', 'Housekeeper')]}"
/>
<field name="job_name" invisible="1" />
</xpath>
</field>
</record>

View File

@@ -1,57 +1,82 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>
<record id="view_pms_housekeeping_task_type_tree" model="ir.ui.view">
<field name="name">pms.housekeeping.task.type.tree</field>
<field name="model">pms.housekeeping.task.type</field>
<field name="arch" type="xml">
<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" />
<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)]}"/>
</tree>
</field>
</record>
<record id="view_pms_housekeeping_task_type_form" model="ir.ui.view">
<field name="name">pms.housekeeping.task.type.form</field>
<field name="model">pms.housekeeping.task.type</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Housekeeping Task Type">
<record id="view_pms_housekeeping_task_type_tree" model="ir.ui.view">
<field name="name">pms.housekeeping.task.type.tree</field>
<field name="model">pms.housekeeping.task.type</field>
<field name="arch" type="xml">
<tree name="Housekeeping Task Type">
<field name="name" />
<field name="is_automated" />
<field name="is_inspection" />
<field name="housekeeper_ids" 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)]}"
/>
<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)]}"
/>
</tree>
</field>
</record>
<record id="view_pms_housekeeping_task_type_form" model="ir.ui.view">
<field name="name">pms.housekeeping.task.type.form</field>
<field name="model">pms.housekeeping.task.type</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Housekeeping Task Type">
<group>
<group>
<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>
<field name="name" />
<field name="is_automated" />
<field name="is_inspection" />
<field name="housekeeper_ids" widget="many2many_tags" />
<field name="parent_id" />
<field name="description" />
</group>
</form>
</field>
</record>
</data>
<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>
</record>
</odoo>

View File

@@ -1,88 +1,91 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>
<record id="view_pms_housekeeping_task_tree" model="ir.ui.view">
<field name="name">pms.housekeeping.task.tree</field>
<field name="model">pms.housekeeping.task</field>
<field name="arch" type="xml">
<tree string="Housekeeping Task">
<record id="view_pms_housekeeping_task_tree" model="ir.ui.view">
<field name="name">pms.housekeeping.task.tree</field>
<field name="model">pms.housekeeping.task</field>
<field name="arch" type="xml">
<tree name="Housekeeping Task">
<field name="name" />
<field name="room_id" />
<field name="task_type_id" />
<field name="state" />
<field name="priority" />
<field name="cleaning_comments" />
<field name="employee_ids" />
<field name="parent_id" />
</tree>
</field>
</record>
<record id="view_pms_housekeeping_task_form" model="ir.ui.view">
<field name="name">pms.housekeeping.task.form</field>
<field name="model">pms.housekeeping.task</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Housekeeping Task">
<header>
<button
name="action_pending"
string="Mark as Pending"
class="oe_highlight"
type="object"
attrs="{'invisible': [('pending_allowed', '=', False)]}"
/>
<button
name="action_to_do"
string="Mark as To Do"
class="oe_highlight"
type="object"
attrs="{'invisible':[('to_do_allowed', '=', False)]}"
/>
<button
name="action_in_progress"
string="Mark as In Progress"
class="oe_highlight"
type="object"
attrs="{'invisible':[('in_progress_allowed', '=', False)]}"
/>
<button
name="action_done"
string="Mark as Done"
class="oe_highlight"
type="object"
attrs="{'invisible':[('done_allowed', '=', False)]}"
/>
<button
name="action_cancel"
string="Cancel Task"
type="object"
attrs="{'invisible':[('cancel_allowed', '=', False)]}"
/>
<field name="state" widget="statusbar" />
</header>
<group class="col-6">
<field name="name" />
<field name="room_id" />
<field name="task_type_id" />
<field name="state"/>
<field name="parent_state" invisible="1" />
<field name="pending_allowed" invisible="1" />
<field name="to_do_allowed" invisible="1" />
<field name="in_progress_allowed" invisible="1" />
<field name="done_allowed" invisible="1" />
<field name="cancel_allowed" invisible="1" />
</group>
<group class="col-6">
<field name="task_date" />
<field name="priority" />
<field name="cleaning_comments" />
<field name="employee_ids" />
<field name="employee_ids" widget="many2many_tags" />
</group>
<group class="col-12">
<field name="parent_id" />
</tree>
</field>
</record>
<record id="view_pms_housekeeping_task_form" model="ir.ui.view">
<field name="name">pms.housekeeping.task.form</field>
<field name="model">pms.housekeeping.task</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Housekeeping Task">
<header>
<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_date" />
<field name="priority" />
<field name="employee_ids" widget="many2many_tags"/>
</group>
<group class="col-12">
<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>
</data>
<field name="cleaning_comments" />
</group>
<group class="col-12">
<field
name="cancellation_type_id"
attrs="{'invisible': [('state', '!=', 'cancel')]}"
/>
</group>
</form>
</field>
</record>
</odoo>

View File

@@ -1,35 +1,33 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>
<record model="ir.actions.act_window" id="action_pms_housekeeping_task_type">
<field name="name">Housekeeping Task Type</field>
<field name="res_model">pms.housekeeping.task.type</field>
<field name="view_mode">tree,form</field>
</record>
<record model="ir.actions.act_window" id="action_pms_housekeeping_task">
<field name="name">Housekeeping Task</field>
<field name="res_model">pms.housekeeping.task</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem
name="Housekeeping"
id="menu_action_pms_housekeeping"
sequence="17"
parent="pms.pms_management_menu"
/>
<menuitem
name="Task Types"
id="menu_action_pms_housekeeping_view_task_type"
action="pms_housekeeping.action_pms_housekeeping_task_type"
sequence="10"
parent="pms_housekeeping.menu_action_pms_housekeeping"
/>
<menuitem
name="Tasks"
id="menu_action_pms_housekeeping_view_task"
action="pms_housekeeping.action_pms_housekeeping_task"
sequence="9"
parent="pms_housekeeping.menu_action_pms_housekeeping"
/>
</data>
<record model="ir.actions.act_window" id="action_pms_housekeeping_task_type">
<field name="name">Housekeeping Task Type</field>
<field name="res_model">pms.housekeeping.task.type</field>
<field name="view_mode">tree,form</field>
</record>
<record model="ir.actions.act_window" id="action_pms_housekeeping_task">
<field name="name">Housekeeping Task</field>
<field name="res_model">pms.housekeeping.task</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem
name="Housekeeping"
id="menu_action_pms_housekeeping"
sequence="17"
parent="pms.pms_management_menu"
/>
<menuitem
name="Task Types"
id="menu_action_pms_housekeeping_view_task_type"
action="pms_housekeeping.action_pms_housekeeping_task_type"
sequence="10"
parent="pms_housekeeping.menu_action_pms_housekeeping"
/>
<menuitem
name="Tasks"
id="menu_action_pms_housekeeping_view_task"
action="pms_housekeeping.action_pms_housekeeping_task"
sequence="9"
parent="pms_housekeeping.menu_action_pms_housekeeping"
/>
</odoo>