diff --git a/booking.py b/booking.py
index 8f6025c..6d791b3 100644
--- a/booking.py
+++ b/booking.py
@@ -194,7 +194,7 @@ class Booking(Workflow, ModelSQL, ModelView):
},
'bill_to_channel': {
'invisible': ~Eval('channel'),
- 'readonly': Eval('channel_paymode') != 'ota_collect',
+ 'readonly': (Eval('channel_paymode') != 'ota_collect') | Eval('channel_invoice', True),
},
})
@@ -212,6 +212,22 @@ class Booking(Workflow, ModelSQL, ModelView):
default['booking_date'] = datetime.now()
return super(Booking, cls).copy(bookings, default=default)
+ @classmethod
+ def search_rec_name(cls, name, clause):
+ _, operator, value = clause
+ if operator.startswith('!') or operator.startswith('not '):
+ bool_op = 'AND'
+ else:
+ bool_op = 'OR'
+ domain = [
+ bool_op,
+ ('number', operator, value),
+ ('ota_booking_code', operator, value),
+ ('party.name', operator, value),
+ ('contact', operator, value),
+ ]
+ return domain
+
@staticmethod
def default_currency():
Company = Pool().get('company.company')
@@ -249,6 +265,12 @@ class Booking(Workflow, ModelSQL, ModelView):
res += line.num_children
return res
+ @fields.depends('ota_booking_code', 'lines')
+ def on_change_ota_booking_code(self):
+ if self.ota_booking_code:
+ for line in self.lines:
+ line.reference = self.ota_booking_code
+
@fields.depends('party', 'price_list', 'lines')
def on_change_party(self):
if self.party:
@@ -422,7 +444,6 @@ class Booking(Workflow, ModelSQL, ModelView):
raise UserError(gettext('hotel.msg_customer_is_required'))
bk = fo.booking
- print(' fo.booking ....', fo.booking)
agent_id = bk.channel.agent.id if bk.channel else None
if party.id not in res.keys():
# Add room product to sale
@@ -481,8 +502,6 @@ class Booking(Workflow, ModelSQL, ModelView):
'reference': charge.folio.registration_card,
'lines': [],
}
- # if invoice_party_id != bk.party.id:
- # else:
res[invoice_party_id]['lines'].append({
'description': ' | '.join([
@@ -817,13 +836,6 @@ class Booking(Workflow, ModelSQL, ModelView):
res += line.total_amount
return res
- # def get_occupancies(self, name):
- # occupancies = set()
- # for line in self.lines:
- # if line.occupancy_line:
- # occupancies.add(line.occupancy_line.id)
- # return list(occupancies)
-
def get_channel_commission(self, name):
res = sum(line.commission_amount for line in self.lines if
line.commission_amount)
@@ -978,6 +990,8 @@ class SelectRooms(Wizard):
values = {
'booking': booking.id,
'product': product.id,
+ 'reference': booking.ota_booking_code,
+ 'contact': booking.contact,
'room': room.id,
'arrival_date': self.start.arrival_date,
'departure_date': self.start.departure_date,
diff --git a/folio.py b/folio.py
index 2d5bf1a..3075c55 100644
--- a/folio.py
+++ b/folio.py
@@ -57,14 +57,17 @@ _ZERO = Decimal('0')
class Folio(ModelSQL, ModelView):
'Folio'
__name__ = 'hotel.folio'
- booking = fields.Many2One('hotel.booking', 'Booking', ondelete='CASCADE',
- select=True)
- registration_card = fields.Char('Registration Card', readonly=True,
- select=True, help="Unique sequence for card guest registration.")
- room = fields.Many2One('hotel.room', 'Room', select=True, states={
+ STATES = {
'required': Eval('registration_state') == 'check_in',
'readonly': Eval('registration_state') == 'check_in',
- })
+ }
+ booking = fields.Many2One('hotel.booking', 'Booking', ondelete='CASCADE',
+ select=True)
+ reference = fields.Char('Reference', states=STATES)
+ registration_card = fields.Char('Registration Card', readonly=True,
+ select=True, help="Unique sequence for card guest registration.")
+ room = fields.Many2One('hotel.room', 'Room', select=True,
+ states=STATES_CHECKIN)
arrival_date = fields.Date('Arrival Date', required=True,
states=STATES_CHECKOUT)
departure_date = fields.Date('Departure Date', required=True,
@@ -83,10 +86,7 @@ class Folio(ModelSQL, ModelView):
'get_unit_price_w_tax')
uom = fields.Many2One('product.uom', 'UOM', readonly=True)
main_guest = fields.Many2One('party.party', 'Main Guest', select=True,
- states={
- 'required': Eval('registration_state') == 'check_in',
- 'readonly': Eval('registration_state') == 'check_in',
- }
+ states=STATES_CHECKIN
)
contact = fields.Char('Contact', states=STATES_CHECKIN)
num_children = fields.Function(fields.Integer('No. Children'),
@@ -143,10 +143,11 @@ class Folio(ModelSQL, ModelView):
), 'on_change_with_room_amount')
stock_moves = fields.Many2Many('hotel.folio-stock.move', 'folio',
'move', 'Stock Moves', states={'readonly': True})
+ channel = fields.Function(fields.Many2One('hotel.channel', 'Channel'),
+ 'get_channel')
@classmethod
def __setup__(cls):
- # UPDATE hotel_folio SET nights_quantity=(departure_date-arrival_date)
super(Folio, cls).__setup__()
cls._check_modify_exclude = [
'nationality', 'origin_country', 'target_country',
@@ -190,6 +191,7 @@ class Folio(ModelSQL, ModelView):
('registration_card', operator, value),
('product.name', operator, value),
('party.name', operator, value),
+ ('reference', operator, value),
]
return domain
@@ -246,6 +248,10 @@ class Folio(ModelSQL, ModelView):
if self.invoice_line:
return self.invoice_line.invoice.state
+ def get_channel(self, name=None):
+ if self.booking and self.booking.channel:
+ return self.booking.channel.id
+
def set_registration_number(self):
"""
Fill the number field for registration card with sequence
@@ -875,8 +881,8 @@ class Migration(Report):
('arrival_date', '>=', start),
('arrival_date', '<=', end),
('main_guest', '!=', None),
- ('registration_state', 'in', ['check_in', 'check_out']),
('guests.party', '!=', None),
+ ('registration_state', 'in', ['check_in', 'check_out']),
])
return report_context
diff --git a/migration_report.fods b/migration_report.fods
index 6d0491e..2481003 100644
Binary files a/migration_report.fods and b/migration_report.fods differ
diff --git a/patch.sql b/patch.sql
index abf2bf1..13ea5b1 100644
--- a/patch.sql
+++ b/patch.sql
@@ -2,3 +2,4 @@
ALTER TABLE hotel_channel DROP COLUMN commission;
ALTER TABLE hotel_channel DROP COLUMN payment_method;
ALTER TABLE hotel_booking RENAME COLUMN party_seller TO channel;
+UPDATE hotel_folio SET nights_quantity=(departure_date-arrival_date)
diff --git a/view/board_folio_form.xml b/view/board_folio_form.xml
index 4bdc776..a92f33d 100644
--- a/view/board_folio_form.xml
+++ b/view/board_folio_form.xml
@@ -28,6 +28,8 @@ this repository contains the full copyright notices and license terms. -->
+
+
diff --git a/view/board_folio_tree.xml b/view/board_folio_tree.xml
index 35a7995..3587af2 100644
--- a/view/board_folio_tree.xml
+++ b/view/board_folio_tree.xml
@@ -7,10 +7,13 @@ this repository contains the full copyright notices and license terms. -->
+
+
+
diff --git a/view/booking_folio_form.xml b/view/booking_folio_form.xml
index c03ee94..17d9144 100644
--- a/view/booking_folio_form.xml
+++ b/view/booking_folio_form.xml
@@ -30,6 +30,8 @@ this repository contains the full copyright notices and license terms. -->
+
+
diff --git a/view/booking_form.xml b/view/booking_form.xml
index 7699992..7bd5fbe 100644
--- a/view/booking_form.xml
+++ b/view/booking_form.xml
@@ -20,10 +20,10 @@ this repository contains the full copyright notices and license terms. -->
-
-
+
+
diff --git a/view/booking_tree.xml b/view/booking_tree.xml
index 1526e23..421add7 100644
--- a/view/booking_tree.xml
+++ b/view/booking_tree.xml
@@ -6,8 +6,8 @@ this repository contains the full copyright notices and license terms. -->
-
+