Merge PR #274 into 14.0

Signed-off-by DarioLodeiros
This commit is contained in:
OCA-git-bot
2024-06-24 07:46:55 +00:00
14 changed files with 137 additions and 12 deletions

View File

@@ -94,6 +94,7 @@
"views/precheckin_portal_templates.xml",
"wizards/wizard_massive_changes.xml",
"wizards/wizard_advanced_filters.xml",
"wizards/folio_payment_link_views.xml",
"views/payment_transaction_views.xml",
"views/account_move_line_views.xml",
"report/proforma_report_templates.xml",

View File

@@ -282,8 +282,19 @@ class AccountMove(models.Model):
payments=to_propose, invoice=move
)
if to_reconcile:
(pay_term_lines + to_reconcile).reconcile()
try:
(pay_term_lines + to_reconcile).reconcile()
except Exception as e:
message = (
_(
"""
An error occurred while reconciling
the invoice with the payments: %s
"""
)
% str(e)
)
move.message_post(body=message)
return True
def _post(self, soft=True):

View File

@@ -237,6 +237,11 @@ class PmsProperty(models.Model):
string="Image in checkin",
default=get_default_logo(),
)
block_create_past_reservations = fields.Boolean(
string="Block Create Past Reservations",
help="Block the creation of reservations in the past",
default=False,
)
@api.depends_context(
"checkin",

View File

@@ -570,3 +570,10 @@ class PmsReservationLine(models.Model):
)
if duplicated:
raise ValidationError(_("Duplicated reservation line date"))
@api.constrains("date")
def _check_past_reservations(self):
for record in self:
if record.pms_property_id.block_create_past_reservations:
if record.date < fields.Date.today():
raise ValidationError(_("You can't create past reservations"))

View File

@@ -346,7 +346,7 @@ class PmsService(models.Model):
continue
product = service.product_id
consumed_on = product.consumed_on
if product.per_day:
if product.per_day and consumed_on in ("before", "after"):
lines = []
day_qty = service._service_day_qty()
days_diff = (reservation.checkout - reservation.checkin).days
@@ -406,13 +406,18 @@ class PmsService(models.Model):
service.service_line_ids = lines
else:
if not service.service_line_ids:
target_date = (
reservation.checkin
if consumed_on == "checkin"
else reservation.checkout
)
price_unit = service._get_price_unit_line()
service.service_line_ids = [
(
0,
False,
{
"date": fields.Date.today(),
"date": target_date,
"day_qty": day_qty,
"price_unit": price_unit,
},

View File

@@ -31,7 +31,12 @@ class ProductTemplate(models.Model):
consumed_on = fields.Selection(
string="Consumed",
help="Indicates when the product is consumed",
selection=[("before", "Before night"), ("after", "After night")],
selection=[
("before", "All before night"),
("after", "All after night"),
("checkin", "Only first day"),
("checkout", "Only last day"),
],
default="before",
)
daily_limit = fields.Integer(

View File

@@ -34,6 +34,18 @@ class ResPartner(models.Model):
index=True,
)
default_commission = fields.Integer(string="Commission", help="Default commission")
commission_type = fields.Selection(
selection=[
("included", "Commission Included in Price"),
("subtract", "Commission Subtracts from Price"),
],
string="Commission Type",
help="""
If select subtract commission, for automatic import of reservations,
the commission is calculated as price - (price * commission / 100)
""",
default="included",
)
apply_pricelist = fields.Boolean(
string="Apply Pricelist",
help="Indicates if agency pricelist is applied to his reservations",

View File

@@ -8,10 +8,11 @@
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
@@ -274,7 +275,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -300,7 +301,7 @@ span.option {
span.pre {
white-space: pre }
span.problematic {
span.problematic, pre.problematic {
color: red }
span.section-subtitle {
@@ -438,7 +439,9 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>

View File

@@ -74,6 +74,9 @@
>
<field name="default_pricelist_id" required="True" />
</group>
<group string="Reservation">
<field name="block_create_past_reservations" />
</group>
<group string="Timezone">
<field name="tz" widget="timezone_mismatch" />
</group>

View File

@@ -82,6 +82,7 @@
name="sale_channel_id"
options="{'no_create': True,'no_open': True}"
/>
<field name="commission_type" />
<field name="default_commission" />
<!-- <label for="price_discount"/>
<div class="o_row">

View File

@@ -7,3 +7,4 @@ from . import wizard_payment_folio
from . import wizard_folio_changes
from . import wizard_several_partners
from . import pms_booking_duplicate
from . import folio_payment_link

View File

@@ -0,0 +1,59 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from werkzeug import urls
from odoo import api, models
class FolioPaymentLink(models.TransientModel):
_inherit = "payment.link.wizard"
_description = "Generate Sales Payment Link"
@api.model
def default_get(self, fields):
res = super(FolioPaymentLink, self).default_get(fields)
if res["res_id"] and res["res_model"] == "pms.folio":
record = self.env[res["res_model"]].browse(res["res_id"])
res.update(
{
"description": record.name,
"amount": record.pending_amount,
"currency_id": record.currency_id.id,
"partner_id": record.partner_id.id if record.partner_id else False,
"amount_max": record.pending_amount,
}
)
return res
def _generate_link(self):
"""Override of the base method to add the folio_id in the link."""
for payment_link in self:
if payment_link.res_model == "pms.folio":
# TODO: Review controller /website_payment/pay,
# how inherit it to add acquirers by property?
# now we send the first acquirer that has the property in pms_property_ids
folio = self.env["pms.folio"].browse(payment_link.res_id)
acquirer = self.env["payment.acquirer"].search(
[
("pms_property_ids", "in", folio.property_id.id),
],
limit=1,
)
record = self.env[payment_link.res_model].browse(payment_link.res_id)
payment_link.link = (
"%s/website_payment/pay?reference=%s&amount=%s&currency_id=%s"
"&acquirer_id=%s&partner_id=%s&folio_id=%s&company_id=%s"
"&access_token=%s"
) % (
record.get_base_url(),
urls.url_quote_plus(payment_link.description),
payment_link.pending_amount,
payment_link.currency_id.id,
acquirer.id if acquirer else None,
payment_link.partner_id.id if payment_link.partner_id else None,
payment_link.res_id,
payment_link.company_id.id,
payment_link.access_token,
)
else:
super(FolioPaymentLink, payment_link)._generate_link()

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="action_folio_generate_link" model="ir.actions.act_window">
<field name="name">Generate a Payment Link</field>
<field name="res_model">payment.link.wizard</field>
<field name="view_mode">form</field>
<field name="view_id" ref="payment.payment_link_wizard_view_form" />
<field name="target">new</field>
<field name="binding_model_id" ref="model_pms_folio" />
<field name="binding_view_types">form</field>
</record>
</odoo>

View File

@@ -343,9 +343,7 @@ class BookingDuplicate(models.TransientModel):
"price_unit": ser_line.price_unit,
"discount": ser_line.discount,
"date": ser_line.date
+ datetime.timedelta(days=displacement_days)
if service.per_day
else fields.Date.today(),
+ datetime.timedelta(days=displacement_days),
},
)
)