mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[TMP][FIX] run create direct folio
This commit is contained in:
@@ -314,23 +314,24 @@ class HotelFolio(models.Model):
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
if vals.get('name', _('New')) == _('New'):
|
||||
if vals.get('name', _('New')) == _('New') or 'name' not in vals:
|
||||
if 'company_id' in vals:
|
||||
vals['name'] = self.env['ir.sequence'].with_context(
|
||||
force_company=vals['company_id']
|
||||
).next_by_code('sale.order') or _('New')
|
||||
else:
|
||||
vals['name'] = self.env['ir.sequence'].next_by_code('hotel.folio') or _('New')
|
||||
|
||||
|
||||
# Makes sure partner_invoice_id' and 'pricelist_id' are defined
|
||||
lfields = ('partner_invoice_id', 'partner_shipping_id', 'pricelist_id')
|
||||
#~ if any(f not in vals for f in lfields):
|
||||
#~ partner = self.env['res.partner'].browse(vals.get('partner_id'))
|
||||
#~ addr = partner.address_get(['delivery', 'invoice'])
|
||||
if any(f not in vals for f in lfields):
|
||||
partner = self.env['res.partner'].browse(vals.get('partner_id'))
|
||||
addr = partner.address_get(['delivery', 'invoice'])
|
||||
#~ vals['partner_invoice_id'] = vals.setdefault('partner_invoice_id', addr['invoice'])
|
||||
#~ vals['pricelist_id'] = vals.setdefault(
|
||||
#~ 'pricelist_id',
|
||||
#~ partner.property_product_pricelist and partner.property_product_pricelist.id)
|
||||
vals['pricelist_id'] = vals.setdefault(
|
||||
'pricelist_id',
|
||||
partner.property_product_pricelist and partner.property_product_pricelist.id)
|
||||
result = super(HotelFolio, self).create(vals)
|
||||
return result
|
||||
|
||||
@@ -353,7 +354,10 @@ class HotelFolio(models.Model):
|
||||
|
||||
addr = self.partner_id.address_get(['invoice'])
|
||||
#TEMP:
|
||||
values = { 'user_id': self.partner_id.user_id.id or self.env.uid }
|
||||
values = { 'user_id': self.partner_id.user_id.id or self.env.uid,
|
||||
'pricelist_id':self.partner_id.property_product_pricelist and \
|
||||
self.partner_id.property_product_pricelist.id or \
|
||||
self.env['ir.default'].sudo().get('res.config.settings', 'parity_pricelist_id')}
|
||||
#~ values = {
|
||||
#~ 'pricelist_id': self.partner_id.property_product_pricelist and \
|
||||
#~ self.partner_id.property_product_pricelist.id or False,
|
||||
@@ -488,18 +492,16 @@ class HotelFolio(models.Model):
|
||||
def _compute_cardex_count(self):
|
||||
_logger.info('_compute_cardex_amount')
|
||||
for record in self:
|
||||
if record.reservation_type == 'normal':
|
||||
if record.reservation_type == 'normal' and record.room_lines:
|
||||
write_vals = {}
|
||||
filtered_reservs = record.filtered(
|
||||
lambda x: x.room_lines.state != 'cancelled' and \
|
||||
not x.room_lines.parent_reservation)
|
||||
|
||||
filtered_reservs = record.room_lines.filtered(
|
||||
lambda x: x.state != 'cancelled' and \
|
||||
not x.parent_reservation)
|
||||
mapped_cardex = filtered_reservs.mapped('cardex_ids.id')
|
||||
write_vals.update({'cardex_count': len(mapped_cardex)})
|
||||
record.cardex_count = len(mapped_cardex)
|
||||
mapped_cardex_count = filtered_reservs.mapped(
|
||||
lambda x: (x.adults + x.children) - len(x.cardex_ids))
|
||||
write_vals.update({'cardex_pending_count': sum(mapped_cardex_count)})
|
||||
record.write(write_vals)
|
||||
record.cardex_pending_count = sum(mapped_cardex_count)
|
||||
|
||||
"""
|
||||
MAILING PROCESS
|
||||
|
||||
@@ -334,11 +334,14 @@ class HotelReservation(models.Model):
|
||||
def _prepare_add_missing_fields(self, values):
|
||||
""" Deduce missing required fields from the onchange """
|
||||
res = {}
|
||||
onchange_fields = ['room_id', 'pricelist_id', 'reservation_type', 'currency_id']
|
||||
if values.get('partner_id') and values.get('room_type_id') and \
|
||||
any(f not in values for f in onchange_fields):
|
||||
onchange_fields = ['room_id', 'reservation_type', 'currency_id', 'name']
|
||||
if values.get('partner_id') and values.get('room_type_id'):
|
||||
line = self.new(values)
|
||||
line.onchange_room_id()
|
||||
if any(f not in values for f in onchange_fields):
|
||||
line.onchange_room_id()
|
||||
line.onchange_compute_reservation_description()
|
||||
if 'pricelist_id' not in values:
|
||||
line.onchange_partner_id()
|
||||
for field in onchange_fields:
|
||||
if field not in values:
|
||||
res[field] = line._fields[field].convert_to_write(line[field], line)
|
||||
@@ -353,7 +356,7 @@ class HotelReservation(models.Model):
|
||||
if checkin and checkout and room_type:
|
||||
room_chosen = self.env['hotel.room.type'].check_availability_room(checkin, checkout, room_type)[0]
|
||||
res.update({
|
||||
'room_id': room_chosen
|
||||
'room_id': room_chosen.id
|
||||
})
|
||||
return res
|
||||
|
||||
@@ -888,11 +891,9 @@ class HotelReservation(models.Model):
|
||||
def _compute_cardex_count(self):
|
||||
_logger.info('_compute_cardex_count')
|
||||
for record in self:
|
||||
record.write({
|
||||
'cardex_count': len(record.cardex_ids),
|
||||
'cardex_pending_count': (record.adults + record.children) \
|
||||
record.cardex_count = len(record.cardex_ids)
|
||||
record.cardex_pending_count = (record.adults + record.children) \
|
||||
- len(record.cardex_ids)
|
||||
})
|
||||
|
||||
# https://www.odoo.com/es_ES/forum/ayuda-1/question/calculated-fields-in-search-filter-possible-118501
|
||||
@api.multi
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
<span class="o_stat_text">Checks</span>
|
||||
</div>
|
||||
</button>
|
||||
<!-- <field name="currency_id" invisible="1"/> -->
|
||||
<field name="currency_id" invisible="1"/>
|
||||
|
||||
<!-- <button type="object" class="oe_stat_button"
|
||||
id="invoices_smart_button"
|
||||
@@ -94,16 +94,6 @@
|
||||
</div>
|
||||
</button> -->
|
||||
|
||||
<!-- <button type="object" class="oe_stat_button"
|
||||
id="payment_smart_button"
|
||||
icon="fa-money"
|
||||
name="action_recalcule_payment"
|
||||
help="Calcule the total Price">
|
||||
<div class="o_form_field o_stat_info">
|
||||
<span class="o_stat_text">Calcule Price</span>
|
||||
</div>
|
||||
</button> -->
|
||||
|
||||
<!-- <button type="object" class="oe_stat_button"
|
||||
id="refunds_smart_button"
|
||||
icon="fa-undo"
|
||||
@@ -307,8 +297,8 @@
|
||||
<field name="name"/>
|
||||
<field name="adults"/>
|
||||
<field name="children"/>
|
||||
<!-- <field name="room_type_id" on_change="1" options="{'no_create': True,'no_open': True}"
|
||||
attrs="{'readonly':[('state','not in',('draft'))]}"/> -->
|
||||
<field name="room_type_id" on_change="1" options="{'no_create': True,'no_open': True}"
|
||||
attrs="{'readonly':[('state','not in',('draft'))]}"/>
|
||||
<field name="channel_type" attrs="{'required':[('reservation_type','not in',('staff','out'))]}"/>
|
||||
</group>
|
||||
<group class="oe_subtotal_footer" style="margin-right: 20px; !important" colspan="2" name="reservation_total" string="Amounts">
|
||||
|
||||
Reference in New Issue
Block a user