Replace booking line by folio
This commit is contained in:
parent
4b5f184129
commit
be564ccc41
|
@ -33,7 +33,7 @@ def register():
|
|||
operation.Operation,
|
||||
operation.OperationLine,
|
||||
booking.Booking,
|
||||
booking.BookingLine,
|
||||
booking.BookingFolio,
|
||||
booking.BookingDailyStart,
|
||||
configuration.ConfigurationProduct,
|
||||
housekeeping.Housekeeping,
|
||||
|
|
143
booking.py
143
booking.py
|
@ -4,6 +4,7 @@
|
|||
from __future__ import with_statement
|
||||
from datetime import datetime, timedelta
|
||||
from decimal import Decimal
|
||||
|
||||
from trytond.model import Workflow, ModelView, ModelSQL, fields
|
||||
from trytond.wizard import Wizard, StateView, Button, StateTransition, StateReport
|
||||
from trytond.report import Report
|
||||
|
@ -162,7 +163,7 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
states=STATES, domain=[('id', If(In('company',
|
||||
Eval('context', {})), '=', '!='), Get(Eval('context', {}),
|
||||
'company', 0))], readonly=True)
|
||||
lines = fields.One2Many('hotel.booking.line', 'booking', 'Lines',
|
||||
lines = fields.One2Many('hotel.folio', 'booking', 'Lines',
|
||||
states={
|
||||
'required': Eval('state') == 'confirmed',
|
||||
'readonly': Eval('registration_state').in_(['check_in', 'check_out']),
|
||||
|
@ -324,7 +325,7 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
operations = []
|
||||
for line in self.lines:
|
||||
ops = Operation.search([
|
||||
('origin', '=', 'hotel.booking.line,' + str(line.id))
|
||||
('origin', '=', 'hotel.folio,' + str(line.id))
|
||||
])
|
||||
if ops:
|
||||
ids_op = [o.id for o in ops]
|
||||
|
@ -400,7 +401,7 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
# @ModelView.button
|
||||
# def check_in(cls, records):
|
||||
# CHECK_INDIVIDUAL = False
|
||||
# Line = Pool().get('hotel.booking.line')
|
||||
# Line = Pool().get('hotel.folio')
|
||||
# check_in_(records,CHECK_INDIVIDUAL)
|
||||
# for record in records:
|
||||
# for line in record.lines:
|
||||
|
@ -438,7 +439,7 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
# @ModelView.button
|
||||
# def check_out(cls, records):
|
||||
# CHECK_INDIVIDUAL = False
|
||||
# Line = Pool().get('hotel.booking.line')
|
||||
# Line = Pool().get('hotel.folio')
|
||||
# for record in records:
|
||||
# cls.write([record], {'registration_state': 'check_out'})
|
||||
# update_occupancy(state='closed',check=CHECK_INDIVIDUAL,records=records)
|
||||
|
@ -499,7 +500,7 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
def create_occupancy(self):
|
||||
pool = Pool()
|
||||
Config = pool.get('hotel.configuration')
|
||||
Line = pool.get('hotel.booking.line')
|
||||
Line = pool.get('hotel.folio')
|
||||
|
||||
config = Config.get_configuration()
|
||||
if config.check_out_time is None or config.check_in_time is None:
|
||||
|
@ -670,16 +671,15 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
|
||||
@fields.depends('price_list', 'breakfast_included')
|
||||
def on_change_price_list(self):
|
||||
print('Aquiaaaaaaa')
|
||||
if self.price_list:
|
||||
self.breakfast_included = self.price_list.breakfast_included
|
||||
|
||||
|
||||
class BookingLine(ModelSQL, ModelView):
|
||||
'Booking Line'
|
||||
__name__ = 'hotel.booking.line'
|
||||
booking = fields.Many2One('hotel.booking', 'Booking',
|
||||
ondelete='CASCADE', select=True)
|
||||
class BookingFolio(ModelSQL, ModelView):
|
||||
'Booking Folio'
|
||||
__name__ = 'hotel.folio'
|
||||
booking = fields.Many2One('hotel.booking', 'Booking', ondelete='CASCADE',
|
||||
select=True)
|
||||
room = fields.Many2One('hotel.room', 'Room', select=True, states={
|
||||
'required': Eval('registration_state') == 'check_in',
|
||||
'readonly': Eval('registration_state') == 'check_in',
|
||||
|
@ -728,10 +728,15 @@ class BookingLine(ModelSQL, ModelView):
|
|||
select=True, states=STATES_CHECKIN)
|
||||
registration_state = fields.Selection(REGISTRATION_STATE,
|
||||
'Registration State', readonly=True)
|
||||
# charges = fields.One2Many('hotel.folio.charge', 'folio', 'Charges',
|
||||
# states={
|
||||
# 'required': Eval('state') == 'confirmed',
|
||||
# 'readonly': Eval('registration_state').in_(['check_in', 'check_out']),
|
||||
# }, depends=['state', 'party'], context={'party': Eval('party')})
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(BookingLine, cls).__setup__()
|
||||
super(BookingFolio, cls).__setup__()
|
||||
cls._check_modify_exclude = [
|
||||
'nationality', 'origin_country', 'target_country',
|
||||
'registration_state', 'guests'
|
||||
|
@ -1108,7 +1113,7 @@ class SelectRooms(Wizard):
|
|||
|
||||
def _add_rooms(self):
|
||||
pool = Pool()
|
||||
Line = pool.get('hotel.booking.line')
|
||||
Line = pool.get('hotel.folio')
|
||||
Booking = pool.get('hotel.booking')
|
||||
booking = Booking(Transaction().context.get('active_id'))
|
||||
lines_to_create = []
|
||||
|
@ -1169,7 +1174,7 @@ class Guest(ModelSQL, ModelView):
|
|||
'Guest'
|
||||
__name__ = 'hotel.booking.guest'
|
||||
_rec_name = 'party'
|
||||
booking_line = fields.Many2One('hotel.booking.line', 'Booking Line',
|
||||
booking_line = fields.Many2One('hotel.folio', 'Booking Line',
|
||||
required=True, ondelete='CASCADE')
|
||||
party = fields.Many2One('party.party', 'Party', required=False)
|
||||
type_guest = fields.Selection([
|
||||
|
@ -1353,7 +1358,7 @@ class BookingForecastReport(Report):
|
|||
pool = Pool()
|
||||
Company = pool.get('company.company')
|
||||
Room = pool.get('hotel.room')
|
||||
BookingLine = pool.get('hotel.booking.line')
|
||||
BookingLine = pool.get('hotel.folio')
|
||||
|
||||
rooms = Room.search([])
|
||||
alldays = {}
|
||||
|
@ -1675,3 +1680,111 @@ class BookingDailyReport(Report):
|
|||
report_context['company'] = Company(data['company']).party.name
|
||||
report_context['date'] = data['date']
|
||||
return report_context
|
||||
|
||||
|
||||
class HotelCharge(Workflow, ModelSQL, ModelView):
|
||||
'Hotel Charge'
|
||||
__name__ = 'hotel.charge'
|
||||
|
||||
INVOICE_STATES = [
|
||||
('', ''),
|
||||
('pending', 'Pending'),
|
||||
('in_process', 'In Process'),
|
||||
('invoiced', 'Invoiced'),
|
||||
('paid', 'Paid')
|
||||
]
|
||||
|
||||
booking_line = fields.Many2One('', 'Booking Line',
|
||||
required=True)
|
||||
service_date = fields.Date('Service Date', select=True, required=True)
|
||||
product = fields.Many2One('product.product', 'Product',
|
||||
domain=[('salable', '=', True)], required=True)
|
||||
quantity = fields.Integer('Quantity', required=True)
|
||||
invoice_to = fields.Many2One('party.party', 'Invoice To', required=True)
|
||||
unit_price = fields.Numeric('Unit Price', required=True)
|
||||
unit_price_w_tax = fields.Function(fields.Numeric('Unit Price'),
|
||||
'get_unit_price_w_tax')
|
||||
order = fields.Char('Order', select=True)
|
||||
description = fields.Char('Description', select=True)
|
||||
state = fields.Selection(INVOICE_STATES, 'State', readonly=True)
|
||||
state_string = state.translated('state')
|
||||
sale_line = fields.Many2One('sale.line', 'Sale Line', readonly=True)
|
||||
amount = fields.Function(fields.Numeric('Amount',
|
||||
digits=(16, 2)), 'get_amount')
|
||||
taxed_amount = fields.Function(fields.Numeric('Amount with Tax',
|
||||
digits=(16, 2)), 'get_taxed_amount')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(HotelFolio, cls).__setup__()
|
||||
cls._buttons.update({
|
||||
'transfer': {
|
||||
'invisible': True,
|
||||
},
|
||||
'bill': {
|
||||
'invisible': Eval('invoice_state') is not None,
|
||||
},
|
||||
})
|
||||
|
||||
@staticmethod
|
||||
def default_quantity():
|
||||
return 1
|
||||
|
||||
@staticmethod
|
||||
def default_date_service():
|
||||
today = Pool().get('ir.date').today()
|
||||
return today
|
||||
|
||||
def get_amount(self, name=None):
|
||||
if self.quantity and self.unit_price:
|
||||
return self.quantity * self.unit_price_w_tax
|
||||
return 0
|
||||
|
||||
def get_unit_price_w_tax(self, name=None):
|
||||
Tax = Pool().get('account.tax')
|
||||
res = self.unit_price or 0
|
||||
if self.unit_price:
|
||||
values = Tax.compute(
|
||||
self.product.template.customer_taxes_used,
|
||||
self.unit_price, 1)
|
||||
if values:
|
||||
value = values[0]
|
||||
res = value['base'] + value['amount']
|
||||
return res
|
||||
|
||||
def get_taxed_amount(self, name=None):
|
||||
if self.quantity and self.unit_price:
|
||||
return self.quantity * self.unit_price
|
||||
|
||||
# def get_sale(self, name=None):
|
||||
# if self.sale_line:
|
||||
# return self.sale_line.sale.id
|
||||
|
||||
# def compute_amount_with_tax(line):
|
||||
# tax_amount = _ZERO
|
||||
# amount = _ZERO
|
||||
# if line.taxes:
|
||||
# tax_list = Tax.compute(line.taxes, line.unit_price or _ZERO,
|
||||
# line.quantity or 0.0)
|
||||
#
|
||||
# tax_amount = sum([t['amount'] for t in tax_list], _ZERO)
|
||||
#
|
||||
# if line.unit_price:
|
||||
# amount = line.unit_price * Decimal(line.quantity)
|
||||
# return amount + tax_amount
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
def bill(cls, records):
|
||||
cls.create_sales(records)
|
||||
|
||||
@classmethod
|
||||
@ModelView.button_action('hotel.wizard_operation_line_transfer')
|
||||
def transfer(cls, records):
|
||||
pass
|
||||
|
||||
@fields.depends('unit_price', 'product')
|
||||
def on_change_product(self):
|
||||
if self.product:
|
||||
self.unit_price = self.product.template.list_price
|
||||
self.description = self.product.description
|
||||
|
|
|
@ -117,12 +117,12 @@ this repository contains the full copyright notices and license terms. -->
|
|||
action="act_booking_form" id="menu_booking_form"/>
|
||||
|
||||
<record model="ir.ui.view" id="booking_line_view_tree">
|
||||
<field name="model">hotel.booking.line</field>
|
||||
<field name="model">hotel.folio</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="name">booking_line_tree</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="booking_line_view_form">
|
||||
<field name="model">hotel.booking.line</field>
|
||||
<field name="model">hotel.folio</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">booking_line_form</field>
|
||||
</record>
|
||||
|
@ -199,13 +199,13 @@ this repository contains the full copyright notices and license terms. -->
|
|||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="booking_line_guest_view_tree">
|
||||
<field name="model">hotel.booking.line</field>
|
||||
<field name="model">hotel.folio</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="name">booking_line_guest_tree</field>
|
||||
</record>
|
||||
<record model="ir.action.act_window" id="act_booking_board_form">
|
||||
<field name="name">Board Guest Moves</field>
|
||||
<field name="res_model">hotel.booking.line</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"/>
|
||||
|
|
|
@ -123,7 +123,7 @@ class Housekeeping(Workflow, ModelSQL, ModelView):
|
|||
pool = Pool()
|
||||
Date = pool.get('ir.date')
|
||||
Configuration = pool.get('hotel.configuration')
|
||||
BookingLine = pool.get('hotel.booking.line')
|
||||
BookingLine = pool.get('hotel.folio')
|
||||
config = Configuration.get_configuration()
|
||||
lines = BookingLine.search_read([
|
||||
('room', '=', self.room.id),
|
||||
|
|
|
@ -374,7 +374,7 @@ class Operation(Workflow, ModelSQL, ModelView):
|
|||
|
||||
@classmethod
|
||||
def _get_origin(cls):
|
||||
return ['hotel.operation.maintenance', 'hotel.booking.line']
|
||||
return ['hotel.operation.maintenance', 'hotel.folio']
|
||||
|
||||
@classmethod
|
||||
def copy(cls, operations, default=None):
|
||||
|
@ -1035,7 +1035,7 @@ class Migration(Report):
|
|||
@classmethod
|
||||
def get_context(cls, records, header, data):
|
||||
report_context = super().get_context(records, header, data)
|
||||
Line = Pool().get('hotel.booking.line')
|
||||
Line = Pool().get('hotel.folio')
|
||||
start = data['start_date']
|
||||
end = data['end_date']
|
||||
report_context['records'] = Line.search([
|
||||
|
|
Loading…
Reference in New Issue