diff --git a/constants.py b/constants.py
index 298c4e2..2887093 100644
--- a/constants.py
+++ b/constants.py
@@ -94,6 +94,7 @@ COMPLEMENTARY = [
]
INVOICE_STATES = [
+ ('', 'None'),
('draft', 'Draft'),
('validated', 'Validated'),
('posted', 'Posted'),
diff --git a/folio.py b/folio.py
index 80c061a..96e0845 100644
--- a/folio.py
+++ b/folio.py
@@ -111,6 +111,9 @@ class Folio(ModelSQL, ModelView):
'readonly': Eval('registration_state').in_(['check_out']),
})
invoice_line = fields.Many2One('account.invoice.line', 'Invoice Line')
+ to_invoice = fields.Boolean('To Invoice', states={
+ 'invisible': Bool(Eval('invoice_line')),
+ }, depends=['invoice_line'])
invoice = fields.Function(fields.Many2One('account.invoice', 'Invoice',
depends=['invoice_line']), 'get_invoice')
invoice_state = fields.Function(fields.Selection(
@@ -187,6 +190,7 @@ class Folio(ModelSQL, ModelView):
raise UserError(gettext('hotel.msg_missing_select_room'))
rec.set_registration_number()
rec.booking.check_rooms()
+ rec.add_main_guest()
cls.write(records, {'registration_state': 'check_in'})
@classmethod
@@ -208,6 +212,10 @@ class Folio(ModelSQL, ModelView):
def pay(cls, records):
pass
+ @staticmethod
+ def default_to_invoice():
+ return True
+
def get_invoice_state(self, name=None):
if self.invoice_line:
return self.invoice_line.invoice.state
@@ -228,6 +236,16 @@ class Folio(ModelSQL, ModelView):
self.registration_card = number
self.save()
+ def add_main_guest(self):
+ pool = Pool()
+ Guest = pool.get('hotel.folio.guest')
+ Guest.create([{
+ 'folio': self.id,
+ 'party': self.main_guest.id,
+ 'type_guest': 'adult',
+ 'type_document': 13,
+ }])
+
@classmethod
def create_invoice(cls, record):
pool = Pool()
@@ -640,12 +658,12 @@ class Folio(ModelSQL, ModelView):
TODO: If room fee is applied should be used for total price calculation
instead of flat price. Fee is linked to channel management.
"""
- res = _ZERO
- if self.nights_quantity and self.unit_price:
- res = self.nights_quantity * self.unit_price_w_tax
+ res = []
+ if self.nights_quantity and self.unit_price_w_tax:
+ res = [self.nights_quantity * self.unit_price_w_tax]
for charge in self.charges:
- res += charge.amount
- res = round(res, Folio.total_amount.digits[1])
+ res.append(charge.amount)
+ res = round(sum(res), Folio.total_amount.digits[1])
return res
def get_channel_commission(self, name):
@@ -869,6 +887,9 @@ class HotelCharge(Workflow, ModelSQL, ModelView):
digits=(16, 2)), 'get_amount')
taxed_amount = fields.Function(fields.Numeric('Amount with Tax',
digits=(16, 2)), 'get_taxed_amount')
+ to_invoice = fields.Boolean('To Invoice', states={
+ 'invisible': Bool(Eval('invoice_line')),
+ }, depends=['invoice_line'])
@classmethod
def __setup__(cls):
@@ -886,6 +907,10 @@ class HotelCharge(Workflow, ModelSQL, ModelView):
def default_quantity():
return 1
+ @staticmethod
+ def default_to_invoice():
+ return True
+
@staticmethod
def default_date_service():
today = Pool().get('ir.date').today()
diff --git a/service.py b/service.py
index 8b4da34..f3f032e 100644
--- a/service.py
+++ b/service.py
@@ -159,7 +159,7 @@ class ServiceLine(Workflow, ModelSQL, ModelView):
states={'readonly': True})
folio = fields.Many2One('hotel.folio', 'Folio', domain=[
('room', '=', Eval('room')),
- ('registration_state', 'in', 'check_in')
+ ('registration_state', '=', 'check_in')
], depends=['room'])
state = fields.Selection([
('draft', 'Draft'),
@@ -252,6 +252,7 @@ class ServiceLine(Workflow, ModelSQL, ModelView):
'invoice_to': self.folio.main_guest.id,
'unit_price': self.product.template.list_price,
'product': self.product.id,
+ 'state': '',
}
line, = FolioCharge.create([new_line])
@@ -302,7 +303,7 @@ class CreateDailyServices(Wizard):
folios = Folio.search([
('arrival_date', '<', self.start.date),
# ('departure_date', '<', self.start.date),
- ('registration_state', 'in', ['check_in', 'check_out']),
+ ('registration_state', 'in', ['check_in']),
])
print('folios...', folios)
@@ -315,17 +316,8 @@ class CreateDailyServices(Wizard):
Service.open([service])
product = self.start.kind.product
for fol in folios:
- print('fol.breakfast_included... ', fol.breakfast_included)
if not fol.breakfast_included:
continue
- lines_to_create.append({
- 'service': service.id,
- 'folio': fol.id,
- 'room': fol.room.id,
- 'guest': fol.main_guest.name,
- 'product': product.id,
- 'quantity': 1,
- })
for guest in fol.guests:
lines_to_create.append({
'folio': fol.id,
diff --git a/view/board_folio_form.xml b/view/board_folio_form.xml
index a805b69..dab5861 100644
--- a/view/board_folio_form.xml
+++ b/view/board_folio_form.xml
@@ -51,15 +51,18 @@ 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 3bf5fd3..bc1d78f 100644
--- a/view/booking_folio_form.xml
+++ b/view/booking_folio_form.xml
@@ -6,6 +6,8 @@ this repository contains the full copyright notices and license terms. -->
+
+
@@ -16,8 +18,6 @@ this repository contains the full copyright notices and license terms. -->
-
-
@@ -42,13 +42,20 @@ this repository contains the full copyright notices and license terms. -->
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
diff --git a/view/folio_charge_form.xml b/view/folio_charge_form.xml
index 7f2e216..6eff207 100644
--- a/view/folio_charge_form.xml
+++ b/view/folio_charge_form.xml
@@ -22,6 +22,8 @@ this repository contains the full copyright notices and license terms. -->
+
+
diff --git a/view/folio_charge_tree.xml b/view/folio_charge_tree.xml
index 2a402ae..5e2f150 100644
--- a/view/folio_charge_tree.xml
+++ b/view/folio_charge_tree.xml
@@ -3,6 +3,7 @@
this repository contains the full copyright notices and license terms. -->
+