diff --git a/__init__.py b/__init__.py
index 1806cbb..6c6ca22 100644
--- a/__init__.py
+++ b/__init__.py
@@ -19,6 +19,7 @@ from . import dash
from . import invoice
from . import statement
from . import stock
+from . import operation
def register():
@@ -36,6 +37,7 @@ def register():
configuration.Configuration,
product.Template,
product.PriceList,
+ operation.Maintenance,
booking.Booking,
booking.BookingDailyStart,
booking.ManagerStart,
diff --git a/booking.xml b/booking.xml
index 1abb3e4..e117791 100644
--- a/booking.xml
+++ b/booking.xml
@@ -83,13 +83,6 @@ this repository contains the full copyright notices and license terms. -->
-
No Show
@@ -100,13 +93,6 @@ this repository contains the full copyright notices and license terms. -->
-
- Check Out
-
-
-
-
-
All
diff --git a/operation.py b/operation.py
new file mode 100644
index 0000000..a5c588c
--- /dev/null
+++ b/operation.py
@@ -0,0 +1,101 @@
+#This file is part of Presik. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
+from trytond.model import ModelView, ModelSQL, fields, Workflow
+from trytond.pyson import Eval, Bool
+
+
+STATES = {'readonly': Eval('state') != 'draft'}
+
+
+class Maintenance(Workflow, ModelSQL, ModelView):
+ 'Hotel Maintenance'
+ __name__ = 'hotel.maintenance'
+ room = fields.Many2One('hotel.room', 'Room', required=True, states=STATES)
+ start_date = fields.Date('Start Maintenance', states=STATES)
+ end_date = fields.Date('End Maintenance', states={
+ 'required': Bool(Eval('start_date')),
+ 'readonly': Eval('state') != 'draft'
+ })
+ total_days = fields.Function(fields.Integer('Total Days'), 'get_days')
+ issue = fields.Text('Issue', required=True)
+ action = fields.Text('Action', states={
+ 'required': Eval('state') == 'finished',
+ 'readonly': Eval('state') != 'confirmed'
+ })
+ inspected_by = fields.Many2One('company.employee', 'Inspected By',
+ required=True)
+ state = fields.Selection([
+ ('draft', 'Draft'),
+ ('confirmed', 'Confirmed'),
+ ('finished', 'Finished'),
+ ('cancelled', 'Canceled'),
+ ], 'State', readonly=True, select=True)
+ criticality = fields.Selection([
+ ('low', 'Low'),
+ ('important', 'Important'),
+ ('urgent', 'Urgent'),
+ ], 'Criticality')
+
+ @classmethod
+ def __setup__(cls):
+ super(Maintenance, cls).__setup__()
+ cls._transitions |= set((
+ ('draft', 'confirmed'),
+ ('draft', 'cancelled'),
+ ('confirmed', 'draft'),
+ ('cancelled', 'draft'),
+ ('confirmed', 'cancelled'),
+ ('confirmed', 'finished'),
+ ('finished', 'confirmed'),
+ ))
+ cls._buttons.update({
+ 'confirm': {
+ 'invisible': Eval('state') != 'draft',
+ },
+ 'finish': {
+ 'invisible': Eval('state') != 'confirmed',
+ },
+ 'draft': {
+ 'invisible': Eval('state') != 'confirmed',
+ },
+ 'cancel': {
+ 'invisible': Eval('state') != 'finished',
+ }
+ })
+
+ @staticmethod
+ def default_state():
+ return 'draft'
+
+ @classmethod
+ @ModelView.button
+ @Workflow.transition('draft')
+ def draft(cls, records):
+ pass
+
+ @classmethod
+ @ModelView.button
+ @Workflow.transition('cancelled')
+ def cancel(cls, records):
+ pass
+
+ @classmethod
+ @ModelView.button
+ @Workflow.transition('confirmed')
+ def confirm(cls, records):
+ pass
+
+ @classmethod
+ @ModelView.button
+ @Workflow.transition('finished')
+ def finish(cls, records):
+ pass
+
+ @fields.depends('start_date', 'end_date')
+ def on_change_start_date(self):
+ if not self.start_date:
+ self.end_date = None
+
+ def get_days(self, name):
+ if self.end_date and self.start_date:
+ return (self.end_date - self.start_date).days
diff --git a/operation.xml b/operation.xml
new file mode 100644
index 0000000..36b249f
--- /dev/null
+++ b/operation.xml
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+ hotel.maintenance
+ tree
+ maintenance_tree
+
+
+ hotel.maintenance
+ form
+ maintenance_form
+
+
+ Maintenance
+ hotel.maintenance
+
+
+
+
+
+
+
+
+
+
+
+
+ Draft`
+
+
+
+
+
+
+ Confirmed
+
+
+
+
+
+
+ All
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/room.py b/room.py
index a11f85b..604d03f 100644
--- a/room.py
+++ b/room.py
@@ -25,7 +25,7 @@ class Room(ModelSQL, ModelView):
amenities = fields.Many2Many('hotel.room-hotel.amenities', 'room',
'amenities', 'Amenities')
space = fields.Integer('Space', help='Space on m2')
- channel_id = fields.Char('Channel ID')
+ channel_id = fields.Char('Channel Manager ID')
main_accommodation = fields.Many2One('product.template',
'Main Accommodation', ondelete='RESTRICT', depends=['templates'],
domain=[('id', 'in', Eval('templates', []))],
@@ -42,6 +42,11 @@ class Room(ModelSQL, ModelView):
def default_active():
return True
+ @fields.depends('start_mnt', 'end_mnt')
+ def on_change_start_mnt(self):
+ if not self.start_mnt:
+ self.end_mnt = None
+
class RoomAmenities(ModelSQL):
'Room - Amenities'
@@ -93,13 +98,9 @@ class CleanningDays(ModelSQL, ModelView):
('5', 'Friday'),
('6', 'Saturday'),
('7', 'Sunday'),
- ], 'Weekday', required=True)
+ ], 'Weekday', required=True)
note = fields.Text('Note')
- @classmethod
- def __setup__(cls):
- super(CleanningDays, cls).__setup__()
-
class RoomTemplate(ModelSQL):
'Room - Template'
diff --git a/tryton.cfg b/tryton.cfg
index b7691e6..16d9183 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -8,11 +8,11 @@ depends:
sale
product_price_list
sale_price_list
- account_voucher
- party_personal
- commission
- dash
account_statement
+ account_voucher
+ commission
+ party_personal
+ dash
sale_shop
xml:
hotel.xml
@@ -32,3 +32,4 @@ xml:
sale.xml
policy.xml
message.xml
+ operation.xml
diff --git a/view/maintenance_form.xml b/view/maintenance_form.xml
new file mode 100644
index 0000000..f530fc8
--- /dev/null
+++ b/view/maintenance_form.xml
@@ -0,0 +1,31 @@
+
+
+
diff --git a/view/maintenance_tree.xml b/view/maintenance_tree.xml
new file mode 100644
index 0000000..992ec79
--- /dev/null
+++ b/view/maintenance_tree.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+