-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Release * [IMP] Pricing multi rate (OCA#47) * Pricing multi rate * improve pricing compute * Fix: Cleaning fee on multiquote and unit price (OCA#49) * fix send order (singleton issue on write) (OCA#50) * fix send order (singleton issue on write) * fix state validation * Fix guest info on guesty (push/update) (OCA#51) * ADD CI/CO Date on SO (PDF & Portal) (OCA#53) * Branch Consolidation * ADD CI/CO date and time on SO preview (Portal) (OCA#52) * changes to complement the qweb view * fix add hour on ci/co Co-authored-by: Brandon Molina <[email protected]> * Feature/sale pdf format (OCA#48) * report pdf custom with checkint-out info * new format for changes * fix format * fix: add hour in CI/CO Co-authored-by: Brandon Molina <[email protected]> Co-authored-by: Brandon Molina <[email protected]> * Fix: remove logs Co-authored-by: Brandon Molina <[email protected]>
- Loading branch information
1 parent
f63c008
commit 9aa7862
Showing
11 changed files
with
253 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Copyright (C) 2021 Casai (https://www.casai.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
import datetime | ||
import logging | ||
|
||
from odoo import models | ||
|
||
_log = logging.getLogger(__name__) | ||
|
||
|
||
class ProductProduct(models.Model): | ||
_inherit = "product.product" | ||
|
||
def price_compute(self, price_type): | ||
result = super().price_compute(price_type) | ||
for product in self: | ||
if product.reservation_ok and self.env.company.guesty_backend_id: | ||
property_id = self.env.context.get("property_id") | ||
reservation_start = self.env.context.get("reservation_start") | ||
reservation_stop = self.env.context.get("reservation_stop") | ||
reservation_date = self.env.context.get("reservation_date") | ||
if ( | ||
property_id | ||
and reservation_start | ||
and reservation_stop | ||
and reservation_date | ||
): | ||
price = product.compute_reservation_price( | ||
property_id, | ||
reservation_start, | ||
reservation_stop, | ||
reservation_date, | ||
) | ||
if price: | ||
result[product.id] = price | ||
return result | ||
|
||
def compute_reservation_price(self, property_id, start, stop, reservation_date): | ||
real_stop_date = stop - datetime.timedelta(days=1) | ||
success, result = self.env.company.guesty_backend_id.call_get_request( | ||
url_path="availability-pricing/api/calendar/listings/{}".format( | ||
property_id.guesty_id | ||
), | ||
params={ | ||
"startDate": start.strftime("%Y-%m-%d"), | ||
"endDate": real_stop_date.strftime("%Y-%m-%d"), | ||
}, | ||
paginate=False, | ||
) | ||
if not success: | ||
return None | ||
|
||
dates_list = result["data"]["days"] | ||
if len(dates_list) == 0: | ||
return None | ||
|
||
prices = [calendar.get("price", 0.0) for calendar in dates_list] | ||
avg_price = sum(prices) / len(prices) | ||
|
||
currency_name = dates_list[0]["currency"] | ||
currency_id = ( | ||
self.env["res.currency"] | ||
.sudo() | ||
.search([("name", "=", currency_name)], limit=1) | ||
) | ||
|
||
if not currency_id: | ||
currency_id = self.sudo().env.ref("base.USD", raise_if_not_found=False) | ||
|
||
# noinspection PyProtectedMember | ||
price_currency = currency_id._convert( | ||
avg_price, | ||
self.currency_id, | ||
self.env.company, | ||
reservation_date, | ||
) | ||
|
||
return price_currency |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,24 @@ | ||
# Copyright (C) 2021 Casai (https://www.casai.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from odoo import fields, models | ||
from odoo import _, fields, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
guesty_ids = fields.One2many("res.partner.guesty", "partner_id") | ||
|
||
def split_name(self): | ||
name_values = self.name.split(" ") | ||
if len(name_values) == 0: | ||
raise ValidationError(_("No name defined")) | ||
|
||
if len(name_values) == 1: | ||
return name_values[0], None | ||
|
||
if len(name_values) == 2: | ||
return name_values[0], name_values[1] | ||
|
||
if len(name_values) >= 3: | ||
return name_values[0], " ".join(name_values[1:-1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,37 @@ | ||
# Copyright (C) 2021 Casai (https://www.casai.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
import logging | ||
|
||
from odoo import fields, models | ||
|
||
_log = logging.getLogger(__name__) | ||
|
||
|
||
class ResPartnerGuesty(models.Model): | ||
_name = "res.partner.guesty" | ||
_description = "Guesty Partner" | ||
|
||
partner_id = fields.Many2one("res.partner", required=True, ondelete="cascade") | ||
guesty_id = fields.Char(required=True) | ||
|
||
def guesty_push_update(self): | ||
first_name, last_name = self.partner_id.split_name() | ||
|
||
body = { | ||
"firstName": first_name, | ||
"lastName": last_name, | ||
"fullName": self.partner_id.name, | ||
} | ||
|
||
if self.partner_id.phone: | ||
body["phone"] = self.partner_id.phone | ||
|
||
if self.partner_id.email: | ||
body["email"] = self.partner_id.email | ||
|
||
success, res = self.env.company.guesty_backend_id.call_put_request( | ||
url_path="guests/{}".format(self.guesty_id), body=body | ||
) | ||
|
||
if success: | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<odoo> | ||
<template | ||
id="sale_order_report_custom" | ||
inherit_id="sale.report_saleorder_document" | ||
name="sale.order.report.custom" | ||
> | ||
<xpath expr="//div[@id='informations']" position="after"> | ||
<div class="o_check_out_info"> | ||
<br /> | ||
<strong>Reservation details</strong> | ||
<table class="table table-sm o_second_table"> | ||
<thead style="display: table-row-group"> | ||
<tr> | ||
<th name="th_check_in" class="text-left">Check in</th> | ||
<th name="th_check_out" class="text-left">Check out</th> | ||
</tr> | ||
</thead> | ||
<tbody class="check_info_tbody"> | ||
<tr> | ||
<td name="td_check_in"> | ||
<span | ||
t-field="doc.check_in" | ||
t-options='{"widget": "datetime", "format": "MMM dd, Y HH:mm"}' | ||
/> | ||
</td> | ||
<td name="td_check_out" class="text-left"> | ||
<span | ||
t-field="doc.check_out" | ||
t-options='{"widget": "datetime", "format": "MMM dd, Y HH:mm"}' | ||
/> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</xpath> | ||
</template> | ||
</odoo> |
26 changes: 26 additions & 0 deletions
26
connector_guesty/views/sales_order_portal_template_custom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<odoo> | ||
<template | ||
id="sale_order_portal_template_custom" | ||
inherit_id="sale.sale_order_portal_content" | ||
name="sale.order.portal.template.custom" | ||
> | ||
<xpath expr="//div[@class='row']" position="after"> | ||
<div> | ||
<br /> | ||
<strong class="d-block mb-1">Reservation details</strong> | ||
<span>Check in:</span> | ||
<b | ||
t-field="sale_order.check_in" | ||
t-options='{"widget": "datetime", "format": "MMM dd, Y HH:mm"}' | ||
/> | ||
<br /> | ||
<span>Check out:</span> | ||
<b | ||
t-field="sale_order.check_out" | ||
t-options='{"widget": "datetime", "format": "MMM dd, Y HH:mm"}' | ||
/> | ||
<hr /> | ||
</div> | ||
</xpath> | ||
</template> | ||
</odoo> |
Oops, something went wrong.