Refactory plan rate

This commit is contained in:
oscar alvarez 2023-10-30 07:36:33 -05:00
parent 93915736cf
commit f81d2f22aa
9 changed files with 168 additions and 90 deletions

View File

@ -112,7 +112,9 @@ def register():
analytic.AnalyticSpace,
price_list.HotelPriceList,
rate_plan.RatePlan,
rate_plan.RatePlanPriceList,
rate_plan.RatePlanRule,
rate_plan.RatePlanCalendar,
siat.SiatSyncStart,
dash.AppWebMelHous,
module='hotel', type_='model')

View File

@ -69,8 +69,7 @@ class Booking(Workflow, ModelSQL, ModelView):
states={
'invisible': Eval('media') != 'ota',
'readonly': Eval('state').in_(['finished', 'cancelled']),
},
help="Agency or channel that do reservation.")
}, help="Agency or channel that do reservation.")
state = fields.Selection(STATE_BOOKING, 'State', readonly=True,
required=True)
state_string = state.translated('state')

View File

@ -6,97 +6,92 @@ from trytond.model import ModelView, ModelSQL, fields, Workflow
# from trytond.pool import Pool
class RatePlanCalendar(ModelSQL, ModelView):
'Hotel Rate Plan Calendar'
__name__ = 'hotel.rate_plan.calendar'
start_date = fields.Date('Start Date', required=True)
end_date = fields.Date('End Date', required=True)
type_ = fields.Selection([
('high', 'High'),
('low', 'Low'),
('middle', 'Middle'),
], 'Type')
@staticmethod
def default_type_():
return 'high'
class RatePlan(Workflow, ModelSQL, ModelView):
'Hotel Rate Plan'
__name__ = 'hotel.rate_plan'
active = fields.Boolean('Active')
name = fields.Char('Name', required=True)
price_lists = fields.Many2Many('hotel.rate_plan-product.price_list',
'rate_plan', 'price_list', 'Price Lists', required=True)
party = fields.Many2One('party.party', 'Party')
kind = fields.Selection([
('channel', 'Channel'),
('direct', 'Direct'),
('corporative', 'Corporative'),
('web', 'Web'),
('agency', 'Agency'),
], 'Kind', required=True)
cancellation_condition = fields.Selection([
('non_refundable', 'Non-Refundable'),
('flexible', 'Flexible'),
# ('flexible42', 'Flexible 42 Days'),
], 'Cancellation Condition', required=True)
minimum_stay = fields.Integer('Minimum Stay',
help="Minimun stay in days for to apply this plan rate")
all_inclusive = fields.Boolean('All Inclusive')
breakfast = fields.Boolean('Breakfast')
lunch = fields.Boolean('Lunch')
dinner = fields.Boolean('Dinner')
# ----------------- variations -----------------
monday = fields.Char('Monday')
tuesday = fields.Char('Tuesday')
wednesday = fields.Char('Wednesday')
thursday = fields.Char('Thursday')
friday = fields.Char('Friday')
saturday = fields.Char('Saturday')
sunday = fields.Char('Sunday')
holiday = fields.Char('Holiday')
price_list = fields.Many2One('product.price_list', 'Price List',
required=True)
start_date = fields.Date('Start Date', required=True)
end_date = fields.Date('End Date', required=True)
state = fields.Selection([
('draft', 'Draft'),
('confirmed', 'Confirmed'),
('in_progress', 'In progress'),
('finished', 'Finished'),
('cancelled', 'Canceled'),
], 'State', readonly=True)
required=False)
@classmethod
def __setup__(cls):
super(RatePlan, cls).__setup__()
# cls._transitions |= set((
# ('draft', 'confirmed'),
# ('draft', 'cancelled'),
# ('confirmed', 'draft'),
# ('confirmed', 'in_progress'),
# ('cancelled', 'draft'),
# ('confirmed', 'cancelled'),
# ('in_progress', 'finished'),
# ('finished', 'in_progress'),
# ))
# cls._buttons.update({
# 'confirm': {
# 'invisible': Eval('state') != 'draft',
# },
# 'in_progress': {
# 'invisible': Eval('state') != 'confirmed',
# },
# 'finish': {
# 'invisible': Eval('state') != 'in_progress',
# },
# 'draft': {
# 'invisible': Eval('state').in_(['draft', 'cancelled']),
# },
# 'cancel': {
# 'invisible': Eval('state') == 'finished',
# }
# })
@classmethod
def __register__(cls, module_name):
super().__register__(module_name)
table_h = cls.__table_handler__(module_name)
table_h.drop_column('start_date')
table_h.drop_column('end_date')
# table_h.drop_column('price_list')
@staticmethod
def default_state():
return 'draft'
def default_minimum_stay():
return 0
# @classmethod
# @ModelView.button
# @Workflow.transition('draft')
# def draft(cls, records):
# pass
#
# @classmethod
# @ModelView.button
# @Workflow.transition('cancelled')
# def cancel(cls, records):
# pass
#
# @classmethod
# @ModelView.button
# @Workflow.transition('confirmed')
# def confirm(cls, records):
# pass
#
# @classmethod
# @ModelView.button
# @Workflow.transition('in_progress')
# def in_progress(cls, records):
# pass
#
# @classmethod
# @ModelView.button
# @Workflow.transition('finished')
# def finish(cls, records):
# pass
@staticmethod
def default_breakfast():
return True
@fields.depends('start_date', 'end_date')
def on_change_start_date(self):
if not self.start_date:
self.end_date = None
@staticmethod
def default_active():
return True
def get_days(self, name):
if self.end_date and self.start_date:
return (self.end_date - self.start_date).days
def get_rec_name(self, name):
return self.price_list.name
class RatePlanPriceList(ModelSQL):
'Rate Plan - Price List'
__name__ = 'hotel.rate_plan-product.price_list'
price_list = fields.Many2One('product.price_list', 'Price List',
required=True, ondelete='CASCADE')
rate_plan = fields.Many2One('hotel.rate_plan', 'Rate Plan',
required=True, ondelete='CASCADE')
class RatePlanRule(ModelSQL, ModelView):

View File

@ -4,6 +4,34 @@ this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.ui.view" id="hotel_rate_plan_calendar_view_tree">
<field name="model">hotel.rate_plan.calendar</field>
<field name="type">tree</field>
<field name="name">rate_plan_calendar_tree</field>
</record>
<record model="ir.ui.view" id="hotel_rate_plan_calendar_view_form">
<field name="model">hotel.rate_plan.calendar</field>
<field name="type">form</field>
<field name="name">rate_plan_calendar_form</field>
</record>
<record model="ir.action.act_window" id="act_hotel_rate_plan_calendar_form">
<field name="name">Rate Plan Calendar</field>
<field name="res_model">hotel.rate_plan.calendar</field>
</record>
<record model="ir.action.act_window.view" id="act_rate_plan_calendar_form_view1">
<field name="sequence" eval="10"/>
<field name="view" ref="hotel_rate_plan_calendar_view_tree"/>
<field name="act_window" ref="act_hotel_rate_plan_calendar_form"/>
</record>
<record model="ir.action.act_window.view" id="act_rate_plan_calendar_form_view2">
<field name="sequence" eval="20"/>
<field name="view" ref="hotel_rate_plan_calendar_view_form"/>
<field name="act_window" ref="act_hotel_rate_plan_calendar_form"/>
</record>
<menuitem name="Rate Plan Calendar" parent="hotel.menu_configuration"
sequence="40" id="menu_hotel_rate_plan_calendar"
action="act_hotel_rate_plan_calendar_form" />
<record model="ir.ui.view" id="hotel_rate_plan_view_tree">
<field name="model">hotel.rate_plan</field>
<field name="type">tree</field>

View File

@ -1,5 +1,5 @@
[tryton]
version=6.0.115
version=6.0.116
depends:
party
company

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
<label name="type_"/>
<field name="type_"/>
<newline />
<label name="start_date"/>
<field name="start_date"/>
<label name="end_date"/>
<field name="end_date"/>
</form>

View File

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree editable="1">
<field name="start_date" expand="1"/>
<field name="end_date" expand="1"/>
<field name="type_" expand="1"/>
</tree>

View File

@ -2,11 +2,45 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
<label name="price_list"/>
<field name="price_list" widget="selection"/>
<newline />
<label name="start_date"/>
<field name="start_date"/>
<label name="end_date"/>
<field name="end_date"/>
<label name="name"/>
<field name="name"/>
<label name="active"/>
<field name="active"/>
<label name="kind"/>
<field name="kind"/>
<label name="party"/>
<field name="party"/>
<label name="minimum_stay"/>
<field name="minimum_stay"/>
<label name="cancellation_condition"/>
<field name="cancellation_condition"/>
<group string="Food" col="8" id="food" colspan="4">
<label name="all_inclusive"/>
<field name="all_inclusive"/>
<label name="breakfast"/>
<field name="breakfast"/>
<label name="lunch"/>
<field name="lunch"/>
<label name="dinner"/>
<field name="dinner"/>
</group>
<group string="Price Lists" id="weedays" colspan="2">
<field name="price_lists" colspan="4"/>
</group>
<group string="Weedays" col="2" id="weedays" colspan="2">
<label name="monday"/>
<field name="monday"/>
<label name="tuesday"/>
<field name="tuesday"/>
<label name="wednesday"/>
<field name="wednesday"/>
<label name="thursday"/>
<field name="thursday"/>
<label name="friday"/>
<field name="friday"/>
<label name="saturday"/>
<field name="saturday"/>
<label name="sunday"/>
<field name="sunday"/>
</group>
</form>

View File

@ -2,7 +2,7 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="price_list" expand="1"/>
<field name="start_date" expand="1"/>
<field name="end_date" expand="1"/>
<field name="name" expand="1"/>
<field name="party" expand="1"/>
<field name="kind" expand="1"/>
</tree>