Skip to content
Extraits de code Groupes Projets

Comparer les révisions

Les modifications sont affichées comme si la révision source était fusionnée avec la révision cible. En savoir plus sur la comparaison des révisions.

Source

Sélectionner le projet cible
No results found
Sélectionner une révision Git
  • 16.0
1 résultat

Cible

Sélectionner le projet cible
  • lefilament/oacc/oacc_portal_account_surplus
  • arthur-enercoop/oacc_portal_account_surplus
2 résultats
Sélectionner une révision Git
  • 16.0
1 résultat
Afficher les modifications
Validations sur la source (2)
......@@ -10,7 +10,7 @@ from odoo.addons.http_routing.models.ir_http import slug
class PortalAccount(PortalAccount):
def _prepare_invoice_surplus_portal_values(self, operation, domain, order):
def _prepare_invoice_surplus_portal_values(self, operation, order):
"""
Get all surplus invoices matching domain
"""
......@@ -18,7 +18,6 @@ class PortalAccount(PortalAccount):
values.update(self._get_role(operation))
domain = expression.AND(
[
domain,
[("acc_operation_id", "=", operation.id)],
[("acc_delivery_id", "=", False)],
[
......@@ -65,16 +64,6 @@ class PortalAccount(PortalAccount):
values["invoices_surplus"] = request.env["account.move"].sudo().search(domain)
return values
def _get_operation_values(self, operation):
render_values = super()._get_operation_values(operation)
if operation.is_surplus_active:
render_values[
"ope_invoices_surplus"
] = self._prepare_invoice_surplus_portal_values(
operation=operation, domain=[], order="name desc"
)["invoices_surplus"]
return render_values
@http.route(
[
'/operation/<model("acc.operation"):operation>/invoices-surplus',
......@@ -89,38 +78,21 @@ class PortalAccount(PortalAccount):
"""
List all surplus invoices
"""
render_values = self._get_operation_values(operation)
searchbar_sortings = self._get_account_searchbar_sortings()
# default sort by order
if not sortby:
sortby = "date"
order = searchbar_sortings[sortby]["order"]
domain = []
searchbar_filters = self._get_account_searchbar_filters()
# default filter by value
if not filterby:
filterby = "all"
domain += searchbar_filters[filterby]["domain"]
render_values = {}
render_values.update(self._get_role(operation))
searchbar_inputs = self._get_account_searchbar_inputs()
if search and search_in:
domain += self._get_account_search_domain(search_in, search)
order = "state, name desc, start_date desc, partner_id"
render_values["invoices_surplus"] = self._prepare_invoice_surplus_portal_values(
operation, domain, order
operation, order
)["invoices_surplus"]
render_values.update(
{
"default_url": "/operation/" + slug(operation) + "/invoices-surplus",
"page_name": "invoice-surplus",
"search_in": search_in,
"search": search,
"sortby": sortby,
"filterby": filterby,
"searchbar_inputs": searchbar_inputs,
"searchbar_filters": searchbar_filters,
"page_breadcrumbs": "Factures Surplus",
}
)
......
......@@ -4,7 +4,7 @@
<xpath expr="//li[@id='menu-contact']" position="before">
<li
class="nav-item"
t-if="operation.is_surplus_active and ope_invoices_surplus"
t-if="operation.is_surplus_active and (isProductor or isAdmin or isSuperAdmin)"
>
<a
t-attf-href="/operation/#{slug(operation)}/invoices-surplus"
......@@ -17,198 +17,21 @@
</template>
<!-- Operation Document template -->
<!-- TODO: reuse same template as for consumer invoices -->
<template id='operation_invoice_surplus' name="Operation Factures Surplus">
<t t-set="body_classname" t-value="'o_woperations_body'" />
<t t-call="oacc_portal.layout_op">
<div id="wrap" t-attf-class="wrap mt-0">
<div class="container mb-5">
<t t-call="portal.portal_searchbar">
<t t-set="title">Mes factures surplus</t>
<div class="col-12 bg-white">
<h3
class="text-center mt-2 text-uppercase"
>Mes Factures Surplus</h3>
<t t-if="invoices_surplus">
<t t-set="invoices" t-value="invoices_surplus" />
<t t-call="oacc_portal_account.operation_invoice_table" />
</t>
<div class="row mt-4">
<div class="col-12 bg-white shadow">
<form
class="d-flex daterange-content pt-3"
t-att-action="'/operation/%s/invoices-surplus' % (slug(operation))"
method="get"
/>
<table class="table mt-4" t-if="invoices_surplus">
<thead>
<tr class="active">
<th />
<th />
<th>Numéro de facture</th>
<th>Date</th>
<th>Période</th>
<th>Acheteur</th>
<th class="text-center">Montant</th>
<th class="text-center">Statut</th>
<th />
</tr>
</thead>
<tbody>
<tr
t-foreach="invoices_surplus"
t-as="invoice"
>
<td>
<a
t-att-href="invoice.get_portal_url(report_type='pdf', download=True)"
target="_blank"
title="Télécharger"
aria-label="Télécharger"
>
<i class="fa fa-download" />
</a>
</td>
<td>
<a
t-att-href="invoice.get_portal_url()"
target="_blank"
title="Visualiser"
aria-label="Visualiser"
>
<i class="fa fa-eye" />
</a>
</td>
<td class="fw-bolder">
<a
t-att-href="invoice.get_portal_url()"
t-att-title="invoice.name"
target="_blank"
>
<t
t-esc="invoice.name"
t-if="invoice.name != '/'"
/>
<em
t-elif="invoice.state == 'draft'"
>Facture Brouillon</em>
<em
t-else="invoice.state == 'cancel'"
>Facture Annulée</em>
</a>
</td>
<td style="width: 120px;"><t
t-out="invoice.invoice_date"
t-options="{'widget': 'date', 'format': 'dd-MM-YYYY'}"
/></td>
<td><t
t-out="invoice.start_date"
t-options="{'widget': 'date', 'format': 'dd-MM-YYYY'}"
/> au <t
t-out="invoice.end_date"
t-options="{'widget': 'date', 'format': 'dd-MM-YYYY'}"
/></td>
<td><t
t-out="invoice.partner_id.name"
/></td>
<td class="text-end"><t
t-out="invoice.amount_total_signed"
t-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: invoice.currency_id}"
/> TTC</td>
<td class="tx_status text-center">
<t t-if="invoice.state == 'draft'">
<span
class="badge rounded-pill text-bg-info"
><i
class="fa fa-fw fa-square-o"
aria-label="Brouillon"
title="Brouillon"
role="img"
/><span
class="d-none d-md-inline"
>Brouillon</span></span>
</t>
<t
t-if="invoice.state == 'posted' and invoice.payment_state not in ('in_payment', 'paid', 'reversed')"
>
<span
class="badge rounded-pill text-bg-warning"
aria-label="En paiement"
title="Lorsque le producteur recevra votre paiement, il devra manuellement marquer la facture comme payée, le statut passera alors à Payée."
><i
class="fa fa-fw fa-clock-o"
role="img"
/><span
class="d-none d-md-inline"
>En paiement</span></span>
</t>
<t
t-if="invoice.state == 'posted' and invoice.payment_state in ('paid', 'in_payment')"
>
<span
class="badge rounded-pill text-bg-success"
><i
class="fa fa-fw fa-check-square-o"
aria-label="Payée"
title="Payée"
role="img"
/><span
class="d-none d-md-inline"
>Payée</span></span>
</t>
<t
t-if="invoice.state == 'posted' and invoice.payment_state == 'reversed'"
>
<span
class="badge rounded-pill text-bg-success"
><i
class="fa fa-fw fa-check-square-o"
aria-label="Extournée"
title="Extournée"
role="img"
/><span
class="d-none d-md-inline"
>Extournée</span></span>
</t>
</td>
<td
class="text-center"
t-if="(isProductor or isAdmin or isSuperAdmin) and invoice.state == 'draft'"
>
<a
title="Valider la facture"
aria-label="Valider la facture"
t-att-href="'/my/invoices/%s/post?from_list=invoices-surplus' % invoice.id"
class="btn btn-sm btn-primary"
role="button"
>
<i class="fa fa-check" />
<span
class="d-none d-md-inline"
>Valider</span>
</a>
</td>
<td
class="text-center"
t-elif="(isProductor or isAdmin or isSuperAdmin) and invoice.state == 'posted' and invoice.payment_state in ('not_paid', 'partial') and invoice.amount_total and invoice.move_type == 'out_invoice'"
>
<a
t-att-href="'/my/invoices/%s/pay?from_list=invoices-surplus' % invoice.id"
aria-label="Marquer la facture comme payée"
class="btn btn-sm btn-primary"
role="button"
title="Lorsque vous recevez le paiement du consommateur, cliquez sur ce bouton pour marquer le facture comme payée."
>
<i class="fa fa-credit-card" />
<span
class="d-none d-md-inline"
>Marquer comme payée</span>
</a>
</td>
<td t-else="" />
</tr>
</tbody>
</table>
<t t-else="">
<p
t-else=""
style="padding-top: 10px;"
class="pt-5"
>Il n'y a actuellement aucune facture de surplus sur cette opération.</p>
</div>
</div>
</div>
</t>
</div>
</t>
</template>
......