diff --git a/__init__.py b/__init__.py index 5ea8a19..6be4b11 100644 --- a/__init__.py +++ b/__init__.py @@ -28,7 +28,6 @@ def register(): room.RoomTemplate, city.MigrationCity, location.HotelLocation, - channel.SaleChannel, policy.HotelPolicyCancellation, company.Company, configuration.ConfigurationProduct, @@ -41,12 +40,15 @@ def register(): housekeeping.Housekeeping, housekeeping.HousekeepingCleaningType, party.Party, + channel.SaleChannel, channel.ChannelTax, + channel.ChannelCommission, booking.SelectRoomsAsk, booking.BookingVoucher, booking.RoomsOccupancyStart, booking.BookingForecastStart, booking.UpdateHolderStart, + booking.BookingChannelCommision, folio.FolioGuest, folio.GuestsListStart, folio.StatisticsByMonthStart, diff --git a/booking.py b/booking.py index bc741f1..1ab707f 100644 --- a/booking.py +++ b/booking.py @@ -154,6 +154,10 @@ class Booking(Workflow, ModelSQL, ModelView): ) invoices = fields.Function(fields.Many2Many('account.invoice', None, None, 'Invoices'), 'get_invoices') + extra_commissions = fields.Many2Many('hotel.booking-channel.commission', + 'booking', 'commission', 'Channel Commission', domain=[ + ('channel', '=', Eval('channel')) + ]) @classmethod def __setup__(cls): @@ -1716,6 +1720,15 @@ class ManagerReport(Report): report_context['guests_by_city'] = guests_by_city.values() report_context['company'] = Company(data['company']) user_id = Transaction().context.get('user') - print(user_id) report_context['user'] = User(user_id) return report_context + + +class BookingChannelCommision(ModelSQL): + 'Booking Channel Commision' + __name__ = 'hotel.booking-channel.commission' + _table = 'hotel_booking_channel_commission_rel' + commission = fields.Many2One('hotel.channel.commission', 'Channel Commission', + ondelete='CASCADE', select=True, required=True) + booking = fields.Many2One('hotel.booking', 'Booking', ondelete='RESTRICT', + required=True) diff --git a/channel.py b/channel.py index 86cb293..6b6c7a9 100644 --- a/channel.py +++ b/channel.py @@ -8,6 +8,15 @@ from trytond.pool import Pool from .constants import PAYMENT_METHOD_CHANNEL +class ChannelCommission(ModelSQL, ModelView): + 'Channel Commission Extra' + __name__ = 'hotel.channel.commission' + channel = fields.Many2One('hotel.channel', 'Sale Channel', + ondelete='CASCADE', select=True, required=True) + name = fields.Char('Name', required=True) + commission = fields.Float('Commission', required=True, digits=(4, 2)) + + class SaleChannel(ModelSQL, ModelView): 'Sale Channel' __name__ = 'hotel.channel' @@ -45,15 +54,17 @@ class SaleChannel(ModelSQL, ModelView): ] ) currency = fields.Many2One('currency.currency', 'Currency', - required=True) + required=True) price_list = fields.Many2One('product.price_list', 'Price List') - payment_method = fields.Selection(PAYMENT_METHOD_CHANNEL, - 'Payment Method') + payment_method = fields.Selection(PAYMENT_METHOD_CHANNEL, 'Payment Method') collection_mode = fields.Selection([ ('', ''), ('anticipated', 'Anticipated'), ('after_sale', 'After-Sale'), - ], 'Collection Mode', required=False, help="Commission collection mode") + ], 'Collection Mode', required=False, + help="Commission collection mode") + extra_commissions = fields.One2Many('hotel.channel.commission', + 'channel', 'Extra Commissions') @staticmethod def default_company(): diff --git a/channel.xml b/channel.xml index 065fcea..7c2a9e4 100644 --- a/channel.xml +++ b/channel.xml @@ -4,6 +4,17 @@ this repository contains the full copyright notices and license terms. --> + + hotel.channel.commission + tree + channel_commission_tree + + + hotel.channel.commission + form + channel_commission_form + + hotel.channel tree diff --git a/view/booking_form.xml b/view/booking_form.xml index be23854..98af860 100644 --- a/view/booking_form.xml +++ b/view/booking_form.xml @@ -75,6 +75,7 @@ this repository contains the full copyright notices and license terms. -->