mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] retrieve data in calendar by product.pricelist and hotel
This commit is contained in:
@@ -64,6 +64,7 @@
|
||||
</button>
|
||||
|
||||
</div>
|
||||
<field name="hotel_id" invisible="0"/>
|
||||
<h2><field name="name"/></h2>
|
||||
<h1>
|
||||
<field name="partner_id" default_focus="1" placeholder="Guest" attrs="{'invisible':[('reservation_type','in',('out'))]}"/>
|
||||
@@ -237,6 +238,7 @@
|
||||
<field name="amount_total" sum="Total amount"/>
|
||||
<field name="pending_amount" sum="Total debt"/>
|
||||
<field name="invoice_status" />
|
||||
<field name="hotel_id" invisible="0"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -142,6 +142,7 @@
|
||||
</div>
|
||||
<span class="label label-danger" attrs="{'invisible': [('state', 'not in', ('cancelled'))]}">Cancelled Reservation!</span>
|
||||
<span class="label label-warning" attrs="{'invisible': [('overbooking', '=', False)]}">OverBooking!</span>
|
||||
<field name="hotel_id" invisible="0"/>
|
||||
<h1>
|
||||
<field name="room_id" select="1"
|
||||
nolabel="1" options="{'no_create': True,'no_open': True}" placeholder="Room"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
</h1>
|
||||
</div>
|
||||
<group>
|
||||
<field name="hotel_id" invisible="1"/>
|
||||
<field name="hotel_id" invisible="0"/>
|
||||
</group>
|
||||
<div>
|
||||
<separator string="Pricelist Items"/>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<field name="class_id" />
|
||||
</group>
|
||||
<group>
|
||||
<field name="hotel_id" invisible="1"/>
|
||||
<field name="hotel_id" invisible="0"/>
|
||||
<field name="list_price" widget='monetary' options="{'currency_field': 'currency_id', 'field_digits': True}"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<notebook>
|
||||
<page name="information_hotel_room" string="Information">
|
||||
<group colspan="4" col="4">
|
||||
<field name="hotel_id" invisible="1"/>
|
||||
<field name="hotel_id" invisible="0" force_save="1"/>
|
||||
<field name="floor_id" string="Ubication"
|
||||
attrs="{'readonly':[('shared_room_id','!=', False)]}" />
|
||||
<!-- <field name="categ_id" select="1" domain="[('isroomtype','=',True)]" string="Room Type" /> -->
|
||||
|
||||
@@ -6,7 +6,7 @@ from odoo.tools import (
|
||||
DEFAULT_SERVER_DATE_FORMAT,
|
||||
DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
from odoo import models, api, _, fields
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.exceptions import AccessError, ValidationError
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -211,9 +211,12 @@ class HotelCalendarManagement(models.TransientModel):
|
||||
@api.model
|
||||
def get_hcalendar_all_data(self, dfrom, dto, pricelist_id, restriction_id,
|
||||
withRooms):
|
||||
hotel_id = self.env.user.hotel_id.id
|
||||
|
||||
if not dfrom or not dto:
|
||||
raise ValidationError(_('Input Error: No dates defined!'))
|
||||
vals = {}
|
||||
# TODO: res.config by hotel
|
||||
if not pricelist_id:
|
||||
pricelist_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'default_pricelist_id')
|
||||
@@ -221,17 +224,16 @@ class HotelCalendarManagement(models.TransientModel):
|
||||
restriction_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'default_restriction_id')
|
||||
|
||||
# TODO: ensure pricelist_id and restriction_id belong to the current hotel
|
||||
pricelist_id = int(pricelist_id)
|
||||
vals.update({'pricelist_id': pricelist_id})
|
||||
restriction_id = int(restriction_id)
|
||||
vals.update({'restriction_id': restriction_id})
|
||||
|
||||
room_type_rest_it_obj = self.env['hotel.room.type.restriction.item']
|
||||
restriction_item_ids = room_type_rest_it_obj.search([
|
||||
restriction_item_ids = self.env['hotel.room.type.restriction.item'].search([
|
||||
('date', '>=', dfrom), ('date', '<=', dto),
|
||||
('restriction_id', '=', restriction_id),
|
||||
])
|
||||
|
||||
pricelist_item_ids = self.env['product.pricelist.item'].search([
|
||||
('date_start', '>=', dfrom), ('date_end', '<=', dto),
|
||||
('pricelist_id', '=', pricelist_id),
|
||||
@@ -241,6 +243,7 @@ class HotelCalendarManagement(models.TransientModel):
|
||||
|
||||
json_prices = self._hcalendar_pricelist_json_data(pricelist_item_ids)
|
||||
json_rest = self._hcalendar_restriction_json_data(restriction_item_ids)
|
||||
# TODO REVIEW: what are json_rc and json_events used for in calendar management ¿?
|
||||
json_rc = self._hcalendar_get_count_reservations_json_data(dfrom, dto)
|
||||
json_events = self._hcalendar_events_json_data(dfrom, dto)
|
||||
vals.update({
|
||||
@@ -251,9 +254,15 @@ class HotelCalendarManagement(models.TransientModel):
|
||||
})
|
||||
|
||||
if withRooms:
|
||||
room_ids = self.env['hotel.room.type'].search(
|
||||
[],
|
||||
order='sequence ASC')
|
||||
room_ids = self.env['hotel.room.type'].search([
|
||||
('hotel_id', '=', hotel_id)
|
||||
], order='sequence ASC') or None
|
||||
|
||||
if not room_ids:
|
||||
raise AccessError(
|
||||
_("Wrong hotel and company access settings for this user. "
|
||||
"No room types found for hotel %s") % self.env.user.hotel_id.name)
|
||||
|
||||
json_rooms = self._hcalendar_room_json_data(room_ids)
|
||||
vals.update({'rooms': json_rooms or []})
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ class ProductPricelist(models.Model):
|
||||
|
||||
@api.multi
|
||||
def update_price(self, room_type_id, date, price):
|
||||
import wdb; wdb.set_trace()
|
||||
room_type = self.env['hotel.room.type'].browse(room_type_id)
|
||||
pritem_obj = self.env['product.pricelist.item']
|
||||
for record in self:
|
||||
|
||||
@@ -40,7 +40,7 @@ return AbstractModel.extend({
|
||||
},
|
||||
|
||||
get_pricelists: function () {
|
||||
var domain = [];
|
||||
var domain = [['hotel_ids', 'in', Session.user_hotels.current_hotel[0]]];
|
||||
domain.push(['pricelist_type', '=', 'daily']);
|
||||
return this._rpc({
|
||||
model: 'product.pricelist',
|
||||
@@ -51,10 +51,11 @@ return AbstractModel.extend({
|
||||
},
|
||||
|
||||
get_restrictions: function () {
|
||||
var domain = [['hotel_id', '=', Session.user_hotels.current_hotel[0]]];
|
||||
return this._rpc({
|
||||
model: 'hotel.room.type.restriction',
|
||||
method: 'search_read',
|
||||
args: [false, ['id','name']],
|
||||
args: [domain, ['id','name']],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user