Fix views

This commit is contained in:
Oscar 2021-10-05 22:37:33 -05:00
parent 145cb1712f
commit dccac4944a
6 changed files with 212 additions and 236 deletions

View File

@ -270,7 +270,7 @@ class Booking(Workflow, ModelSQL, ModelView):
},
'pay_advance': {
'invisible':
Or(Eval('registration_state') == 'check_in', Eval('state') != 'confirmed'),
Eval('registration_state').in_(['check_out', 'offer']),
},
'send_email': {
'invisible': Eval('state') != 'confirmed'
@ -384,9 +384,7 @@ class Booking(Workflow, ModelSQL, ModelView):
@classmethod
@ModelView.button
def no_show(cls, records):
check = False
for record in records:
record.update_occupancy(state='cancelled', records=records, check=check)
cls.write([record], {'registration_state': 'no_show'})
record.cancel_occupancy()
@ -490,48 +488,6 @@ class Booking(Workflow, ModelSQL, ModelView):
context['taxes'] = taxes
return context
def update_occupancy(self, state, records, check):
Operation = Pool().get('hotel.operation')
OperationVoucher = Pool().get('hotel.operation-account.voucher')
vouchers_added = False
lines = records if check is True else self.lines
for line in lines:
# if state != 'open':
# continue
guests = [{
'party': line.main_guest.id
}]
for g in line.guests:
# if line.main_guest.id == g.party.id:
# continue
guests.append({
'party': g.party.id
})
if line.operation:
Operation.write([line.operation], {
'state': state,
'main_guest': line.main_guest.id,
'party': line.booking.party.id,
'unit_price': line.unit_price,
'start_date': line.arrival_date,
'end_date': line.departure_date,
'reference': line.booking.registration_card,
'guests': [('create', guests)]
})
vouchers = None
if not vouchers_added and self.vouchers:
vouchers = self.vouchers
vouchers_added = True
if vouchers:
for v in vouchers:
OperationVoucher.create([{
'voucher': v.id,
'operation': line.operation.id
}])
def get_total_advance(self, name):
Advance = Pool().get('hotel.booking-account.voucher')
vouchers = Advance.search([('booking', '=', self.id)])
@ -617,7 +573,7 @@ class Folio(ModelSQL, ModelView):
('template.type', '=', 'service'),
('template.kind', '=', 'accommodation'),
], required=True, states=STATES_CHECKIN)
unit_price = fields.Numeric('Unit Price', digits=(16, 2),
unit_price = fields.Numeric('Unit Price', digits=(16, 4),
states={
'required': Bool(Eval('product')),
'readonly': Eval('registration_state') == 'check_in',
@ -658,6 +614,10 @@ class Folio(ModelSQL, ModelView):
states={
'readonly': ~Eval('registration_state').in_(['check_in']),
})
party = fields.Many2One('party.party', 'Party to Bill', select=True,
states={
'readonly': Eval('registration_state').in_(['check_out']),
})
@classmethod
def __setup__(cls):
@ -668,45 +628,16 @@ class Folio(ModelSQL, ModelView):
],
cls._buttons.update({
'check_in': {
'invisible': Eval('state') == 'confirmed' and
Eval('registration_state').in_(['check_in', 'check_out']),
'invisible': Eval('registration_state').in_(['check_in', 'check_out']),
},
'check_out': {
'invisible': Eval('state') != 'check_in' and
Eval('registration_state') == 'check_out',
'invisible': Eval('registration_state').in_(['check_out', 'pending']),
}
})
@classmethod
def write(cls, *args):
lines, vals = args[0], args[-1]
for line in lines:
# if not line.operation:
# continue
# values = {}
# if vals.get('room'):
# values.update({
# 'room': vals['room'],
# })
# if vals.get('main_guest'):
# values.update({
# 'party': vals['main_guest'],
# })
# if vals.get('product'):
# values.update({
# 'accommodation': vals['product'],
# })
# if vals.get('state'):
# values.update({'state': vals['state']})
# if vals.get('arrival_date'):
# values.update({'start_date': vals['arrival_date']})
# if vals.get('departure_date'):
# values.update({'end_date': vals['departure_date']})
# if values:
# Operation = Pool().get('hotel.operation')
# Operation.write([line.operation], values)
pass
actions = iter(args)
if len(args) > 2:
actions = iter(args[2:])
@ -728,7 +659,6 @@ class Folio(ModelSQL, ModelView):
if not validate_party:
config_party.validate_party = True
config_party.save()
config_party.save()
booking = records[0].booking
# booking.party.pre_validate()
Booking.set_registration_card_number([booking])
@ -742,7 +672,6 @@ class Folio(ModelSQL, ModelView):
booking.check_rooms()
cls.write([records[0]], {'registration_state': 'check_in'})
booking.update_occupancy(state='open', records=records, check=check)
change_state = all(
[rl.registration_state == 'check_in' for rl in booking.lines]
@ -761,9 +690,6 @@ class Folio(ModelSQL, ModelView):
check = True
for record in records:
cls.write([record], {'registration_state': 'check_out'})
record.booking.update_occupancy(
state='closed', records=records, check=check
)
@staticmethod
def default_main_guest():

View File

@ -198,25 +198,35 @@ this repository contains the full copyright notices and license terms. -->
<field name="perm_delete" eval="True"/>
</record>
<record model="ir.ui.view" id="booking_folio_guest_view_tree">
<record model="ir.ui.view" id="board_folio_view_tree">
<field name="model">hotel.folio</field>
<field name="type">tree</field>
<field name="name">booking_folio_guest_tree</field>
<field name="name">board_folio_tree</field>
</record>
<record model="ir.action.act_window" id="act_booking_board_form">
<field name="name">Board Guest Moves</field>
<record model="ir.ui.view" id="board_folio_view_form">
<field name="model">hotel.folio</field>
<field name="type">form</field>
<field name="name">board_folio_form</field>
</record>
<record model="ir.action.act_window" id="act_board_folio_view">
<field name="name">Board Folios</field>
<field name="res_model">hotel.folio</field>
<field name="search_value"
eval="[('create_date', '>=', DateTime(hour=0, minute=0, second=0, microsecond=0, delta_years=-1))]"
pyson="1"/>
</record>
<record model="ir.action.act_window.view" id="act_booking_board_form_view1">
<record model="ir.action.act_window.view" id="act_hotel_board_folio_tree_view">
<field name="sequence" eval="1"/>
<field name="view" ref="booking_folio_guest_view_tree"/>
<field name="act_window" ref="act_booking_board_form"/>
<field name="view" ref="board_folio_view_tree"/>
<field name="act_window" ref="act_board_folio_view"/>
</record>
<record model="ir.action.act_window.view" id="act_hotel_board_folio_form_view">
<field name="sequence" eval="2"/>
<field name="view" ref="board_folio_view_form"/>
<field name="act_window" ref="act_board_folio_view"/>
</record>
<menuitem parent="menu_booking_form" sequence="30"
action="act_booking_board_form" id="menu_guest_moves_form"/>
action="act_board_folio_view" id="menu_hotel_board_folio"/>
<record model="ir.action.act_window.domain" id="act_guest_moves_form_domain_arriving_today">
<field name="name">Arriving Today</field>
@ -224,7 +234,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="domain" eval="[
('arrival_date', '=', Date()),
]" pyson="1"/>
<field name="act_window" ref="act_booking_board_form"/>
<field name="act_window" ref="act_board_folio_view"/>
</record>
<record model="ir.action.act_window.domain" id="act_guest_moves_form_domain_leaving_today">
<field name="name">Leaving Today</field>
@ -232,7 +242,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="domain" eval="[
('departure_date', '=', Date()),
]" pyson="1"/>
<field name="act_window" ref="act_booking_board_form"/>
<field name="act_window" ref="act_board_folio_view"/>
</record>
<record model="ir.action.act_window.domain" id="act_guest_moves_form_domain_no_show_today">
<field name="name">No Show Yesterday</field>
@ -241,7 +251,7 @@ this repository contains the full copyright notices and license terms. -->
('arrival_date', '=', Date()),
('booking.registration_state', 'in', ['no_show']),
]" pyson="1"/>
<field name="act_window" ref="act_booking_board_form"/>
<field name="act_window" ref="act_board_folio_view"/>
</record>
<record model="ir.action.act_window.domain" id="act_guest_moves_form_domain_all">
<field name="name">All</field>
@ -249,7 +259,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="domain" eval="[
('arrival_date', '>=', Date()),
]" pyson="1"/>
<field name="act_window" ref="act_booking_board_form"/>
<field name="act_window" ref="act_board_folio_view"/>
</record>
<!-- <record model="ir.action.act_window" id="act_open_booking_sales_form">

View File

@ -20,15 +20,6 @@ STATES_MNT = {
'readonly': Eval('state') != 'draft',
}
OPERATION_STATES = [
('draft', 'Draft'),
('open', 'Open'),
('closed', 'Closed'),
('invoiced', 'Invoiced'),
('transfered', 'Transfered'),
('cancelled', 'Cancel'),
]
COLOR_BOOKING = {
'draft': '#9b9f9f',
'check_in': '#e6bd0f',
@ -56,7 +47,7 @@ COMPLEMENTARY = [
('courtesy', 'Courtesy')
]
_ZERO = Decimal('0.00')
_ZERO = Decimal('0')
# class Operation(Workflow, ModelSQL, ModelView):
@ -761,137 +752,137 @@ _ZERO = Decimal('0.00')
# def get_rec_name(self, name):
# if self.party:
# return self.party.name
#
#
# class OperationMaintenance(Workflow, ModelSQL, ModelView):
# 'Operation Maintenance'
# __name__ = 'hotel.operation.maintenance'
# operation = fields.Many2One('hotel.operation', 'Operation', states=STATES_MNT)
# room = fields.Many2One('hotel.room', 'Room', states=STATES_MNT, select=True,
# required=True)
# kind = fields.Selection([
# ('maintenance', 'Maintenance'),
# ], 'Kind', readonly=True, select=True)
# start_date = fields.Date('Start Date', states=STATES_MNT, required=True,
# select=True)
# end_date = fields.Date('End Date', states=STATES_MNT, required=True,
# select=True)
# description = fields.Text('Description', states=STATES_MNT, select=True)
# state = fields.Selection([
# ('draft', 'Draft'),
# ('confirmed', 'Confirmed'),
# ('finished', 'Finished'),
# ('cancelled', 'Canceled'),
# ], 'State', readonly=True, select=True)
#
# @classmethod
# def __setup__(cls):
# super(OperationMaintenance, cls).__setup__()
# cls._transitions |= set((
# ('draft', 'confirmed'),
# ('draft', 'cancelled'),
# ('confirmed', 'finished'),
# ('confirmed', 'cancelled'),
# ))
# cls._buttons.update({
# 'cancel': {
# 'invisible': ~Eval('state').in_(['draft', 'confirmed']),
# },
# 'draft': {
# 'invisible': Eval('state') != 'confirmed',
# },
# 'confirm': {
# 'invisible': Eval('state') != 'draft',
# },
# 'finish': {
# 'invisible': Eval('state') != 'confirmed',
# },
# })
#
# @classmethod
# def trigger_create(cls, records):
# for mant in records:
# mant.create_operation()
#
# @staticmethod
# def default_kind():
# return 'maintenance'
#
# @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):
# for mant in records:
# mant.delete_operation()
#
# @classmethod
# @ModelView.button
# @Workflow.transition('confirmed')
# def confirm(cls, records):
# for mant in records:
# mant.update_operation({'state': 'confirmed'})
#
# @classmethod
# @ModelView.button
# @Workflow.transition('finished')
# def finish(cls, records):
# for mant in records:
# mant.update_operation({'state': 'finished'})
#
# def delete_operation(self):
# Operation = Pool().get('hotel.operation')
# Operation.delete([self.operation])
#
# def create_operation(self):
# Operation = Pool().get('hotel.operation')
# values = {
# 'kind': 'maintenance',
# 'room': self.room,
# 'start_date': self.start_date,
# 'end_date': self.end_date,
# 'state': self.state,
# 'origin': str(self)
# }
# operation, = Operation.create([values])
# self.write([self], {'operation': operation.id})
#
# def update_operation(self, values):
# Operation = Pool().get('hotel.operation')
# Operation.write([self.operation], values)
#
# @classmethod
# def write(cls, records, values):
# Room = Pool().get('hotel.room')
# for rec in records:
# if values.get('start_date') or values.get('end_date') or values.get('room'):
# start_date = values.get('start_date') or rec.start_date
# end_date = values.get('end_date') or rec.end_date
# room = Room(values.get('room') or rec.room)
# Operation().check_dates(start_date, end_date, room, rec.operation)
# rec.update_operation({
# 'start_date': start_date,
# 'end_date': end_date,
# 'room': room.id,
# })
# super(OperationMaintenance, cls).write(records, values)
#
# def check_method(self):
# """
# Check the methods.
# """
# Operation = Pool().get('hotel.operation')
# Operation().check_dates(self.start_date, self.end_date, self.room,
# self.operation)
class OperationMaintenance(Workflow, ModelSQL, ModelView):
'Operation Maintenance'
__name__ = 'hotel.operation.maintenance'
operation = fields.Many2One('hotel.operation', 'Operation', states=STATES_MNT)
room = fields.Many2One('hotel.room', 'Room', states=STATES_MNT, select=True,
required=True)
kind = fields.Selection([
('maintenance', 'Maintenance'),
], 'Kind', readonly=True, select=True)
start_date = fields.Date('Start Date', states=STATES_MNT, required=True,
select=True)
end_date = fields.Date('End Date', states=STATES_MNT, required=True,
select=True)
description = fields.Text('Description', states=STATES_MNT, select=True)
state = fields.Selection([
('draft', 'Draft'),
('confirmed', 'Confirmed'),
('finished', 'Finished'),
('cancelled', 'Canceled'),
], 'State', readonly=True, select=True)
@classmethod
def __setup__(cls):
super(OperationMaintenance, cls).__setup__()
cls._transitions |= set((
('draft', 'confirmed'),
('draft', 'cancelled'),
('confirmed', 'finished'),
('confirmed', 'cancelled'),
))
cls._buttons.update({
'cancel': {
'invisible': ~Eval('state').in_(['draft', 'confirmed']),
},
'draft': {
'invisible': Eval('state') != 'confirmed',
},
'confirm': {
'invisible': Eval('state') != 'draft',
},
'finish': {
'invisible': Eval('state') != 'confirmed',
},
})
@classmethod
def trigger_create(cls, records):
for mant in records:
mant.create_operation()
@staticmethod
def default_kind():
return 'maintenance'
@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):
for mant in records:
mant.delete_operation()
@classmethod
@ModelView.button
@Workflow.transition('confirmed')
def confirm(cls, records):
for mant in records:
mant.update_operation({'state': 'confirmed'})
@classmethod
@ModelView.button
@Workflow.transition('finished')
def finish(cls, records):
for mant in records:
mant.update_operation({'state': 'finished'})
def delete_operation(self):
Operation = Pool().get('hotel.operation')
Operation.delete([self.operation])
def create_operation(self):
Operation = Pool().get('hotel.operation')
values = {
'kind': 'maintenance',
'room': self.room,
'start_date': self.start_date,
'end_date': self.end_date,
'state': self.state,
'origin': str(self)
}
operation, = Operation.create([values])
self.write([self], {'operation': operation.id})
def update_operation(self, values):
Operation = Pool().get('hotel.operation')
Operation.write([self.operation], values)
@classmethod
def write(cls, records, values):
Room = Pool().get('hotel.room')
for rec in records:
if values.get('start_date') or values.get('end_date') or values.get('room'):
start_date = values.get('start_date') or rec.start_date
end_date = values.get('end_date') or rec.end_date
room = Room(values.get('room') or rec.room)
Operation().check_dates(start_date, end_date, room, rec.operation)
rec.update_operation({
'start_date': start_date,
'end_date': end_date,
'room': room.id,
})
super(OperationMaintenance, cls).write(records, values)
def check_method(self):
"""
Check the methods.
"""
Operation = Pool().get('hotel.operation')
Operation().check_dates(self.start_date, self.end_date, self.room,
self.operation)
class FolioCharge(Workflow, ModelSQL, ModelView):

49
view/board_folio_form.xml Normal file
View File

@ -0,0 +1,49 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form col="6">
<label name="product"/>
<field name="product" widget="selection"/>
<label name="main_guest"/>
<field name="main_guest"/>
<label name="room"/>
<field name="room" widget="selection"/>
<label name="arrival_date"/>
<field name="arrival_date" widget="date"/>
<label name="departure_date"/>
<field name="departure_date" widget="date"/>
<label name="nights_quantity"/>
<field name="nights_quantity"/>
<label name="unit_price"/>
<field name="unit_price"/>
<label name="host_quantity"/>
<field name="host_quantity"/>
<label name="party"/>
<field name="party"/>
<notebook colspan="6">
<page string="Charges" id="hotel_charges">
<field name="charges" colspan="4"/>
</page>
<page string="Guests" id="hotel_guests">
<field name="guests" colspan="4"/>
</page>
<page string="Additional Info" id="folio_additional_info">
<label name="nationality"/>
<field name="nationality"/>
<label name="total_commission"/>
<field name="total_commission"/>
<label name="origin_country"/>
<field name="origin_country"/>
<label name="target_country"/>
<field name="target_country"/>
<separator name="notes" colspan="4"/>
<field name="notes" colspan="4"/>
</page>
</notebook>
<label name="total_amount"/>
<field name="total_amount"/>
<label name="registration_state"/>
<field name="registration_state"/>
<button name="check_in" string="Check In"/>
<button name="check_out" string="Check Out"/>
</form>

View File

@ -13,5 +13,5 @@ this repository contains the full copyright notices and license terms. -->
<field name="total_amount"/>
<field name="host_quantity"/>
<field name="registration_state"/>
<!-- <button name="check_out" string="Check Out"/> -->
<button name="check_out" string="Check Out"/>
</tree>