minor fix in domain check rooms

This commit is contained in:
Camilo Sarmiento 2020-08-29 10:19:37 -05:00
parent a4fb626698
commit a12ed8e42b

View file

@ -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: