Remove old code
This commit is contained in:
parent
1ecfcb7ecc
commit
cb38ffed1a
|
@ -61,7 +61,6 @@ def register():
|
|||
service.ServiceKind,
|
||||
service.CreateDailyServicesStart,
|
||||
room.RoomTemplate,
|
||||
booking.BookingSale,
|
||||
housekeeping.HotelHousekeepingTask,
|
||||
housekeeping.HotelTask,
|
||||
housekeeping.HousekeepingServiceStart,
|
||||
|
|
160
booking.py
160
booking.py
|
@ -14,7 +14,7 @@ from trytond.pool import Pool
|
|||
|
||||
__all__ = [
|
||||
'Booking', 'BookingLine', 'BookingReport', 'SelectRooms', 'SelectRoomsAsk',
|
||||
'BookingSale', 'BookingVoucher', 'RoomsOccupancy', 'RoomsOccupancyStart',
|
||||
'BookingVoucher', 'RoomsOccupancy', 'RoomsOccupancyStart',
|
||||
'RoomsOccupancyReport', 'GuestsListReport', 'GuestsListStart',
|
||||
'RegistrationCardReport', 'BookingForecastReport', 'GuestsList',
|
||||
'Guest', 'BookingDailyStart', 'BookingDaily', 'BookingDailyReport'
|
||||
|
@ -211,8 +211,8 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
code = fields.Char('Code', states={'readonly': True})
|
||||
booker = fields.Many2One('party.party', 'Booker', states={'readonly': True})
|
||||
created_channel = fields.DateTime('Created Channel', states={'readonly': True})
|
||||
sales = fields.Many2Many('hotel.booking-sale.sale', 'booking',
|
||||
'sale', 'Sales', readonly=True)
|
||||
# sales = fields.Many2Many('hotel.booking-sale.sale', 'booking',
|
||||
# 'sale', 'Sales', readonly=True)
|
||||
# operations = fields.Many2Many('hotel.booking-hotel.operation', 'booking',
|
||||
# 'sale', 'Sales', readonly=True)
|
||||
vouchers = fields.Many2Many('hotel.booking-account.voucher', 'booking',
|
||||
|
@ -544,75 +544,75 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
context['taxes'] = taxes
|
||||
return context
|
||||
|
||||
def create_sale(self):
|
||||
pool = Pool()
|
||||
Model = pool.get('ir.model')
|
||||
SaleLine = pool.get('sale.line')
|
||||
Configuration = pool.get('hotel.configuration')
|
||||
configuration = Configuration.get_configuration()
|
||||
date_ = datetime.today().date()
|
||||
model = Model.search([('name', '=', str(self.__name__))])
|
||||
ctx = {}
|
||||
|
||||
if not self.payment_term:
|
||||
self.raise_user_error('payterm_missing')
|
||||
|
||||
if self.price_list:
|
||||
ctx['price_list'] = self.price_list
|
||||
ctx['sale_date'] = date_
|
||||
ctx['currency'] = self.currency.id
|
||||
if self.party:
|
||||
ctx['customer'] = self.party.id
|
||||
|
||||
if not model:
|
||||
model = 'Booking'
|
||||
else:
|
||||
model = model[0].name
|
||||
|
||||
if self.invoice_method == 'by_booking':
|
||||
bookings_ = [(self.party, self.lines)]
|
||||
else:
|
||||
bookings_ = [
|
||||
(line.main_guest, [line]) for line in self.lines
|
||||
]
|
||||
|
||||
for party, lines in bookings_:
|
||||
sale = self.get_sale(party, date_)
|
||||
sale.save()
|
||||
for line in lines:
|
||||
if line.nights_quantity <= 0:
|
||||
continue
|
||||
|
||||
if self.price_list:
|
||||
with Transaction().set_context(ctx):
|
||||
unit_price = self.price_list.compute(
|
||||
self.party, line.product,
|
||||
line.product.template.list_price,
|
||||
line.nights_quantity, line.product.default_uom)
|
||||
else:
|
||||
unit_price = line.unit_price
|
||||
|
||||
unit_price = self.currency.round(line.unit_price)
|
||||
new_line = self.create_sale_line(sale, line, unit_price)
|
||||
SaleLine.create([new_line])
|
||||
|
||||
# Add and create default charges lines if exists
|
||||
for product in configuration.default_charges:
|
||||
taxes_ids = self.get_taxes(product)
|
||||
new_line = {
|
||||
'sale': sale.id,
|
||||
'type': 'line',
|
||||
'unit': product.template.default_uom.id,
|
||||
'quantity': 1,
|
||||
'unit_price': product.template.list_price,
|
||||
'product': product.id,
|
||||
'description': product.rec_name,
|
||||
}
|
||||
if taxes_ids:
|
||||
new_line.update({'taxes': [('add', taxes_ids)]})
|
||||
if new_line:
|
||||
SaleLine.create([new_line])
|
||||
self.write([self], {'sales': [('add', [sale.id])]})
|
||||
# def create_sale(self):
|
||||
# pool = Pool()
|
||||
# Model = pool.get('ir.model')
|
||||
# SaleLine = pool.get('sale.line')
|
||||
# Configuration = pool.get('hotel.configuration')
|
||||
# configuration = Configuration.get_configuration()
|
||||
# date_ = datetime.today().date()
|
||||
# model = Model.search([('name', '=', str(self.__name__))])
|
||||
# ctx = {}
|
||||
#
|
||||
# if not self.payment_term:
|
||||
# self.raise_user_error('payterm_missing')
|
||||
#
|
||||
# if self.price_list:
|
||||
# ctx['price_list'] = self.price_list
|
||||
# ctx['sale_date'] = date_
|
||||
# ctx['currency'] = self.currency.id
|
||||
# if self.party:
|
||||
# ctx['customer'] = self.party.id
|
||||
#
|
||||
# if not model:
|
||||
# model = 'Booking'
|
||||
# else:
|
||||
# model = model[0].name
|
||||
#
|
||||
# if self.invoice_method == 'by_booking':
|
||||
# bookings_ = [(self.party, self.lines)]
|
||||
# else:
|
||||
# bookings_ = [
|
||||
# (line.main_guest, [line]) for line in self.lines
|
||||
# ]
|
||||
#
|
||||
# for party, lines in bookings_:
|
||||
# sale = self.get_sale(party, date_)
|
||||
# sale.save()
|
||||
# for line in lines:
|
||||
# if line.nights_quantity <= 0:
|
||||
# continue
|
||||
#
|
||||
# if self.price_list:
|
||||
# with Transaction().set_context(ctx):
|
||||
# unit_price = self.price_list.compute(
|
||||
# self.party, line.product,
|
||||
# line.product.template.list_price,
|
||||
# line.nights_quantity, line.product.default_uom)
|
||||
# else:
|
||||
# unit_price = line.unit_price
|
||||
#
|
||||
# unit_price = self.currency.round(line.unit_price)
|
||||
# new_line = self.create_sale_line(sale, line, unit_price)
|
||||
# SaleLine.create([new_line])
|
||||
#
|
||||
# # Add and create default charges lines if exists
|
||||
# for product in configuration.default_charges:
|
||||
# taxes_ids = self.get_taxes(product)
|
||||
# new_line = {
|
||||
# 'sale': sale.id,
|
||||
# 'type': 'line',
|
||||
# 'unit': product.template.default_uom.id,
|
||||
# 'quantity': 1,
|
||||
# 'unit_price': product.template.list_price,
|
||||
# 'product': product.id,
|
||||
# 'description': product.rec_name,
|
||||
# }
|
||||
# if taxes_ids:
|
||||
# new_line.update({'taxes': [('add', taxes_ids)]})
|
||||
# if new_line:
|
||||
# SaleLine.create([new_line])
|
||||
# self.write([self], {'sales': [('add', [sale.id])]})
|
||||
|
||||
def update_occupancy(self, state):
|
||||
Operation = Pool().get('hotel.operation')
|
||||
|
@ -1093,14 +1093,14 @@ class SelectRooms(Wizard):
|
|||
booking.save()
|
||||
|
||||
|
||||
class BookingSale(ModelSQL):
|
||||
'Booking - Sale'
|
||||
__name__ = 'hotel.booking-sale.sale'
|
||||
_table = 'booking_sales_rel'
|
||||
booking = fields.Many2One('hotel.booking', 'Booking', ondelete='CASCADE',
|
||||
required=True)
|
||||
sale = fields.Many2One('sale.sale', 'Sale', ondelete='RESTRICT',
|
||||
required=True)
|
||||
# class BookingSale(ModelSQL):
|
||||
# 'Booking - Sale'
|
||||
# __name__ = 'hotel.booking-sale.sale'
|
||||
# _table = 'booking_sales_rel'
|
||||
# booking = fields.Many2One('hotel.booking', 'Booking', ondelete='CASCADE',
|
||||
# required=True)
|
||||
# sale = fields.Many2One('sale.sale', 'Sale', ondelete='RESTRICT',
|
||||
# required=True)
|
||||
|
||||
|
||||
class BookingVoucher(ModelSQL):
|
||||
|
|
|
@ -55,10 +55,8 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="comments" colspan="4"/>
|
||||
</page>
|
||||
<page string="Operations" id="operations">
|
||||
<!-- <field name="sales" colspan="4"/> -->
|
||||
<label name="invoice_method"/>
|
||||
<field name="invoice_method"/>
|
||||
<field name="operations" colspan="4"/>
|
||||
</page>
|
||||
<page string="Channel Manager" id="channel_manager">
|
||||
<label name="booker"/>
|
||||
|
|
Loading…
Reference in New Issue