mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
Change parity by default
This commit is contained in:
@@ -267,10 +267,10 @@ class HotelCalendarManagement(models.TransientModel):
|
||||
vals = {}
|
||||
if not pricelist_id:
|
||||
pricelist_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'parity_pricelist_id')
|
||||
'res.config.settings', 'default_pricelist_id')
|
||||
if not restriction_id:
|
||||
restriction_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'parity_restrictions_id')
|
||||
'res.config.settings', 'default_restrictions_id')
|
||||
|
||||
pricelist_id = int(pricelist_id)
|
||||
vals.update({'pricelist_id': pricelist_id})
|
||||
|
||||
@@ -59,7 +59,7 @@ class HotelReservation(models.Model):
|
||||
@api.model
|
||||
def _hcalendar_room_data(self, rooms):
|
||||
pricelist_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'parity_pricelist_id')
|
||||
'res.config.settings', 'default_pricelist_id')
|
||||
if pricelist_id:
|
||||
pricelist_id = int(pricelist_id)
|
||||
json_rooms = []
|
||||
@@ -117,7 +117,7 @@ class HotelReservation(models.Model):
|
||||
@api.model
|
||||
def get_hcalendar_pricelist_data(self, dfrom, dto):
|
||||
pricelist_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'parity_pricelist_id')
|
||||
'res.config.settings', 'default_pricelist_id')
|
||||
if pricelist_id:
|
||||
pricelist_id = int(pricelist_id)
|
||||
date_start = fields.Date.from_string(dfrom) - timedelta(days=1)
|
||||
@@ -157,7 +157,7 @@ class HotelReservation(models.Model):
|
||||
@api.model
|
||||
def get_hcalendar_restrictions_data(self, dfrom, dto):
|
||||
restriction_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'parity_restrictions_id')
|
||||
'res.config.settings', 'default_restrictions_id')
|
||||
if restriction_id:
|
||||
restriction_id = int(restriction_id)
|
||||
date_start = fields.Date.from_string(dfrom) - timedelta(days=1)
|
||||
|
||||
@@ -11,12 +11,12 @@ class HotelRoomTypeResrtrictionItem(models.Model):
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
res = super(HotelRoomTypeResrtrictionItem, self).create(vals)
|
||||
restrictions_parity_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'parity_restrictions_id')
|
||||
if restrictions_parity_id:
|
||||
restrictions_parity_id = int(restrictions_parity_id)
|
||||
restrictions_default_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'default_restrictions_id')
|
||||
if restrictions_default_id:
|
||||
restrictions_default_id = int(restrictions_default_id)
|
||||
restriction_id = res.restriction_id.id
|
||||
if restriction_id == restrictions_parity_id and \
|
||||
if restriction_id == restrictions_default_id and \
|
||||
self.applied_on == '0_room_type':
|
||||
self.env['bus.hotel.calendar'].send_restriction_notification({
|
||||
'restriction_id': self.restriction_id.id,
|
||||
@@ -35,15 +35,15 @@ class HotelRoomTypeResrtrictionItem(models.Model):
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
restrictions_parity_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'parity_restrictions_id')
|
||||
if restrictions_parity_id:
|
||||
restrictions_parity_id = int(restrictions_parity_id)
|
||||
restrictions_default_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'default_restrictions_id')
|
||||
if restrictions_default_id:
|
||||
restrictions_default_id = int(restrictions_default_id)
|
||||
ret_vals = super(HotelRoomTypeResrtrictionItem, self).write(vals)
|
||||
|
||||
bus_hotel_calendar_obj = self.env['bus.hotel.calendar']
|
||||
for record in self:
|
||||
if record.restriction_id.id != restrictions_parity_id or \
|
||||
if record.restriction_id.id != restrictions_default_id or \
|
||||
record.applied_on != '0_room_type':
|
||||
continue
|
||||
bus_hotel_calendar_obj.send_restriction_notification({
|
||||
@@ -63,14 +63,14 @@ class HotelRoomTypeResrtrictionItem(models.Model):
|
||||
|
||||
@api.multi
|
||||
def unlink(self):
|
||||
restrictions_parity_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'parity_restrictions_id')
|
||||
if restrictions_parity_id:
|
||||
restrictions_parity_id = int(restrictions_parity_id)
|
||||
restrictions_default_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'default_restrictions_id')
|
||||
if restrictions_default_id:
|
||||
restrictions_default_id = int(restrictions_default_id)
|
||||
# Construct dictionary with relevant info of removed records
|
||||
unlink_vals = []
|
||||
for record in self:
|
||||
if record.restriction_id.id != restrictions_parity_id or \
|
||||
if record.restriction_id.id != restrictions_default_id or \
|
||||
record.applied_on != '0_room_type':
|
||||
continue
|
||||
unlink_vals.append({
|
||||
|
||||
@@ -10,7 +10,7 @@ class IrDefault(models.Model):
|
||||
@api.model
|
||||
def set(self, model_name, field_name, value, user_id=False, company_id=False, condition=False):
|
||||
super(IrDefault, self).set(model_name, field_name, value, user_id, company_id, condition)
|
||||
if model_name == 'res.config.settings' and field_name == 'parity_pricelist_id':
|
||||
if model_name == 'res.config.settings' and field_name == 'default_pricelist_id':
|
||||
pricelist_id = int(value)
|
||||
self.env['room.pricelist.cached'].search([]).unlink()
|
||||
|
||||
|
||||
@@ -9,17 +9,17 @@ class ProductPricelistItem(models.Model):
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
res = super(ProductPricelistItem, self).create(vals)
|
||||
pricelist_parity_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'parity_pricelist_id')
|
||||
if pricelist_parity_id:
|
||||
pricelist_parity_id = int(pricelist_parity_id)
|
||||
pricelist_default_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'default_pricelist_id')
|
||||
if pricelist_default_id:
|
||||
pricelist_default_id = int(pricelist_default_id)
|
||||
pricelist_id = res.pricelist_id.id
|
||||
product_tmpl_id = res.product_tmpl_id.id
|
||||
date_start = res.date_start
|
||||
room_type = self.env['hotel.room.type'].search([
|
||||
('product_id.product_tmpl_id', '=', product_tmpl_id)
|
||||
], limit=1)
|
||||
if pricelist_id == pricelist_parity_id and room_type:
|
||||
if pricelist_id == pricelist_default_id and room_type:
|
||||
prod = room_type.product_id.with_context(
|
||||
quantity=1,
|
||||
date=date_start,
|
||||
@@ -51,10 +51,10 @@ class ProductPricelistItem(models.Model):
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
pricelist_parity_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'parity_pricelist_id')
|
||||
if pricelist_parity_id:
|
||||
pricelist_parity_id = int(pricelist_parity_id)
|
||||
pricelist_default_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'default_pricelist_id')
|
||||
if pricelist_default_id:
|
||||
pricelist_default_id = int(pricelist_default_id)
|
||||
ret_vals = super(ProductPricelistItem, self).write(vals)
|
||||
|
||||
room_pr_cached_obj = self.env['room.pricelist.cached']
|
||||
@@ -64,7 +64,7 @@ class ProductPricelistItem(models.Model):
|
||||
for record in self:
|
||||
pricelist_id = vals.get('pricelist_id') or \
|
||||
record.pricelist_id.id
|
||||
if pricelist_id != pricelist_parity_id:
|
||||
if pricelist_id != pricelist_default_id:
|
||||
continue
|
||||
date_start = vals.get('date_start') or record.date_start
|
||||
product_tmpl_id = vals.get('product_tmpl_id') or \
|
||||
@@ -104,14 +104,14 @@ class ProductPricelistItem(models.Model):
|
||||
|
||||
@api.multi
|
||||
def unlink(self):
|
||||
pricelist_parity_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'parity_pricelist_id')
|
||||
if pricelist_parity_id:
|
||||
pricelist_parity_id = int(pricelist_parity_id)
|
||||
pricelist_default_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'default_pricelist_id')
|
||||
if pricelist_default_id:
|
||||
pricelist_default_id = int(pricelist_default_id)
|
||||
# Construct dictionary with relevant info of removed records
|
||||
unlink_vals = []
|
||||
for record in self:
|
||||
if record.pricelist_id.id != pricelist_parity_id:
|
||||
if record.pricelist_id.id != pricelist_default_id:
|
||||
continue
|
||||
room_type = self.env['hotel.room.type'].search([
|
||||
('product_id.product_tmpl_id', '=', record.product_tmpl_id.id)
|
||||
|
||||
Reference in New Issue
Block a user