mirror of
https://bitbucket.org/presik/trytonpsk-hotel.git
synced 2023-12-14 07:52:52 +01:00
Fix services
This commit is contained in:
parent
d2ddb3c3dc
commit
d04c5c936c
4
folio.py
4
folio.py
|
@ -119,7 +119,9 @@ class Folio(ModelSQL, ModelView):
|
|||
'invisible': ~Bool(Eval('complementary')),
|
||||
'required': Bool(Eval('complementary')),
|
||||
})
|
||||
breakfast_included = fields.Boolean('Breakfast Included')
|
||||
breakfast_included = fields.Boolean('Breakfast Included', states={
|
||||
'readonly': Eval('registration_state') != 'check_in',
|
||||
})
|
||||
room_amount = fields.Function(fields.Numeric('Room Amount',
|
||||
digits=(16, 2)), 'get_room_amount')
|
||||
stock_moves = fields.Many2Many('hotel.folio-stock.move', 'folio',
|
||||
|
|
80
service.py
80
service.py
|
@ -152,21 +152,12 @@ class ServiceLine(Workflow, ModelSQL, ModelView):
|
|||
quantity = fields.Integer('Quantity', required=True, states=STATES_LINE)
|
||||
description = fields.Char('Description', states=STATES_LINE)
|
||||
order = fields.Char('Order', select=True, states=STATES_LINE)
|
||||
invoice_line = fields.Many2One('account.invoice.line', 'Invoice Line',
|
||||
folio_line = fields.Many2One('hotel.folio', 'Folio Line',
|
||||
states={'readonly': True})
|
||||
guest = fields.Many2One('hotel.folio.guest', 'Guest', states=STATES_LINE,
|
||||
domain=[
|
||||
('folio.room', '=', Eval('room')),
|
||||
# ('operation.start_date', '<=', Eval('')),
|
||||
('id', 'in', Eval('current_guests')),
|
||||
], depends=['current_guests'])
|
||||
guest = fields.Char('Guest', states=STATES_LINE)
|
||||
charge = fields.Many2One('hotel.folio.charge', 'Operation Line',
|
||||
states={'readonly': True})
|
||||
current_guests = fields.Function(fields.Many2Many(
|
||||
'hotel.folio.guest', None, None, 'Current Guests'),
|
||||
'on_change_with_current_guests')
|
||||
folio = fields.Function(fields.Many2One('hotel.folio',
|
||||
'Folio'), 'get_folio')
|
||||
folio = fields.Many2One('hotel.folio', 'Folio')
|
||||
state = fields.Selection([
|
||||
('draft', 'Draft'),
|
||||
('loaded', 'Loaded'),
|
||||
|
@ -234,62 +225,37 @@ class ServiceLine(Workflow, ModelSQL, ModelView):
|
|||
def done(cls, records):
|
||||
pass
|
||||
|
||||
@fields.depends('room')
|
||||
def on_change_with_current_guests(self, name=None):
|
||||
Folio = Pool().get('hotel.folio')
|
||||
if self.room:
|
||||
operations = Folio.search([
|
||||
('room', '=', self.room.id),
|
||||
('state', '=', 'check_in'),
|
||||
])
|
||||
guests = []
|
||||
for op in operations:
|
||||
guests.extend([g.id for g in op.guests])
|
||||
|
||||
return guests
|
||||
|
||||
def get_folio(self, name=None):
|
||||
if self.folio_line:
|
||||
return self.folio_line.folio.id
|
||||
|
||||
def add_product_to_room(self):
|
||||
pool = Pool()
|
||||
Folio = pool.get('hotel.folio')
|
||||
# Folio = pool.get('hotel.folio')
|
||||
FolioCharge = pool.get('hotel.folio.charge')
|
||||
if self.invoice_line:
|
||||
if self.folio_line:
|
||||
return
|
||||
|
||||
dom = [
|
||||
('room', '=', self.room.id),
|
||||
('state', '=', 'open'),
|
||||
('start_date', '<=', self.service.service_date),
|
||||
('end_date', '>=', self.service.service_date),
|
||||
]
|
||||
if self.guest:
|
||||
dom.append(('guests', '=', self.guest.id))
|
||||
# if not folios:
|
||||
# raise UserError(
|
||||
# gettext('hotel.msg_room_not_occupied', s=self.room.name)
|
||||
# )
|
||||
# elif len(folios) > 1:
|
||||
# raise UserError(
|
||||
# gettext('hotel.msg_multiple_rooms_active', s=self.room.name)
|
||||
# )
|
||||
|
||||
folios = Folio.search(dom)
|
||||
if not folios:
|
||||
raise UserError(
|
||||
gettext('hotel.msg_room_not_occupied', s=self.room.name)
|
||||
)
|
||||
elif len(folios) > 1:
|
||||
raise UserError(
|
||||
gettext('hotel.msg_multiple_rooms_active', s=self.room.name)
|
||||
)
|
||||
|
||||
folio = folios[0]
|
||||
# folio = folios[0]
|
||||
new_line = {
|
||||
'operation': folio.id,
|
||||
'folio': self.folio.id,
|
||||
'date_service': self.service.service_date,
|
||||
'order': self.order,
|
||||
'description': self.description,
|
||||
'quantity': int(self.quantity),
|
||||
'invoice_to': folio.main_guest.id,
|
||||
'invoice_to': self.folio.main_guest.id,
|
||||
'unit_price': self.product.template.list_price,
|
||||
'product': self.product.id,
|
||||
}
|
||||
# FIXME: not use int
|
||||
|
||||
line, = FolioCharge.create([new_line])
|
||||
self.write([self], {'charge': line.id})
|
||||
|
@ -338,8 +304,10 @@ class CreateDailyServices(Wizard):
|
|||
|
||||
folios = Folio.search([
|
||||
('arrival_date', '<', self.start.date),
|
||||
# ('departure_date', '<', self.start.date),
|
||||
('registration_state', 'in', ['check_in', 'check_out']),
|
||||
])
|
||||
print('folios...', folios)
|
||||
|
||||
lines_to_create = []
|
||||
service, = Service.create([{
|
||||
|
@ -350,13 +318,23 @@ 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,
|
||||
'service': service.id,
|
||||
'room': fol.room.id,
|
||||
'guest': guest.id,
|
||||
'guest': guest.party.name,
|
||||
'product': product.id,
|
||||
'quantity': 1,
|
||||
})
|
||||
|
|
|
@ -12,9 +12,10 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="company"/>
|
||||
<label name="description"/>
|
||||
<field name="description"/>
|
||||
<button name="open" string="Open" icon="tryton-forward" colspan="2"/>
|
||||
<button name="open" string="Open" icon="tryton-forward" colspan="2"/>
|
||||
<field name="lines" colspan="4"
|
||||
view_ids="hotel.service_line_view_tree"/>
|
||||
|
||||
<group col="5" colspan="4" id="buttons">
|
||||
<label name="state"/>
|
||||
<field name="state"/>
|
||||
|
|
|
@ -8,14 +8,20 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="time_service"/>
|
||||
<label name="product"/>
|
||||
<field name="product"/>
|
||||
<label name="folio"/>
|
||||
<field name="folio"/>
|
||||
<label name="guest"/>
|
||||
<field name="guest"/>
|
||||
<label name="quantity"/>
|
||||
<field name="quantity"/>
|
||||
<label name="order"/>
|
||||
<field name="order"/>
|
||||
<label name="invoice_line"/>
|
||||
<field name="invoice_line"/>
|
||||
<label name="description"/>
|
||||
<field name="description"/>
|
||||
<label name="folio"/>
|
||||
<field name="folio"/>
|
||||
<label name="folio_line"/>
|
||||
<field name="folio_line"/>
|
||||
<label name="state"/>
|
||||
<field name="state"/>
|
||||
</form>
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
this repository contains the full copyright notices and license terms. -->
|
||||
<tree editable="1">
|
||||
<field name="room" widget="selection"/>
|
||||
<field name="guest" widget="selection"/>
|
||||
<field name="guest"/>
|
||||
<field name="folio"/>
|
||||
<field name="time_service"/>
|
||||
<field name="product"/>
|
||||
<button name="load" string="Load"/>
|
||||
|
@ -11,6 +12,5 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="description"/>
|
||||
<field name="order"/>
|
||||
<field name="state"/>
|
||||
<field name="folio"/>
|
||||
<field name="invoice_line"/>
|
||||
<field name="folio_line"/>
|
||||
</tree>
|
||||
|
|
Loading…
Reference in a new issue