Browse Source

[FIX] add invoice report facile data

pull/1/head
Ny Zo 2 months ago
parent
commit
eedbc83be7
  1. 6
      __init__.py
  2. 1
      models/__init__.py
  3. 36
      models/account_move.py
  4. 59
      static/src/img/header-report.svg
  5. 229
      views/report_invoice_template.xml

6
__init__.py

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
# from . import models
from . import models

1
models/__init__.py

@ -0,0 +1 @@
from . import account_move

36
models/account_move.py

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
from json import dumps
from odoo import fields, models
from odoo.tools.misc import formatLang
class AccountMove(models.Model):
_inherit = "account.move"
def get_tax_lines_json(self):
"""Get tax line in json"""
self.ensure_one()
for move in self:
tax_line_ids = self.env['account.tax']
for line in move.line_ids:
tax_line_ids += line.tax_ids
tax_line_ids = list(set(tax_line_ids))
result_lines = []
for tax in tax_line_ids:
line_tax_ids = move.line_ids.filtered(lambda l: tax in l.tax_ids)
base_amount = sum(l.price_subtotal for l in line_tax_ids)
amount_total = sum(l.price_total for l in line_tax_ids)
amount_taxed = amount_total - base_amount
values_line = {
'name': tax.name,
'percentage': tax.amount,
'base_amount': formatLang(self.env, base_amount, currency_obj=move.currency_id),
'amount_taxed': formatLang(self.env, amount_taxed, currency_obj=move.currency_id),
'amount_total': formatLang(self.env, amount_total, currency_obj=move.currency_id),
}
result_lines.append(values_line)
move.tax_line_json = dumps(result_lines)
tax_line_json = fields.Char('Taxe JSON', compute='get_tax_lines_json')

59
static/src/img/header-report.svg

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="1209.338" height="101.599" viewBox="0, 0, 1209.338, 101.599">
<defs>
<clipPath id="Clip_1">
<path d="M-0,101.599 L489.338,101.599 L489.338,-0 L-0,-0 z"/>
</clipPath>
</defs>
<g id="Calque_1">
<g id="Layer_1">
<path d="M525.602,101.599 L1209.338,101.599 L1209.338,51.186 L525.602,51.186 z" fill="#2A3077"/>
<text transform="matrix(1, 0, -0, 1, 755.543, 31.186)">
<tspan x="-77.545" y="6" font-family="AvenirNext-Regular" font-size="21" kerning="0.5" fill="#2A3077">On ne peut pas</tspan>
<tspan x="77.545" y="6" font-family="AvenirNext-Regular" font-size="21" kerning="0" fill="#2A3077"> </tspan>
</text>
<text transform="matrix(1, 0, -0, 1, 862.94, 31.186)">
<tspan x="-24.1" y="6" font-family="AvenirNext-Bold" font-size="21" kerning="0.5" fill="#2A3077">fai</tspan>
<tspan x="3.146" y="6" font-family="AvenirNext-Bold" font-size="21" kerning="0.122" fill="#2A3077">r</tspan>
<tspan x="11.584" y="6" font-family="AvenirNext-Bold" font-size="21" kerning="0" fill="#2A3077">e</tspan>
</text>
<text transform="matrix(1, 0, -0, 1, 962.08, 31.186)">
<tspan x="-74.539" y="6" font-family="AvenirNext-Regular" font-size="21" kerning="0.5" fill="#2A3077"> les hotdogs et</tspan>
<tspan x="74.539" y="6" font-family="AvenirNext-Regular" font-size="21" kerning="0" fill="#2A3077"> </tspan>
</text>
<text transform="matrix(1, 0, -0, 1, 1117.5, 31.186)">
<tspan x="-75.128" y="6" font-family="AvenirNext-Bold" font-size="21" kerning="0.5" fill="#2A3077">servir le clien</tspan>
<tspan x="67.315" y="6" font-family="AvenirNext-Bold" font-size="21" kerning="0" fill="#2A3077">t</tspan>
</text>
<text transform="matrix(1, 0, -0, 1, 1195.953, 31.186)">
<tspan x="-2.822" y="6" font-family="AvenirNext-Regular" font-size="21" kerning="0.185" fill="#2A3077">.</tspan>
<tspan x="2.822" y="6" font-family="AvenirNext-Regular" font-size="21" kerning="0" fill="#2A3077"> </tspan>
</text>
<text transform="matrix(1, 0, -0, 1, 607.5, 74.893)">
<tspan x="-63.546" y="6" font-family="AvenirNext-Regular" font-size="21" fill="#FFFFFF">Nous traitons</tspan>
<tspan x="63.546" y="6" font-family="AvenirNext-Regular" font-size="21" kerning="0" fill="#FFFFFF"> </tspan>
</text>
<text transform="matrix(1, 0, -0, 1, 740.671, 74.893)">
<tspan x="-64.123" y="6" font-family="AvenirNext-Bold" font-size="21" fill="#FFFFFF">vos donnée</tspan>
<tspan x="54.211" y="6" font-family="AvenirNext-Bold" font-size="21" kerning="0" fill="#FFFFFF">s</tspan>
</text>
<text transform="matrix(1, 0, -0, 1, 911.779, 74.893)">
<tspan x="-106.984" y="6" font-family="AvenirNext-Regular" font-size="21" fill="#FFFFFF"> afin que vous puissiez</tspan>
<tspan x="106.984" y="6" font-family="AvenirNext-Regular" font-size="21" kerning="0" fill="#FFFFFF"> </tspan>
</text>
<text transform="matrix(1, 0, -0, 1, 1108.507, 74.893)">
<tspan x="-84.493" y="6" font-family="AvenirNext-Bold" font-size="21" fill="#FFFFFF">servir vos client</tspan>
<tspan x="74.581" y="6" font-family="AvenirNext-Bold" font-size="21" kerning="0" fill="#FFFFFF">s</tspan>
</text>
<text transform="matrix(1, 0, -0, 1, 1195.731, 74.893)">
<tspan x="-2.73" y="6" font-family="AvenirNext-Regular" font-size="21" kerning="0" fill="#FFFFFF">.</tspan>
</text>
<g clip-path="url(#Clip_1)">
<path d="M15.97,60.228 L15.924,101.659 L-0.06,101.659 L-0.011,47.638 C0.002,35.696 9.946,32.606 20.241,32.606 L39.112,32.606 L39.155,41.75 L20.252,41.75 C16.671,41.75 15.984,44.528 15.976,47.644 L15.962,51.084 L36.557,51.084 L36.6,60.228 L15.97,60.228 z M252.933,61.317 L268.507,61.317 C271.131,61.317 271.189,56.914 271.192,55.162 C271.197,52.02 270.677,48.413 266.836,48.413 L257.794,48.413 C253.537,48.413 252.924,52.556 252.928,56.013 L252.933,61.317 z M275.79,48.335 L285.458,48.335 C287.084,48.335 287.122,45.603 287.123,44.515 C287.127,42.565 286.803,40.326 284.42,40.326 L278.808,40.326 C276.165,40.326 275.785,42.897 275.788,45.042 L275.79,48.335 z M265.532,70.327 L272.111,70.327 C273.22,70.327 273.243,68.469 273.245,67.729 C273.247,66.401 273.027,64.879 271.404,64.879 L267.585,64.879 C265.787,64.879 265.528,66.628 265.53,68.088 L265.532,70.327 z M226.125,83.251 L226.122,86.136 C226.115,91.018 229.089,92.503 233.638,92.503 L257.485,92.503 L257.458,101.659 L233.619,101.659 C221.394,101.659 210.102,97.851 210.102,83.829 L210.102,68.374 C210.102,55.314 219.521,51.018 231.347,51.018 L241.102,51.018 L241.694,51.023 C240.43,53.591 240.152,56.972 240.156,60.041 L240.156,60.175 L231.358,60.175 C226.766,60.175 226.105,64.644 226.108,68.372 L226.113,74.096 L242.918,74.096 C245.059,74.096 245.615,71.375 245.761,69.232 L261.754,69.232 C260.957,79.641 253.045,83.251 242.947,83.251 L226.125,83.251 z M78.078,69.466 L78.094,64.269 C78.101,60.98 75.889,60.228 72.923,60.228 L46.794,60.228 L46.777,51.084 L72.894,51.084 C85.01,51.084 94.084,55.699 94.077,68.89 L94.075,84.311 C94.05,96.42 86.812,101.659 75.178,101.659 L62.662,101.659 C51.459,101.659 42.402,97.662 42.426,85.239 C42.411,73.023 51.872,69.466 62.662,69.466 L78.078,69.466 z M124.588,92.515 L143.792,92.515 L143.742,101.659 L124.556,101.659 C112.661,101.659 101.082,98.143 101.091,84.309 L101.108,68.89 C101.098,54.88 112.379,51.084 124.588,51.084 L143.776,51.084 L143.817,60.228 L124.616,60.228 C118.967,60.228 117.101,63.573 117.094,68.892 L117.077,84.309 C117.085,89.567 119.123,92.515 124.588,92.515 z M167.115,51.084 L167.08,101.659 L151.095,101.659 L151.13,51.084 L167.115,51.084 z M167.132,32.606 L167.118,46.228 L151.134,46.228 L151.146,32.606 L167.132,32.606 z M205.55,92.515 L205.501,101.659 L204.097,101.659 C200.611,101.659 197.127,101.659 193.641,101.659 C184.319,101.657 174.805,98.983 174.811,88.013 L174.841,32.606 L190.828,32.606 L190.796,88.013 C190.798,90.137 191.097,92.51 193.672,92.515 C197.159,92.515 200.644,92.515 204.131,92.515 L205.55,92.515 z M78.085,78.609 L62.691,78.609 C58.92,78.609 58.416,82.153 58.412,85.239 C58.409,88.238 58.794,92.515 62.681,92.515 L75.199,92.515 C78.059,92.515 78.088,86.062 78.089,84.309 L78.085,78.609" fill="#2A3077"/>
<path d="M324.137,31.786 L323.777,55.26 L323.167,54.702 C320.591,52.335 317.356,51.456 313.921,51.456 L309.367,51.456 C297.624,51.456 286.226,54.667 286.235,68.547 L286.219,84.961 C286.21,98.633 297.931,101.564 309.333,101.564 L313.886,101.564 C325.286,101.564 337.027,98.629 337.038,84.961 L337.07,31.786 L324.137,31.786 z M324.116,68.497 L323.751,84.961 C323.763,91.575 320.799,95.565 313.906,95.565 L309.004,95.565 C302.108,95.565 299.149,91.572 299.139,84.961 L299.156,68.547 C299.163,61.885 301.913,57.459 309.033,57.459 L314.285,57.459 C321.385,57.459 324.127,61.845 324.116,68.497 z M443.106,51.456 L443.117,57.459 L469.069,57.459 C473.252,57.459 476.453,58.999 476.442,63.631 L476.419,71.026 L458.282,71.026 C448.078,71.026 438.592,73.94 438.606,85.952 C438.583,98.173 447.552,101.564 458.281,101.564 L471.086,101.564 C482.374,101.564 489.311,96.856 489.334,84.961 L489.338,68.547 C489.345,55.493 480.375,51.456 468.651,51.456 L443.106,51.456 z M458.314,77.027 L476.433,77.027 L476.438,84.961 C476.435,88.267 476.174,95.565 471.492,95.565 L458.301,95.565 C452.885,95.565 451.888,90.287 451.891,85.952 C451.895,81.582 453.074,77.027 458.314,77.027 z M348.858,51.456 L348.87,57.459 L374.822,57.459 C379.006,57.459 382.208,58.999 382.198,63.631 L382.174,71.026 L364.037,71.026 C353.833,71.026 344.347,73.94 344.36,85.952 C344.338,98.173 353.307,101.564 364.035,101.564 L376.84,101.564 C388.127,101.564 395.064,96.856 395.089,84.961 L395.091,68.547 C395.099,55.493 386.13,51.456 374.406,51.456 L348.858,51.456 z M364.066,77.027 L382.188,77.027 L382.192,84.961 C382.188,88.267 381.929,95.565 377.245,95.565 L364.056,95.565 C358.64,95.565 357.642,90.287 357.645,85.952 C357.648,81.582 358.83,77.027 364.066,77.027 z M428.904,51.306 L419.417,51.306 L403.043,61.288 L403.02,87.429 C403.018,99.042 412.553,101.564 422.328,101.564 L431.547,101.564 L431.581,95.565 L422.364,95.565 C417.385,95.565 415.937,91.792 415.922,87.429 L415.947,57.306 L428.888,57.306 L428.904,51.306" fill="#9CA0BE"/>
<path d="M403.043,32.79 L415.941,26.568 L415.941,49.187 L403.043,57.053 C384.948,30.223 363.469,15.745 342.05,9.965 C299.712,-1.463 257.873,19.837 242.257,40.372 C270.859,1.38 348.555,-27.511 403.043,42.712 L403.043,32.79" fill="#2A3077"/>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 8.6 KiB

229
views/report_invoice_template.xml

@ -4,7 +4,7 @@
<template id="external_layout_standard">
<div t-attf-class="header o_company_#{company.id}_layout">
<div class="row">
<img src="/facile_data_account/static/src/img/header-facil-data.png" style="max-height: 500px;"/>
<img src="/facile_data_account/static/src/img/header-report.svg" style="max-height: 500px;"/>
</div>
</div>
@ -22,9 +22,35 @@
<div t-attf-class="footer o_standard_footer ">
<div class="text-center" style="border-top: 1px solid black;">
<ul class="list-inline mb4">
<div t-field="company.report_footer"/>
</ul>
<span t-field="o.company_id"/>
-
<span t-field="o.company_id.street"/>
<span t-field="o.company_id.street2"/>
<span t-field="o.company_id.zip"/>
<span t-field="o.company_id.city"/>
<span t-field="o.company_id.country_id"/>
-
Email :
<span t-field="o.company_id.email"/>
-
Site Web :
<span t-field="o.company_id.website"/>
-
IBAN FR76 1090 7002 1246 2212 3778 953
-
Code NAF (APE) :
<span t-field="o.company_id.ape"/>
-
N° RCS
<span t-field="o.company_id.company_registry"/>
-
SAINTES - SARL au capital social de 7000 €
-
Siret
<span t-feld="o.company_id.siret"/>
-
N ° TVA
<span t-field="o.company_id.vat"/>
<div t-if="report_type == 'pdf'" class="text-muted">
Page:
@ -63,11 +89,9 @@
<div class="row mt8">
<div class="offset-6 col-6">
<strong class="font-weight-bold">
<span t-field="o.partner_id.ref"/>
<span t-field="o.partner_id"/>
</strong>
<br/>
Monsieur CORRESPONDANT - Fonction
<br/>
<span t-field="o.partner_id.street"/>
<br/>
</div>
@ -87,13 +111,12 @@
<span t-field="o.partner_id.ref"/>
<br/>
N° TVA :
<span t-field="o.partner_id.vat"/>
<br/>
</div>
<div class="col-6 mt8">
<span t-field="o.partner_id.street2"/>
<br/>
Adresse 3
<br/>
<span t-field="o.partner_id.zip"/>
<span t-field="o.partner_id.city"/>
<br/>
@ -102,37 +125,40 @@
</div>
</div>
<div class="row">
Réf : AJ-NS
<div class="row mb8">
<div class="col-6">
Réf :
<span t-field="o.ref"/>
</div>
</div>
<t t-set="display_discount" t-value="any(l.discount for l in o.invoice_line_ids)"/>
<table class="table table-sm o_main_table" name="invoice_line_table">
<table class="table table-sm o_main_table mt8" name="invoice_line_table">
<thead>
<tr class="font-weight-bold" style="background-color: rgb(42, 48, 119); color: white;">
<th name="th_description" class="text-left">
<tr style="background-color: rgb(42, 48, 119); color: white;">
<th name="th_description" class="text-left font-weight-bold">
<span>Libellé</span>
</th>
<th name="th_quantity" class="text-right">
<th name="th_quantity" class="text-right font-weight-bold">
<span>Qté</span>
</th>
<th name="th_priceunit"
t-attf-class="text-right {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
t-attf-class="text-right font-weight-bold">
<span>PU HT</span>
</th>
<th name="th_price_unit" t-if="display_discount"
t-attf-class="text-right {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<th name="th_price_unit"
t-attf-class="text-right font-weight-bold">
<span>Rem.%</span>
</th>
<th name="th_taxes"
t-attf-class="text-left {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span>Taxes</span>
</th>
<th name="th_subtotal" class="text-right">
<span groups="account.group_show_line_subtotals_tax_excluded">Montant HT</span>
<span groups="account.group_show_line_subtotals_tax_included">TTC</span>
</th>
<th name="th_taxes"
t-attf-class="text-left font-weight-bold">
<span>TVA</span>
</th>
</tr>
</thead>
<tbody class="invoice_tbody">
@ -155,23 +181,23 @@
<span t-field="line.quantity"/>
<span t-field="line.product_uom_id" groups="uom.group_uom"/>
</td>
<td t-attf-class="text-right {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<td t-attf-class="text-right">
<span class="text-nowrap" t-field="line.price_unit"/>
</td>
<td t-if="display_discount"
t-attf-class="text-right {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<td
t-attf-class="text-right ">
<span class="text-nowrap" t-field="line.discount"/>
</td>
<td t-attf-class="text-left {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span t-esc="', '.join(map(lambda x: (x.description or x.name), line.tax_ids))"
id="line_tax_ids"/>
</td>
<td class="text-right o_price_total">
<span class="text-nowrap" t-field="line.price_subtotal"
groups="account.group_show_line_subtotals_tax_excluded"/>
<span class="text-nowrap" t-field="line.price_total"
groups="account.group_show_line_subtotals_tax_included"/>
</td>
<td t-attf-class="text-left">
<span t-esc="', '.join(map(lambda x: (x.description or x.name), line.tax_ids))"
id="line_tax_ids"/>
</td>
</t>
<t t-if="line.display_type == 'line_section'">
<td colspan="99">
@ -211,38 +237,6 @@
<!--Tax totals-->
<t t-set="tax_totals" t-value="json.loads(o.tax_totals_json)"/>
<t t-call="account.document_tax_totals"/>
<!--Payments-->
<t t-if="print_with_payments">
<t t-if="o.payment_state != 'invoicing_legacy'">
<t t-set="payments_vals"
t-value="o.sudo()._get_reconciled_info_JSON_values()"/>
<t t-foreach="payments_vals" t-as="payment_vals">
<tr>
<td>
<i class="oe_form_field text-right oe_payment_label">Paid on
<t t-esc="payment_vals['date']"
t-options='{"widget": "date"}'/>
</i>
</td>
<td class="text-right">
<span t-esc="payment_vals['amount']"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
</t>
<t t-if="len(payments_vals) > 0">
<tr class="border-black">
<td>
<strong>Amount Due</strong>
</td>
<td class="text-right">
<span t-field="o.amount_residual"/>
</td>
</tr>
</t>
</t>
</t>
</table>
</div>
</div>
@ -254,15 +248,112 @@
<span t-field="o.narration"/>
</div>
</div>
<div class="row" style="font-size: 60%;">
Pas d'escompte pour règlement anticipé. En cas de retard de paiement, une pénalité égale à 3 fois le
taux intérêt légal sera exigible (Article L 441-6, alinéa 12 du Code de Commerce).
<br/>
Pour tout professionnel, en sus des indemnités de retard, toute somme, y compris l'acompte, non
payée à sa date d'exigibilité produira de plein droit le paiement d'une indemnité
forfaitaire de 40 euros due au titre des frais de recouvrement (Art. 441-6, I al. 12 du code de
commerce et D. 441-5 ibidem)
<div>
<div class="row zero_min_height mb8">
<div class="col-12">
<div style="border-bottom: 2px solid rgb(42, 48, 119);"/>
</div>
</div>
<div class="row mt8">
<div class="col-6 mt8" style="background-color: rgb(42, 48, 119); color: white;">
<span class="mt0">Détails de la TVA</span>
</div>
<div class="offset-2 col-2 bg-200">
<span>Montant Total :</span>
</div>
<div class="col-2 bg-200">
<span t-esc="tax_totals['formatted_amount_untaxed']"/>
</div>
</div>
<div class="row">
<div class="col-2">
<strong>Code</strong>
</div>
<div class="col-2">
<strong>Base HT</strong>
</div>
<div class="col-1">
<strong>Taux</strong>
</div>
<div class="col-2">
<strong>Montant</strong>
</div>
<div class="offset-1 col-2 ">
TVA :
</div>
<div class="col-2 bg-200">
<span t-esc="amount_untaxed"></span>
</div>
</div>
<div class="row">
<t t-set="line_tax_ids" t-value="json.loads(o.tax_line_json)"/>
<t t-if="line_tax_ids" t-foreach="line_tax_ids" t-as="line">
<div class="col-2">
<span t-esc="line['name']"></span>
</div>
<div class="col-2">
<span t-esc="line['base_amount']"></span>
</div>
<div class="col-1">
<span t-esc="line['percentage']"></span>
</div>
<div class="col-2">
<span t-esc="line['amount_taxed']"></span>
</div>
</t>
<br/>
<t t-if="line_tax_ids">
<div class="col-7"></div>
</t>
<div class="offset-1 col-2">
<span>Total TTC:</span>
</div>
<div class="col-2 bg-200">
<span t-esc="tax_totals['formatted_amount_total']"/>
</div>
</div>
<div class="row">
<div class="col-3" style="background-color: rgb(42, 48, 119); color: white;">
Règlement
</div>
<div class="col-2">
Virement
</div>
</div>
<div class="row">
<div class="col-3" style="background-color: rgb(42, 48, 119); color: white;">
Echéance(s)
</div>
<div class="col-2">
<span t-field="o.amount_total"/>
</div>
</div>
<div class="row" style="font-size: 70%;">
<p>
Le montant total s'élève à quatre cent trente-quatre euros
</p>
</div>
<div class="row" style="font-size: 70%;">
<p>
Pas d'escompte pour règlement anticipé. En cas de retard de paiement, une pénalité égale à 3
fois le
taux intérêt légal sera exigible (Article L 441-6, alinéa 12 du Code de Commerce).
<br/>
Pour tout professionnel, en sus des indemnités de retard, toute somme, y compris l'acompte,
non
payée à sa date d'exigibilité produira de plein droit le paiement d'une indemnité
forfaitaire de 40 euros due au titre des frais de recouvrement (Art. 441-6, I al. 12 du code
de
commerce et D. 441-5 ibidem)
</p>
</div>
</div>
</t>
</template>

Loading…
Cancel
Save