Factory 10
This commit is contained in:
parent
a19e3f2e59
commit
6cbace0a08
|
@ -94,6 +94,7 @@ COMPLEMENTARY = [
|
||||||
]
|
]
|
||||||
|
|
||||||
INVOICE_STATES = [
|
INVOICE_STATES = [
|
||||||
|
('', 'None'),
|
||||||
('draft', 'Draft'),
|
('draft', 'Draft'),
|
||||||
('validated', 'Validated'),
|
('validated', 'Validated'),
|
||||||
('posted', 'Posted'),
|
('posted', 'Posted'),
|
||||||
|
|
35
folio.py
35
folio.py
|
@ -111,6 +111,9 @@ class Folio(ModelSQL, ModelView):
|
||||||
'readonly': Eval('registration_state').in_(['check_out']),
|
'readonly': Eval('registration_state').in_(['check_out']),
|
||||||
})
|
})
|
||||||
invoice_line = fields.Many2One('account.invoice.line', 'Invoice Line')
|
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',
|
invoice = fields.Function(fields.Many2One('account.invoice', 'Invoice',
|
||||||
depends=['invoice_line']), 'get_invoice')
|
depends=['invoice_line']), 'get_invoice')
|
||||||
invoice_state = fields.Function(fields.Selection(
|
invoice_state = fields.Function(fields.Selection(
|
||||||
|
@ -187,6 +190,7 @@ class Folio(ModelSQL, ModelView):
|
||||||
raise UserError(gettext('hotel.msg_missing_select_room'))
|
raise UserError(gettext('hotel.msg_missing_select_room'))
|
||||||
rec.set_registration_number()
|
rec.set_registration_number()
|
||||||
rec.booking.check_rooms()
|
rec.booking.check_rooms()
|
||||||
|
rec.add_main_guest()
|
||||||
cls.write(records, {'registration_state': 'check_in'})
|
cls.write(records, {'registration_state': 'check_in'})
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -208,6 +212,10 @@ class Folio(ModelSQL, ModelView):
|
||||||
def pay(cls, records):
|
def pay(cls, records):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_to_invoice():
|
||||||
|
return True
|
||||||
|
|
||||||
def get_invoice_state(self, name=None):
|
def get_invoice_state(self, name=None):
|
||||||
if self.invoice_line:
|
if self.invoice_line:
|
||||||
return self.invoice_line.invoice.state
|
return self.invoice_line.invoice.state
|
||||||
|
@ -228,6 +236,16 @@ class Folio(ModelSQL, ModelView):
|
||||||
self.registration_card = number
|
self.registration_card = number
|
||||||
self.save()
|
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
|
@classmethod
|
||||||
def create_invoice(cls, record):
|
def create_invoice(cls, record):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
|
@ -640,12 +658,12 @@ class Folio(ModelSQL, ModelView):
|
||||||
TODO: If room fee is applied should be used for total price calculation
|
TODO: If room fee is applied should be used for total price calculation
|
||||||
instead of flat price. Fee is linked to channel management.
|
instead of flat price. Fee is linked to channel management.
|
||||||
"""
|
"""
|
||||||
res = _ZERO
|
res = []
|
||||||
if self.nights_quantity and self.unit_price:
|
if self.nights_quantity and self.unit_price_w_tax:
|
||||||
res = self.nights_quantity * self.unit_price_w_tax
|
res = [self.nights_quantity * self.unit_price_w_tax]
|
||||||
for charge in self.charges:
|
for charge in self.charges:
|
||||||
res += charge.amount
|
res.append(charge.amount)
|
||||||
res = round(res, Folio.total_amount.digits[1])
|
res = round(sum(res), Folio.total_amount.digits[1])
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def get_channel_commission(self, name):
|
def get_channel_commission(self, name):
|
||||||
|
@ -869,6 +887,9 @@ class HotelCharge(Workflow, ModelSQL, ModelView):
|
||||||
digits=(16, 2)), 'get_amount')
|
digits=(16, 2)), 'get_amount')
|
||||||
taxed_amount = fields.Function(fields.Numeric('Amount with Tax',
|
taxed_amount = fields.Function(fields.Numeric('Amount with Tax',
|
||||||
digits=(16, 2)), 'get_taxed_amount')
|
digits=(16, 2)), 'get_taxed_amount')
|
||||||
|
to_invoice = fields.Boolean('To Invoice', states={
|
||||||
|
'invisible': Bool(Eval('invoice_line')),
|
||||||
|
}, depends=['invoice_line'])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __setup__(cls):
|
def __setup__(cls):
|
||||||
|
@ -886,6 +907,10 @@ class HotelCharge(Workflow, ModelSQL, ModelView):
|
||||||
def default_quantity():
|
def default_quantity():
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_to_invoice():
|
||||||
|
return True
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_date_service():
|
def default_date_service():
|
||||||
today = Pool().get('ir.date').today()
|
today = Pool().get('ir.date').today()
|
||||||
|
|
14
service.py
14
service.py
|
@ -159,7 +159,7 @@ class ServiceLine(Workflow, ModelSQL, ModelView):
|
||||||
states={'readonly': True})
|
states={'readonly': True})
|
||||||
folio = fields.Many2One('hotel.folio', 'Folio', domain=[
|
folio = fields.Many2One('hotel.folio', 'Folio', domain=[
|
||||||
('room', '=', Eval('room')),
|
('room', '=', Eval('room')),
|
||||||
('registration_state', 'in', 'check_in')
|
('registration_state', '=', 'check_in')
|
||||||
], depends=['room'])
|
], depends=['room'])
|
||||||
state = fields.Selection([
|
state = fields.Selection([
|
||||||
('draft', 'Draft'),
|
('draft', 'Draft'),
|
||||||
|
@ -252,6 +252,7 @@ class ServiceLine(Workflow, ModelSQL, ModelView):
|
||||||
'invoice_to': self.folio.main_guest.id,
|
'invoice_to': self.folio.main_guest.id,
|
||||||
'unit_price': self.product.template.list_price,
|
'unit_price': self.product.template.list_price,
|
||||||
'product': self.product.id,
|
'product': self.product.id,
|
||||||
|
'state': '',
|
||||||
}
|
}
|
||||||
|
|
||||||
line, = FolioCharge.create([new_line])
|
line, = FolioCharge.create([new_line])
|
||||||
|
@ -302,7 +303,7 @@ class CreateDailyServices(Wizard):
|
||||||
folios = Folio.search([
|
folios = Folio.search([
|
||||||
('arrival_date', '<', self.start.date),
|
('arrival_date', '<', self.start.date),
|
||||||
# ('departure_date', '<', self.start.date),
|
# ('departure_date', '<', self.start.date),
|
||||||
('registration_state', 'in', ['check_in', 'check_out']),
|
('registration_state', 'in', ['check_in']),
|
||||||
])
|
])
|
||||||
print('folios...', folios)
|
print('folios...', folios)
|
||||||
|
|
||||||
|
@ -315,17 +316,8 @@ class CreateDailyServices(Wizard):
|
||||||
Service.open([service])
|
Service.open([service])
|
||||||
product = self.start.kind.product
|
product = self.start.kind.product
|
||||||
for fol in folios:
|
for fol in folios:
|
||||||
print('fol.breakfast_included... ', fol.breakfast_included)
|
|
||||||
if not fol.breakfast_included:
|
if not fol.breakfast_included:
|
||||||
continue
|
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:
|
for guest in fol.guests:
|
||||||
lines_to_create.append({
|
lines_to_create.append({
|
||||||
'folio': fol.id,
|
'folio': fol.id,
|
||||||
|
|
|
@ -51,15 +51,18 @@ this repository contains the full copyright notices and license terms. -->
|
||||||
<field name="notes" colspan="4"/>
|
<field name="notes" colspan="4"/>
|
||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
<group col="8" colspan="6" id="state_buttons">
|
<group col="6" colspan="6" id="state_buttons">
|
||||||
<label name="registration_state"/>
|
<label name="registration_state"/>
|
||||||
<field name="registration_state"/>
|
<field name="registration_state"/>
|
||||||
<label name="total_amount"/>
|
<label name="total_amount"/>
|
||||||
<field name="total_amount"/>
|
<field name="total_amount"/>
|
||||||
|
<label name="to_invoice"/>
|
||||||
|
<field name="to_invoice"/>
|
||||||
<button name="check_in" string="Check In"/>
|
<button name="check_in" string="Check In"/>
|
||||||
<button name="check_out" string="Check Out"/>
|
<button name="check_out" string="Check Out"/>
|
||||||
<button name="bill" string="Bill"/>
|
<button name="bill" string="Bill"/>
|
||||||
<button name="pay" string="Pay"/>
|
<button name="pay" string="Pay"/>
|
||||||
|
<newline />
|
||||||
<label name="invoice"/>
|
<label name="invoice"/>
|
||||||
<field name="invoice"/>
|
<field name="invoice"/>
|
||||||
<label name="invoice_state"/>
|
<label name="invoice_state"/>
|
||||||
|
|
|
@ -6,6 +6,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||||
<field name="product" widget="selection"/>
|
<field name="product" widget="selection"/>
|
||||||
<label name="main_guest"/>
|
<label name="main_guest"/>
|
||||||
<field name="main_guest"/>
|
<field name="main_guest"/>
|
||||||
|
<label name="registration_card"/>
|
||||||
|
<field name="registration_card"/>
|
||||||
<label name="room"/>
|
<label name="room"/>
|
||||||
<field name="room" widget="selection"/>
|
<field name="room" widget="selection"/>
|
||||||
<label name="arrival_date"/>
|
<label name="arrival_date"/>
|
||||||
|
@ -16,8 +18,6 @@ this repository contains the full copyright notices and license terms. -->
|
||||||
<field name="nights_quantity"/>
|
<field name="nights_quantity"/>
|
||||||
<label name="unit_price"/>
|
<label name="unit_price"/>
|
||||||
<field name="unit_price"/>
|
<field name="unit_price"/>
|
||||||
<label name="total_amount"/>
|
|
||||||
<field name="total_amount"/>
|
|
||||||
<label name="host_quantity"/>
|
<label name="host_quantity"/>
|
||||||
<field name="host_quantity"/>
|
<field name="host_quantity"/>
|
||||||
<label name="breakfast_included"/>
|
<label name="breakfast_included"/>
|
||||||
|
@ -42,13 +42,20 @@ this repository contains the full copyright notices and license terms. -->
|
||||||
<field name="notes" colspan="4"/>
|
<field name="notes" colspan="4"/>
|
||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
<label name="registration_state"/>
|
<group col="8" colspan="6" id="state_buttons">
|
||||||
<field name="registration_state"/>
|
<label name="registration_state"/>
|
||||||
<group col="2" colspan="2" id="state_buttons">
|
<field name="registration_state"/>
|
||||||
<button name="bill" string="Bill" icon="tryton-forward"/>
|
<label name="total_amount"/>
|
||||||
|
<field name="total_amount"/>
|
||||||
|
<label name="to_invoice"/>
|
||||||
|
<field name="to_invoice"/>
|
||||||
|
<button name="check_in" string="Check In"/>
|
||||||
|
<button name="check_out" string="Check Out"/>
|
||||||
|
<button name="bill" string="Bill"/>
|
||||||
|
<button name="pay" string="Pay"/>
|
||||||
|
<label name="invoice"/>
|
||||||
|
<field name="invoice"/>
|
||||||
|
<label name="invoice_state"/>
|
||||||
|
<field name="invoice_state"/>
|
||||||
</group>
|
</group>
|
||||||
<label name="invoice"/>
|
|
||||||
<field name="invoice"/>
|
|
||||||
<label name="invoice_state"/>
|
|
||||||
<field name="invoice_state"/>
|
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -22,6 +22,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
<label name="invoice_line"/>
|
<label name="invoice_line"/>
|
||||||
<field name="invoice_line"/>
|
<field name="invoice_line"/>
|
||||||
|
<label name="to_invoice"/>
|
||||||
|
<field name="to_invoice"/>
|
||||||
<label name="state"/>
|
<label name="state"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<!-- <button name="transfer" string="Transfer"/> -->
|
<!-- <button name="transfer" string="Transfer"/> -->
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
this repository contains the full copyright notices and license terms. -->
|
this repository contains the full copyright notices and license terms. -->
|
||||||
<tree editable="1">
|
<tree editable="1">
|
||||||
<field name="date_service"/>
|
<field name="date_service"/>
|
||||||
|
<field name="to_invoice"/>
|
||||||
<field name="product"/>
|
<field name="product"/>
|
||||||
<field name="description"/>
|
<field name="description"/>
|
||||||
<field name="quantity"/>
|
<field name="quantity"/>
|
||||||
|
|
Loading…
Reference in New Issue