Add maintenances projection to planner

This commit is contained in:
oscar alvarez 2022-07-21 09:03:54 -05:00
parent dc36042912
commit 642de10adf
5 changed files with 58 additions and 1 deletions

View File

@ -102,7 +102,7 @@ class Booking(Workflow, ModelSQL, ModelView):
required=False, states=STATES_CONFIRMED)
satisfaction = fields.Selection(SATISFACTION, 'Satisfaction')
media = fields.Selection(MEDIA, 'Media', states=STATES_CHECKIN,
help="Media from booking coming from.")
help="Way through which the booking arrives.")
media_string = media.translated('media')
plan = fields.Selection(PLAN, 'Commercial Plan', states=STATES_CHECKIN,
help="Plans offered by hotel and selected by guest for booking.")

View File

@ -21,6 +21,7 @@ class SaleChannel(ModelSQL, ModelView):
'Sale Channel'
__name__ = 'hotel.channel'
name = fields.Char('Name', required=True)
code = fields.Char('Code', required=True)
agent = fields.Many2One('commission.agent', 'Agent', required=True)
type_commission = fields.Selection([
('percentage', 'Percentage'),

View File

@ -3,6 +3,7 @@
from decimal import Decimal
from datetime import timedelta, datetime, date
from trytond.model import ModelView, Workflow, ModelSQL, fields
from trytond.pyson import Eval, Bool
from trytond.pool import Pool
@ -492,6 +493,58 @@ class Folio(ModelSQL, ModelView):
def update_nights(self, arrival_date, departure_date):
self.nights_quantity = (departure_date - arrival_date).days
@classmethod
def get_folios(cls, args):
Maintenance = Pool().get('hotel.maintenance')
start = datetime.strptime(args['start_date'], "%Y-%m-%d")
start_date = start + timedelta(days=-5)
end_date = start + timedelta(days=30)
dom = ['OR', [
('arrival_date', '>=', start_date),
('arrival_date', '<=', end_date)
], [
('departure_date', '>=', start_date),
('departure_date', '<=', end_date)
]]
fields_names = [
"room.name",
"arrival_date",
"departure_date",
"main_guest.name",
"product.rec_name",
"booking.number",
"booking.media",
"booking.channel.rec_name",
"booking.channel.code",
"registration_state",
"registration_card",
"nights_quantity",
"notes",
]
folios = cls.search_read(dom, fields_names=fields_names)
dom_maint = ['OR', [
('start_date', '>=', start_date),
('start_date', '<=', end_date),
('state', 'in', ('in_progress', 'finished', 'confirmed')),
('start_date', '!=', None),
('end_date', '!=', None),
], [
('end_date', '>=', start_date),
('end_date', '<=', end_date),
('state', 'in', ('in_progress', 'finished', 'confirmed')),
('start_date', '!=', None),
('end_date', '!=', None),
],
]
fields_maint = [
'start_date', 'end_date', 'room', 'room.name', 'issue',
'create_uid.name'
]
mnts = Maintenance.search_read(dom_maint, fields_names=fields_maint)
return {'folios': folios, 'mnts': mnts}
def get_totals(self, name):
"""
The total amount of booking based on room flat price.

View File

@ -6,6 +6,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="name"/>
<label name="company"/>
<field name="company" widget="selection"/>
<label name="code"/>
<field name="code"/>
<label name="agent"/>
<field name="agent"/>
<label name="currency"/>

View File

@ -3,6 +3,7 @@
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="name"/>
<field name="code"/>
<field name="agent"/>
<field name="type_commission"/>
<field name="commission"/>