Skip to content
Extraits de code Groupes Projets
Valider 133e278e rédigé par Juliana's avatar Juliana
Parcourir les fichiers

[UPD]template PDF invoice

parent a88f62e1
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
# Copyright 2022 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import portal
# Copyright 2022 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import http, _
from odoo.addons.portal.controllers.portal import CustomerPortal
class PortalAccount(CustomerPortal):
@http.route(['/my/invoices/<int:invoice_id>'], type='http', auth="public", website=True)
def portal_my_invoice_detail(self, invoice_id, access_token=None, report_type=None, download=False, **kw):
invoice_sudo = self._document_check_access('acc.account', invoice_id, access_token)
if report_type in ('html', 'pdf', 'text'):
return self._show_report(
model=invoice_sudo,
report_type=report_type,
report_ref='acc_account.acc_account_invoices',
download=download)
......@@ -97,6 +97,12 @@ class AccAccount(models.Model):
amount_total = fields.Monetary(
string="Total", store=True, readonly=True, compute="_compute_amount"
)
amount_tcfe = fields.Monetary(
string="Montant TCFE", store=True, readonly=True, compute="_compute_amount"
)
amount_without_tcfe = fields.Monetary(
string="Montant hors TCFE", store=True, readonly=True, compute="_compute_amount"
)
# inverse='_inverse_amount_total')
power_cons = fields.Float("Consommation locale (index Enedis)")
url = fields.Char("URL", compute="_compute_url", store=True)
......@@ -144,10 +150,16 @@ class AccAccount(models.Model):
total_tax = 0.0
total = 0.0
tot_qty = 0.0
tot_tcfe = 0.0
tot_tcfe_off = 0.0
for line in move.line_ids:
total += line.price_total
tot_qty += line.quantity
if line.is_tax:
tot_tcfe += line.price_total
else:
tot_tcfe_off += line.price_total
if move.is_tva and move.tax_id:
total_tax = (total * move.tax_id.amount) / 100
......@@ -155,6 +167,8 @@ class AccAccount(models.Model):
move.amount_untaxed = total
move.amount_tax = total_tax
move.amount_total = total + total_tax
move.amount_tcfe = tot_tcfe
move.amount_without_tcfe = tot_tcfe_off
def _compute_url(self):
for account in self:
......@@ -206,6 +220,7 @@ class AccAccountLine(models.Model):
end_date = fields.Date("Fin de la période")
description = fields.Text("Description de la ligne")
is_tva = fields.Boolean(related="acc_account_id.is_tva")
is_tax = fields.Boolean("Est une taxe")
@api.depends("quantity", "price_unit")
def _compute_amount(self):
......@@ -266,7 +281,8 @@ class AccAccountTaxTcfe(models.Model):
_("Un prix de vente existe déjà pour cette date là")
)
price_id = self.env["acc.account.tax.tcfe"].search([],
price_id = self.env["acc.account.tax.tcfe"].search(
[],
limit=1,
order="create_date desc",
)
......
......@@ -330,6 +330,7 @@ class AccOperation(models.Model):
AccountLine.create(
{
"quantity": power_total,
"is_tax": True,
"price_unit": interval.price,
"acc_account_id": acc_account.id,
"start_date": date_interval_start,
......
......@@ -6,6 +6,7 @@
<field name="name">Factures</field>
<field name="model">acc.account</field>
<field name="report_type">qweb-pdf</field>
<!-- <field name="report_type">qweb-html</field>-->
<field name="report_name">acc_account.report_account</field>
<field name="report_file">account.report_account</field>
<field name="print_report_name">'Facture - %s' % (object.name)</field>
......
......@@ -325,114 +325,58 @@
</div>
<div>
<h2>Synthèse de votre facture</h2>
<h3>Période de livraison concernée : du <t
t-esc="o.start_date"
/> au <t t-esc="o.end_date" /></h3>
<t t-set="lines" t-value="o.line_ids" />
<t t-set="current_subtotal" t-value="0" />
<t t-foreach="lines" t-as="line">
<t
t-set="current_subtotal"
t-value="current_subtotal + line.price_total"
/>
<div >
<span
t-field="line.description"
t-options="{'widget': 'text'}"
/><br />
Prix de l'électricité locale <span
class="text-nowrap"
t-field="line.price_unit"/>
<span
class="text-nowrap"
t-field="line.price_total"/>
</div>
</t>
<h3>Période de livraison concernée : du <span
t-field="o.start_date"
t-options="{'format': 'dd/MM/yyyy'}"
/> au <span
t-field="o.end_date"
t-options="{'format': 'dd/MM/yyyy'}"
/></h3>
<hr />
<table
class="table table-sm o_main_table"
name="account_line_table"
>
<tr>
<td>Prix de l'électricité locale</td>
<td class="text-right">
</td>
</tr>
<tr>
<td>Consommation locale (index Enedis)</td>
<td>Consommation locale</td>
<td class="text-right">
<span t-field="o.power_cons" /> <span
>kWh</span>
</td>
</tr>
<t t-set="lines" t-value="o.line_ids" />
<t t-set="current_subtotal" t-value="0" />
<t t-foreach="lines" t-as="line">
<t
t-set="current_subtotal"
t-value="current_subtotal + line.price_total"
/>
<tr class="border-black">
<t
name="account_invoice_line_accountable"
>
<td
name="account_invoice_line_name"
>
<tr>
<td>Prix de l'électricité locale</td>
<td class="text-right">
<span
t-field="line.description"
t-options="{'widget': 'text'}"
/><br />
Prix de l'électricité locale <span
class="text-nowrap"
t-field="line.price_unit"
/>
t-field="o.amount_without_tcfe"
/> <span>HT</span>
</td>
</tr>
<tr>
<td>Prix de la TCFE</td>
<td class="text-right">
<span
class="text-nowrap"
t-field="line.price_total"
/>
<span t-field="o.amount_tcfe" /> <span
>HT</span>
</td>
</t>
</tr>
</t>
</table>
</div>
<div class="clearfix">
<div id="total" class="row">
<div t-attf-class="col-6 ml-auto">
<table
class="table table-sm"
style="page-break-inside: avoid;"
>
<tr
class="border-black o_subtotal"
style=""
>
<td><strong>Sous-Total</strong></td>
<tr />
<tr>
<td><strong>Total H.T.</strong></td>
<td class="text-right">
<span
t-field="o.amount_untaxed"
/>
<span t-field="o.amount_untaxed" />
</td>
</tr>
<hr />
<t t-if="o.is_tva">
<tr style="">
<t>
<td><span
class="text-nowrap"
/>TVA</td>
<td
class="text-right o_price_total"
>
/>TVA applicable <span
t-field="o.tax_id.name"
/></td>
<td class="text-right">
<span
class="text-nowrap"
t-field="o.amount_tax"
......@@ -441,19 +385,79 @@
</t>
</tr>
</t>
<tr class="border-black o_total">
<td><strong>Total</strong></td>
<tr>
<td><strong>Total TTC*</strong></td>
<td class="text-right">
<span
<strong><span
class="text-nowrap"
t-field="o.amount_total"
/>
/></strong>
</td>
</tr>
</table>
</div>
</div>
</div>
<div>
<p
>*Le total à payer correspond à l’électricité autoconsommée,
la contribution d’acheminement et les taxes hors TVA sur cette
électricité sont collectées par le fournisseur du complément
électrique.</p>
</div>
</div>
<!-- <div class="clearfix">-->
<!-- <div id="total" class="row">-->
<!-- <div t-attf-class="col-6 ml-auto">-->
<!-- <table-->
<!-- class="table table-sm"-->
<!-- style="page-break-inside: avoid;"-->
<!-- >-->
<!-- <tr-->
<!-- class="border-black o_subtotal"-->
<!-- style=""-->
<!-- >-->
<!-- <td><strong>Sous-Total</strong></td>-->
<!-- <td class="text-right">-->
<!-- <span-->
<!-- t-field="o.amount_untaxed"-->
<!-- />-->
<!-- </td>-->
<!-- </tr>-->
<!-- <t t-if="o.is_tva">-->
<!-- <tr style="">-->
<!-- <t>-->
<!-- <td><span-->
<!-- class="text-nowrap"-->
<!-- />TVA</td>-->
<!-- <td-->
<!-- class="text-right o_price_total"-->
<!-- >-->
<!-- <span-->
<!-- class="text-nowrap"-->
<!-- t-field="o.amount_tax"-->
<!-- />-->
<!-- </td>-->
<!-- </t>-->
<!-- </tr>-->
<!-- </t>-->
<!-- <tr class="border-black o_total">-->
<!-- <td><strong>Total TTC*</strong></td>-->
<!-- <td class="text-right">-->
<!-- <span-->
<!-- class="text-nowrap"-->
<!-- t-field="o.amount_total"-->
<!-- />-->
<!-- </td>-->
<!-- </tr>-->
<!-- </table>-->
<!-- <div>-->
<!-- <p>*Le total à payer correspond à l’électricité autoconsommée,-->
<!-- la contribution d’acheminement et les taxes hors TVA sur cette-->
<!-- électricité sont collectées par le fournisseur du complément-->
<!-- électrique.</p>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
</div>
</div>
......
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data noupdate="1">
<data noupdate="0">
<!-- Portal for invoice and invoice lines -->
<record id="acc_account_rule_portal_cons" model="ir.rule">
......@@ -25,7 +25,10 @@
<record id="acc_account_rule_portal_pmo" model="ir.rule">
<field name="name">Portail : Factures pour les pmo</field>
<field name="model_id" ref="acc_account.model_acc_account" />
<field name="domain_force">[('pmo_id','=',[user.partner_id.id])]</field>
<!-- <field name="domain_force">[('pmo_id','=',[user.partner_id.id])]</field>-->
<field
name="domain_force"
>[('pmo_id','child_of',[user.partner_id.id])]</field>
<field name="groups" eval="[(4, ref('base.group_portal'))]" />
</record>
......
......@@ -7,3 +7,7 @@
.o_report_layout_boxed div#total table tr.o_total strong {
color: #000 !important;
}
.o_report_layout_boxed table tbody tr td {
border-right: 0px solid #495057 !important;
}
......@@ -241,6 +241,8 @@
<field name="start_date" />
<field name="end_date" />
<field name="power_cons" />
<field name="amount_tcfe" />
<field name="amount_without_tcfe" />
</group>
</group>
<group>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter