Factory 10
This commit is contained in:
parent
a19e3f2e59
commit
6cbace0a08
|
@ -94,6 +94,7 @@ COMPLEMENTARY = [
|
|||
]
|
||||
|
||||
INVOICE_STATES = [
|
||||
('', 'None'),
|
||||
('draft', 'Draft'),
|
||||
('validated', 'Validated'),
|
||||
('posted', 'Posted'),
|
||||
|
|
35
folio.py
35
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()
|
||||
|
|
14
service.py
14
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,
|
||||
|
|
|
@ -51,15 +51,18 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="notes" colspan="4"/>
|
||||
</page>
|
||||
</notebook>
|
||||
<group col="8" colspan="6" id="state_buttons">
|
||||
<group col="6" colspan="6" id="state_buttons">
|
||||
<label name="registration_state"/>
|
||||
<field name="registration_state"/>
|
||||
<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"/>
|
||||
<newline />
|
||||
<label name="invoice"/>
|
||||
<field name="invoice"/>
|
||||
<label name="invoice_state"/>
|
||||
|
|
|
@ -6,6 +6,8 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="product" widget="selection"/>
|
||||
<label name="main_guest"/>
|
||||
<field name="main_guest"/>
|
||||
<label name="registration_card"/>
|
||||
<field name="registration_card"/>
|
||||
<label name="room"/>
|
||||
<field name="room" widget="selection"/>
|
||||
<label name="arrival_date"/>
|
||||
|
@ -16,8 +18,6 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="nights_quantity"/>
|
||||
<label name="unit_price"/>
|
||||
<field name="unit_price"/>
|
||||
<label name="total_amount"/>
|
||||
<field name="total_amount"/>
|
||||
<label name="host_quantity"/>
|
||||
<field name="host_quantity"/>
|
||||
<label name="breakfast_included"/>
|
||||
|
@ -42,13 +42,20 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="notes" colspan="4"/>
|
||||
</page>
|
||||
</notebook>
|
||||
<label name="registration_state"/>
|
||||
<field name="registration_state"/>
|
||||
<group col="2" colspan="2" id="state_buttons">
|
||||
<button name="bill" string="Bill" icon="tryton-forward"/>
|
||||
<group col="8" colspan="6" id="state_buttons">
|
||||
<label name="registration_state"/>
|
||||
<field name="registration_state"/>
|
||||
<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>
|
||||
<label name="invoice"/>
|
||||
<field name="invoice"/>
|
||||
<label name="invoice_state"/>
|
||||
<field name="invoice_state"/>
|
||||
</form>
|
||||
|
|
|
@ -22,6 +22,8 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="amount"/>
|
||||
<label name="invoice_line"/>
|
||||
<field name="invoice_line"/>
|
||||
<label name="to_invoice"/>
|
||||
<field name="to_invoice"/>
|
||||
<label name="state"/>
|
||||
<field name="state"/>
|
||||
<!-- <button name="transfer" string="Transfer"/> -->
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
this repository contains the full copyright notices and license terms. -->
|
||||
<tree editable="1">
|
||||
<field name="date_service"/>
|
||||
<field name="to_invoice"/>
|
||||
<field name="product"/>
|
||||
<field name="description"/>
|
||||
<field name="quantity"/>
|
||||
|
|
Loading…
Reference in New Issue