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': { 'pay_advance': {
'invisible': 'invisible':
Or(Eval('registration_state') == 'check_in', Eval('state') != 'confirmed'), Eval('registration_state').in_(['check_out', 'offer']),
}, },
'send_email': { 'send_email': {
'invisible': Eval('state') != 'confirmed' 'invisible': Eval('state') != 'confirmed'
@ -384,9 +384,7 @@ class Booking(Workflow, ModelSQL, ModelView):
@classmethod @classmethod
@ModelView.button @ModelView.button
def no_show(cls, records): def no_show(cls, records):
check = False
for record in records: for record in records:
record.update_occupancy(state='cancelled', records=records, check=check)
cls.write([record], {'registration_state': 'no_show'}) cls.write([record], {'registration_state': 'no_show'})
record.cancel_occupancy() record.cancel_occupancy()
@ -490,48 +488,6 @@ class Booking(Workflow, ModelSQL, ModelView):
context['taxes'] = taxes context['taxes'] = taxes
return context 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): def get_total_advance(self, name):
Advance = Pool().get('hotel.booking-account.voucher') Advance = Pool().get('hotel.booking-account.voucher')
vouchers = Advance.search([('booking', '=', self.id)]) vouchers = Advance.search([('booking', '=', self.id)])
@ -617,7 +573,7 @@ class Folio(ModelSQL, ModelView):
('template.type', '=', 'service'), ('template.type', '=', 'service'),
('template.kind', '=', 'accommodation'), ('template.kind', '=', 'accommodation'),
], required=True, states=STATES_CHECKIN) ], required=True, states=STATES_CHECKIN)
unit_price = fields.Numeric('Unit Price', digits=(16, 2), unit_price = fields.Numeric('Unit Price', digits=(16, 4),
states={ states={
'required': Bool(Eval('product')), 'required': Bool(Eval('product')),
'readonly': Eval('registration_state') == 'check_in', 'readonly': Eval('registration_state') == 'check_in',
@ -658,6 +614,10 @@ class Folio(ModelSQL, ModelView):
states={ states={
'readonly': ~Eval('registration_state').in_(['check_in']), '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 @classmethod
def __setup__(cls): def __setup__(cls):
@ -668,45 +628,16 @@ class Folio(ModelSQL, ModelView):
], ],
cls._buttons.update({ cls._buttons.update({
'check_in': { 'check_in': {
'invisible': Eval('state') == 'confirmed' and 'invisible': Eval('registration_state').in_(['check_in', 'check_out']),
Eval('registration_state').in_(['check_in', 'check_out']),
}, },
'check_out': { 'check_out': {
'invisible': Eval('state') != 'check_in' and 'invisible': Eval('registration_state').in_(['check_out', 'pending']),
Eval('registration_state') == 'check_out',
} }
}) })
@classmethod @classmethod
def write(cls, *args): def write(cls, *args):
lines, vals = args[0], args[-1] 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) actions = iter(args)
if len(args) > 2: if len(args) > 2:
actions = iter(args[2:]) actions = iter(args[2:])
@ -728,7 +659,6 @@ class Folio(ModelSQL, ModelView):
if not validate_party: if not validate_party:
config_party.validate_party = True config_party.validate_party = True
config_party.save() config_party.save()
config_party.save()
booking = records[0].booking booking = records[0].booking
# booking.party.pre_validate() # booking.party.pre_validate()
Booking.set_registration_card_number([booking]) Booking.set_registration_card_number([booking])
@ -742,7 +672,6 @@ class Folio(ModelSQL, ModelView):
booking.check_rooms() booking.check_rooms()
cls.write([records[0]], {'registration_state': 'check_in'}) cls.write([records[0]], {'registration_state': 'check_in'})
booking.update_occupancy(state='open', records=records, check=check)
change_state = all( change_state = all(
[rl.registration_state == 'check_in' for rl in booking.lines] [rl.registration_state == 'check_in' for rl in booking.lines]
@ -761,9 +690,6 @@ class Folio(ModelSQL, ModelView):
check = True check = True
for record in records: for record in records:
cls.write([record], {'registration_state': 'check_out'}) cls.write([record], {'registration_state': 'check_out'})
record.booking.update_occupancy(
state='closed', records=records, check=check
)
@staticmethod @staticmethod
def default_main_guest(): 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"/> <field name="perm_delete" eval="True"/>
</record> </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="model">hotel.folio</field>
<field name="type">tree</field> <field name="type">tree</field>
<field name="name">booking_folio_guest_tree</field> <field name="name">board_folio_tree</field>
</record> </record>
<record model="ir.action.act_window" id="act_booking_board_form"> <record model="ir.ui.view" id="board_folio_view_form">
<field name="name">Board Guest Moves</field> <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="res_model">hotel.folio</field>
<field name="search_value" <field name="search_value"
eval="[('create_date', '>=', DateTime(hour=0, minute=0, second=0, microsecond=0, delta_years=-1))]" eval="[('create_date', '>=', DateTime(hour=0, minute=0, second=0, microsecond=0, delta_years=-1))]"
pyson="1"/> pyson="1"/>
</record> </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="sequence" eval="1"/>
<field name="view" ref="booking_folio_guest_view_tree"/> <field name="view" ref="board_folio_view_tree"/>
<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.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> </record>
<menuitem parent="menu_booking_form" sequence="30" <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"> <record model="ir.action.act_window.domain" id="act_guest_moves_form_domain_arriving_today">
<field name="name">Arriving Today</field> <field name="name">Arriving Today</field>
@ -224,7 +234,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="domain" eval="[ <field name="domain" eval="[
('arrival_date', '=', Date()), ('arrival_date', '=', Date()),
]" pyson="1"/> ]" pyson="1"/>
<field name="act_window" ref="act_booking_board_form"/> <field name="act_window" ref="act_board_folio_view"/>
</record> </record>
<record model="ir.action.act_window.domain" id="act_guest_moves_form_domain_leaving_today"> <record model="ir.action.act_window.domain" id="act_guest_moves_form_domain_leaving_today">
<field name="name">Leaving Today</field> <field name="name">Leaving Today</field>
@ -232,7 +242,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="domain" eval="[ <field name="domain" eval="[
('departure_date', '=', Date()), ('departure_date', '=', Date()),
]" pyson="1"/> ]" pyson="1"/>
<field name="act_window" ref="act_booking_board_form"/> <field name="act_window" ref="act_board_folio_view"/>
</record> </record>
<record model="ir.action.act_window.domain" id="act_guest_moves_form_domain_no_show_today"> <record model="ir.action.act_window.domain" id="act_guest_moves_form_domain_no_show_today">
<field name="name">No Show Yesterday</field> <field name="name">No Show Yesterday</field>
@ -241,7 +251,7 @@ this repository contains the full copyright notices and license terms. -->
('arrival_date', '=', Date()), ('arrival_date', '=', Date()),
('booking.registration_state', 'in', ['no_show']), ('booking.registration_state', 'in', ['no_show']),
]" pyson="1"/> ]" pyson="1"/>
<field name="act_window" ref="act_booking_board_form"/> <field name="act_window" ref="act_board_folio_view"/>
</record> </record>
<record model="ir.action.act_window.domain" id="act_guest_moves_form_domain_all"> <record model="ir.action.act_window.domain" id="act_guest_moves_form_domain_all">
<field name="name">All</field> <field name="name">All</field>
@ -249,7 +259,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="domain" eval="[ <field name="domain" eval="[
('arrival_date', '>=', Date()), ('arrival_date', '>=', Date()),
]" pyson="1"/> ]" pyson="1"/>
<field name="act_window" ref="act_booking_board_form"/> <field name="act_window" ref="act_board_folio_view"/>
</record> </record>
<!-- <record model="ir.action.act_window" id="act_open_booking_sales_form"> <!-- <record model="ir.action.act_window" id="act_open_booking_sales_form">

View File

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