[IMP]pms: add report proforma routes

This commit is contained in:
Darío Lodeiros
2022-11-06 10:02:50 +01:00
parent 9c9522182a
commit 9e0562ac53
5 changed files with 95 additions and 2 deletions

View File

@@ -94,6 +94,7 @@
"views/account_move_line_views.xml",
"report/proforma_report_templates.xml",
"report/proforma_report.xml",
"views/account_portal_templates.xml",
],
"demo": [
"demo/pms_master_data.xml",

View File

@@ -570,3 +570,41 @@ class PortalPrecheckin(CustomerPortal):
if firstname and email:
checkin_partner.write({"firstname": firstname, "email": email})
checkin_partner.send_portal_invitation_email(firstname, email)
class PortalAccount(CustomerPortal):
@http.route(
["/my/invoices/proforma/<int:invoice_id>"],
type="http",
auth="public",
website=True,
)
def portal_proforma_my_invoice_detail(
self, invoice_id, access_token=None, report_type=None, download=False, **kw
):
try:
invoice_sudo = self._document_check_access(
"account.move", invoice_id, access_token
)
except (AccessError, MissingError):
return request.redirect("/my")
if report_type in ("html", "pdf", "text"):
return self._show_report(
model=invoice_sudo,
report_type=report_type,
report_ref="pms.action_report_pms_pro_forma_invoice",
download=download,
)
invoice_sudo = invoice_sudo.with_context(proforma=True)
values = self._invoice_get_page_view_values(invoice_sudo, access_token, **kw)
acquirers = values.get("acquirers")
if acquirers:
country_id = (
values.get("partner_id") and values.get("partner_id")[0].country_id.id
)
values["acq_extra_fees"] = acquirers.get_acquirer_extra_fees(
invoice_sudo.amount_residual, invoice_sudo.currency_id, country_id
)
return request.render("pms.pms_proforma_invoice_template", values)

View File

@@ -353,3 +353,38 @@ class AccountMove(models.Model):
self.folio_ids.message_post(body=mens)
raise ValidationError(mens)
return True
def _proforma_access_url(self):
self.ensure_one()
if self.is_invoice(include_receipts=True):
return "/my/invoices/proforma/%s" % (self.id)
else:
return False
def get_proforma_portal_url(
self,
suffix=None,
report_type=None,
download=None,
query_string=None,
anchor=None,
):
"""
Get a proforma portal url for this model, including access_token.
The associated route must handle the flags for them to have any effect.
- suffix: string to append to the url, before the query string
- report_type: report_type query string, often one of: html, pdf, text
- download: set the download query string to true
- query_string: additional query string
- anchor: string to append after the anchor #
"""
self.ensure_one()
url = self._proforma_access_url() + "%s?access_token=%s%s%s%s%s" % (
suffix if suffix else "",
self._portal_ensure_token(),
"&report_type=%s" % report_type if report_type else "",
"&download=true" if download else "",
query_string if query_string else "",
"#%s" % anchor if anchor else "",
)
return url

View File

@@ -1896,6 +1896,7 @@ class PmsFolio(models.Model):
else partner_invoice.invoicing_policy
)
invoice_date = False
if date:
invoice_date = date
if partner_invoice_policy == "checkout":
@@ -1926,8 +1927,9 @@ class PmsFolio(models.Model):
datetime.date.today().month + 1,
month_day,
)
for vals in invoice_vals_list:
vals["invoice_date"] = invoice_date
if invoice_date:
for vals in invoice_vals_list:
vals["invoice_date"] = invoice_date
# 3) Create invoices.

View File

@@ -0,0 +1,17 @@
<odoo>
<template
id="pms_proforma_invoice_template"
name="Invoice Proforma Portal Template"
inherit_id="account.portal_invoice_page"
priority="20"
primary="True"
>
<xpath expr="//iframe[@id='invoice_html']" position="attributes">
<attribute
name="t-att-src"
>invoice.get_proforma_portal_url(report_type='html')</attribute>
</xpath>
</template>
</odoo>