[TMP][FIX] run create direct folio

Failed automatic fusion
This commit is contained in:
Pablo
2018-10-25 12:14:03 +02:00
3 changed files with 13 additions and 28 deletions

View File

@@ -314,7 +314,7 @@ 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']
@@ -492,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

View File

@@ -334,12 +334,11 @@ class HotelReservation(models.Model):
def _prepare_add_missing_fields(self, values):
""" Deduce missing required fields from the onchange """
res = {}
onchange_fields = ['room_id', 'reservation_type', 'currency_id']
onchange_fields = ['room_id', 'reservation_type', 'currency_id', 'name']
if values.get('partner_id') and values.get('room_type_id'):
line = self.new(values)
if any(f not in values for f in onchange_fields):
line.onchange_room_id()
if 'name' not in values:
line.onchange_compute_reservation_description()
if 'pricelist_id' not in values:
line.onchange_partner_id()
@@ -892,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

View File

@@ -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">