mirror of
https://bitbucket.org/presik/trytonpsk-hotel.git
synced 2023-12-14 07:52:52 +01:00
minor fix in domain check rooms
This commit is contained in:
parent
a4fb626698
commit
a12ed8e42b
1 changed files with 25 additions and 7 deletions
32
operation.py
32
operation.py
|
@ -145,7 +145,7 @@ class Operation(Workflow, ModelSQL, ModelView):
|
|||
'invalid_date_range': ('The start date is greater than end date'),
|
||||
'missing_default_configuration': ('Missing default configuration for check-in '
|
||||
'time or check-out time!'),
|
||||
'occupied_room': ('The room is occupied in the date %s')
|
||||
'occupied_room': ('The room is occupied %s')
|
||||
})
|
||||
cls._transitions |= set((
|
||||
('draft', 'open'),
|
||||
|
@ -180,14 +180,21 @@ class Operation(Workflow, ModelSQL, ModelView):
|
|||
super(Operation, cls).validate(records)
|
||||
for r in records:
|
||||
operations = cls.search([
|
||||
('start_date', '<=', r.end_date),
|
||||
('end_date', '<=', r.end_date),
|
||||
('room', '=', r.room.id),
|
||||
('id', '!=', r.id),
|
||||
('state', '!=', 'cancelled')
|
||||
])
|
||||
('state', '!=', 'cancelled'),
|
||||
('kind', '=', 'occupancy'),
|
||||
['AND', ['OR',
|
||||
[
|
||||
('start_date', '>=', r.start_date),
|
||||
('end_date', '<', r.start_date),
|
||||
], [
|
||||
('start_date', '>=', r.end_date),
|
||||
('end_date', '<=', r.end_date),
|
||||
]
|
||||
]]])
|
||||
if operations:
|
||||
cls.raise_user_error('occupied_room', r.end_date)
|
||||
cls.raise_user_error('occupied_room', r.room.name)
|
||||
|
||||
@classmethod
|
||||
def occupancy_rate(cls, start, end):
|
||||
|
@ -1196,7 +1203,9 @@ class TransferOperationStart(ModelView):
|
|||
'Transfer Operation'
|
||||
__name__ = 'hotel.operation.transfer_operation.ask'
|
||||
operation = fields.Many2One('hotel.operation', 'Operation',
|
||||
required=True, domain=[('state', '=', 'check_in')])
|
||||
required=True, domain=[
|
||||
('state', 'in', ['draft', 'open']),
|
||||
])
|
||||
tranfer_charges = fields.Boolean('Transfer Charges')
|
||||
|
||||
@staticmethod
|
||||
|
@ -1219,12 +1228,21 @@ class TransferOperation(Wizard):
|
|||
)
|
||||
transfer = StateTransition()
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(TransferOperation, cls).__setup__()
|
||||
cls._error_messages.update({
|
||||
'operation_current': ('Error, Can not select current operation'),
|
||||
})
|
||||
|
||||
def transition_transfer(self):
|
||||
pool = Pool()
|
||||
Operation = pool.get('hotel.operation')
|
||||
OperationLine = pool.get('hotel.operation.line')
|
||||
current_op = Operation(Transaction().context.get('active_id'))
|
||||
target_op = self.start.operation
|
||||
if target_op.id == current_op.id:
|
||||
self.raise_user_error('operation_current')
|
||||
|
||||
lines_to_transfer = []
|
||||
if self.start.tranfer_charges:
|
||||
|
|
Loading…
Reference in a new issue