mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD] Compute tax excluded
This commit is contained in:
@@ -112,7 +112,7 @@ class HotelReservation(models.Model):
|
||||
line.invoice_status = 'invoiced'
|
||||
else:
|
||||
line.invoice_status = 'no'
|
||||
|
||||
|
||||
|
||||
@api.model
|
||||
def name_search(self, name='', args=None, operator='ilike', limit=100):
|
||||
@@ -173,7 +173,7 @@ class HotelReservation(models.Model):
|
||||
track_visibility='onchange')
|
||||
reservation_type = fields.Selection(related='folio_id.reservation_type',
|
||||
default=lambda *a: 'normal')
|
||||
invoice_count = fields.Integer(related='folio_id.invoice_count')
|
||||
invoice_count = fields.Integer(related='folio_id.invoice_count')
|
||||
board_service_room_id = fields.Many2one('hotel.board.service.room.type',
|
||||
string='Board Service')
|
||||
cancelled_reason = fields.Selection([
|
||||
@@ -305,10 +305,12 @@ class HotelReservation(models.Model):
|
||||
price_subtotal = fields.Monetary(string='Subtotal',
|
||||
readonly=True,
|
||||
store=True,
|
||||
digits=dp.get_precision('Product Price'),
|
||||
compute='_compute_amount_reservation')
|
||||
price_total = fields.Monetary(string='Total',
|
||||
readonly=True,
|
||||
store=True,
|
||||
digits=dp.get_precision('Product Price'),
|
||||
compute='_compute_amount_reservation')
|
||||
price_tax = fields.Float(string='Taxes',
|
||||
readonly=True,
|
||||
@@ -317,10 +319,12 @@ class HotelReservation(models.Model):
|
||||
price_services = fields.Monetary(string='Services Total',
|
||||
readonly=True,
|
||||
store=True,
|
||||
digits=dp.get_precision('Product Price').
|
||||
compute='_compute_amount_room_services')
|
||||
price_room_services_set = fields.Monetary(string='Room Services Total',
|
||||
readonly=True,
|
||||
store=True,
|
||||
digits=dp.get_precision('Product Price'),
|
||||
compute='_compute_amount_set')
|
||||
discount = fields.Float(string='Discount (€)',
|
||||
digits=dp.get_precision('Discount'),
|
||||
@@ -347,7 +351,7 @@ class HotelReservation(models.Model):
|
||||
'channel_type': vals.get('channel_type')})
|
||||
if 'service_ids' in vals and vals['service_ids'][0][2]:
|
||||
for service in vals['service_ids']:
|
||||
service[2]['folio_id'] = folio.id
|
||||
service[2]['folio_id'] = folio.id
|
||||
vals.update({
|
||||
'last_updated_res': fields.Datetime.now(),
|
||||
})
|
||||
|
||||
@@ -23,7 +23,9 @@ class HotelReservationLine(models.Model):
|
||||
ondelete='cascade', required=True,
|
||||
copy=False)
|
||||
date = fields.Date('Date')
|
||||
price = fields.Float('Price')
|
||||
price = fields.Float(
|
||||
string='Price',
|
||||
digits=dp.get_precision('Product Price'))
|
||||
discount = fields.Float(
|
||||
string='Discount (%)',
|
||||
digits=dp.get_precision('Discount'), default=0.0)
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='room_type_id']" position="attributes">
|
||||
<!-- attribute name="attrs">{'readonly': [('channel_reservation_id','!=',False),('able_to_modify_channel','=',False)]}</attribute-->
|
||||
<attribute name="attrs">{'readonly': [('able_to_modify_channel','=',False)]}</attribute>
|
||||
<attribute name="attrs">{'readonly': [('is_from_ota','=',True),('able_to_modify_channel','=',False)]}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='children']" position="attributes">
|
||||
<attribute name="attrs">{'readonly': [('is_from_ota','=',True),('able_to_modify_channel','=',False)]}</attribute>
|
||||
|
||||
@@ -97,8 +97,12 @@ class HotelReservationImporter(Component):
|
||||
DEFAULT_WUBOOK_DATE_FORMAT
|
||||
).replace(tzinfo=tz.gettz('UTC'))
|
||||
if dates_checkin[0] >= wndate <= (dates_checkout[0] - timedelta(days=1)):
|
||||
# HOT-FIX: Hard-Coded Tax 10%
|
||||
room_day_price = round(brday['price'] * 1.1, 2) if not tax_inclusive else brday['price']
|
||||
amount_day_tax = 0
|
||||
if not tax_inclusive:
|
||||
price_subtotal = book['amount'] - broom['ancillary']['taxes']
|
||||
day_tax_weigh = brday['price'] * 100 / price_subtotal
|
||||
amount_day_tax = broom['ancillary']['taxes'] * day_tax_weigh / 100
|
||||
room_day_price = brday['price'] + amount_day_tax
|
||||
reservation_lines.append((0, False, {
|
||||
'date': wndate.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
'price': room_day_price,
|
||||
@@ -114,6 +118,7 @@ class HotelReservationImporter(Component):
|
||||
'external_id': rcode,
|
||||
'ota_id': ota_id and ota_id.id,
|
||||
'ota_reservation_id': crcode,
|
||||
'channel_status': str(book['status']),
|
||||
'channel_raw_data': json.dumps(book),
|
||||
'channel_modified': book['was_modified'],
|
||||
}
|
||||
@@ -122,7 +127,7 @@ class HotelReservationImporter(Component):
|
||||
'checkout': checkout_str,
|
||||
'adults': persons,
|
||||
'children': book['children'],
|
||||
'reservation_lines': reservation_lines,
|
||||
'reservation_line_ids': reservation_lines,
|
||||
'price_unit': tprice,
|
||||
'to_assign': True,
|
||||
'to_read': True,
|
||||
@@ -130,9 +135,8 @@ class HotelReservationImporter(Component):
|
||||
'room_type_id': room_type_bind.odoo_id.id,
|
||||
'splitted': split_booking,
|
||||
'name': room_type_bind and room_type_bind.name,
|
||||
'channel_bind_ids': [(0, False, binding_vals)]
|
||||
'channel_bind_ids': [(0, False, binding_vals)],
|
||||
}
|
||||
|
||||
return vals
|
||||
|
||||
@api.model
|
||||
@@ -447,7 +451,7 @@ class HotelReservationImporter(Component):
|
||||
rlines = sorted_rlines = folio_id.room_lines
|
||||
for rline in rlines:
|
||||
for rline_bind in rline.channel_bind_ids:
|
||||
self.binder(rline_bind.external_id, rline_bind)
|
||||
self.binder.bind(rline_bind.external_id, rline_bind)
|
||||
|
||||
processed_rids.append(rcode)
|
||||
return (processed_rids, any(failed_reservations),
|
||||
|
||||
Reference in New Issue
Block a user