Skip to content

Commit aa190f6

Browse files
committed
feat: add custom report for debit/credit note
1 parent 08bb94f commit aa190f6

File tree

12 files changed

+1242
-28
lines changed

12 files changed

+1242
-28
lines changed

account_invoice_som/i18n/es_ES.po

+544-27
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# -*- encoding: utf-8 -*-
2+
from tools import config
3+
from tools.translate import trans_load
4+
5+
6+
def up(cursor, installed_version):
7+
if not installed_version:
8+
return
9+
10+
11+
trans_load(cursor, '{}/{}/i18n/es_ES.po'.format(config['addons_path'], 'account_invoice_som'), 'es_ES')
12+
13+
def down(cursor, installed_version):
14+
pass
15+
16+
17+
migrate = up
+5-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
import account_invoice_som
1+
from __future__ import absolute_import
2+
from __future__ import unicode_literals
3+
4+
from . import account_invoice_som
5+
from . import nota_carrec
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from __future__ import absolute_import
2+
from __future__ import unicode_literals
3+
4+
from . import report
5+
from . import backend
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
from report_backend.report_backend import ReportBackend, report_browsify
4+
from tools.translate import _
5+
6+
7+
class ReportBackendNotaCarrec(ReportBackend):
8+
_inherit = 'report.backend.account.invoice.nota.carrec'
9+
10+
def get_lang(self, cursor, uid, record_id, context=None):
11+
"""
12+
Get the language of the report, depending on the partner
13+
14+
:param cursor: Database cursor
15+
:param uid: User ID
16+
:param record_id: ID of the record to print
17+
:param context: Context dictionary
18+
19+
:return: Return the language of the RECIPIENT partner, defaulting to 'ca_ES'
20+
"""
21+
if context is None:
22+
context = {}
23+
24+
nota_carrec_brw = self.pool.get('account.invoice.nota.carrec').browse(cursor, uid, record_id, context=context)
25+
lang = nota_carrec_brw.partner_id.lang or 'ca_ES'
26+
27+
return lang
28+
29+
@report_browsify
30+
def get_data(self, cursor, uid, nota, context=None):
31+
res = super(ReportBackendNotaCarrec, self).get_data(cursor, uid, nota, context=context)
32+
res.update({
33+
'lang': self.get_lang(cursor, uid, nota.id, context=context),
34+
})
35+
36+
return res
37+
38+
ReportBackendNotaCarrec()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<%def name="capcalera(issuer, recipient, banners)">
2+
<%
3+
logo_company = banners.get('logo', False)
4+
%>
5+
<div class="flex-container header">
6+
%if logo_company:
7+
<div>
8+
<img src="data:image/png;base64,${logo_company}" alt="Company logo" style="max-height: 50px;"/>
9+
</div>
10+
%endif
11+
<div>
12+
${_(u"NOTA DE CÀRREC/ABONAMENT")}
13+
</div>
14+
</div>
15+
<div class="flex-container margin-bottom-15">
16+
<table class="generic-table colored-window secondary-color w-50mm">
17+
<thead>
18+
<tr>
19+
<th colspan="2">
20+
<div>
21+
<div>${_(u"EMISSORA")}</div>
22+
</div>
23+
</th>
24+
</tr>
25+
</thead>
26+
<tbody>
27+
<tr>
28+
<td>${issuer['name']}</td>
29+
</tr>
30+
<tr>
31+
<td>${issuer['vat']}</td>
32+
</tr>
33+
<tr>
34+
<td>${issuer['street']}</td>
35+
</tr>
36+
<tr>
37+
<td>${issuer['city']}</td>
38+
</tr>
39+
</tbody>
40+
<tfoot>
41+
<tr>
42+
<td colspan="2"></td>
43+
</tr>
44+
</tfoot>
45+
</table>
46+
<table class="generic-table colored-window secondary-color generic-table-green w-50mm">
47+
<thead>
48+
<tr>
49+
<th colspan="2">
50+
<div>
51+
<div>${_(u"DESTINATÀRIA")}</div>
52+
</div>
53+
</th>
54+
</tr>
55+
</thead>
56+
<tbody>
57+
<tr>
58+
<td>${recipient['name']}</td>
59+
</tr>
60+
<tr>
61+
<td>${recipient['vat']}</td>
62+
</tr>
63+
<tr>
64+
<td>${recipient['street']} - ${recipient['zip']} - ${recipient['city']}</td>
65+
</tr>
66+
</tbody>
67+
<tfoot>
68+
<tr>
69+
<td colspan="2"></td>
70+
</tr>
71+
</tfoot>
72+
</table>
73+
</div>
74+
</%def>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<%def name="dades_nota(info)">
2+
<table class="generic-table colored-window secondary-color full-width margin-bottom-15" style="text-align: left;">
3+
<thead>
4+
<tr>
5+
<th colspan="3">
6+
<div>
7+
<div>${_(u"DADES DE LA NOTA DE CÀRREC/ABONAMENT")}</div>
8+
</div>
9+
</th>
10+
</tr>
11+
</thead>
12+
<tbody>
13+
<tr>
14+
<td>${_(u"Referència nota de càrrec")}: </td>
15+
<td>${info['note_reference']}</td>
16+
</tr>
17+
<tr>
18+
<td>${_(u"Data de la nota de càrrec")}: </td>
19+
<td>${info['note_create_date']}</td>
20+
</tr>
21+
<tr>
22+
<td>${_(u"Resum de la nota de càrrec")}: </td>
23+
%if info['payment_direction'] == 'receivable':
24+
<td><b>${_(u"A Cobrar")}</b></td>
25+
%else:
26+
<td><b>${_(u"A Pagar")}</b></td>
27+
%endif
28+
<td><b>${info['amount_total']}</b></td>
29+
</tr>
30+
<tr>
31+
<td>${_(u"Data Bancàries")}: </td>
32+
%if info['bank_details']:
33+
<td>${info['bank_details'][:-4]} + '****'</td>
34+
%else:
35+
<td></td>
36+
%endif
37+
</tr>
38+
<tr>
39+
<td>${_(u"Forma de pagament")}: </td>
40+
%if info['payment_method'] == 'transfer':
41+
<td>${_(u"Transferència")}</td>
42+
%else:
43+
<td>${_(u"Rebut domiciliat")}</td>
44+
%endif
45+
</tr>
46+
</tbody>
47+
<tfoot>
48+
<tr>
49+
<td colspan="3"></td>
50+
</tr>
51+
</tfoot>
52+
</table>
53+
</%def>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<%def name="detall_nota(linies, info)">
2+
<table class="generic-table colored-window secondary-color full-width margin-bottom-15">
3+
<thead>
4+
<tr>
5+
<th colspan="2">
6+
<div>
7+
<div>${_(u"DETALL DE LA NOTA DE CÀRREC/ABONAMENT")}</div>
8+
</div>
9+
</th>
10+
</tr>
11+
</thead>
12+
<tbody>
13+
<tr>
14+
<td colspan="2">
15+
<table class="secondary-table invoice-data-table secondary-color colored-window w-90">
16+
<thead>
17+
<tr>
18+
<th>
19+
<div>
20+
<div>${_(u"Nº Factura")}</div>
21+
</div>
22+
</th>
23+
<th>
24+
<div>
25+
<div>${_(u"Data factura")}</div>
26+
</div>
27+
</th>
28+
<th>
29+
<div>
30+
<div>${_(u"Concepte")}</div>
31+
</div>
32+
</th>
33+
<th>
34+
<div>
35+
<div>${_(u"Tipus factura")}</div>
36+
</div>
37+
</th>
38+
<th>
39+
<div>
40+
<div>${_(u"Moviment")}</div>
41+
</div>
42+
</th>
43+
<th class="border-l-black">
44+
<div>
45+
<div>${_(u"Total Factura")}</div>
46+
</div>
47+
</th>
48+
</tr>
49+
</thead>
50+
%for linia in linies:
51+
<tbody>
52+
%if len(linies) > 1:
53+
<tr>
54+
<td colspan="6" class="bold">
55+
<div>
56+
<div>${linia['header']}</div>
57+
</div>
58+
</td>
59+
</tr>
60+
%endif
61+
%for index, invoice in enumerate(linia['invoices']):
62+
<tr>
63+
<td>${invoice['number']}</td>
64+
<td>${invoice['date_invoice']}</td>
65+
<td>${invoice['concept']}</td>
66+
<td>${invoice['type']}</td>
67+
<td>${invoice['move_direction']}</td>
68+
<td class="border-l-black">${invoice['amount']}</td>
69+
</tr>
70+
%endfor
71+
<tr>
72+
<td colspan="5" class="h-5-mm"></td>
73+
<td class="h-5-mm border-l-black"></td>
74+
</tr>
75+
</tbody>
76+
%endfor
77+
<tfoot>
78+
<tr>
79+
</tr>
80+
<tr>
81+
<td colspan="4"></td>
82+
<td class="hightlighted-field border-black">
83+
<div>
84+
<div>${_(u"Total")}</div>
85+
</div>
86+
</td>
87+
<td class="hightlighted-field border-black">
88+
<div>
89+
<div>${info['amount_total']} €</div>
90+
</div>
91+
</td>
92+
</tr>
93+
</tfoot>
94+
</table>
95+
</td>
96+
</tr>
97+
</tbody>
98+
<tfoot>
99+
<tr>
100+
<td colspan="2"></td>
101+
</tr>
102+
</tfoot>
103+
</table>
104+
</%def>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<%def name="extra_data()">
2+
<div class="extra_data">
3+
INFORMACIÓ SOBRE PROTECCIÓ DE DADES DE SOM RENOVABLES S.L.U <br>
4+
Les dades personals tractades per gestionar la relació contractual i, si s'escau, remetre informació comercial per mitjans electrònics, es conservaran fins a la fi de la relació, baixa comercial o els terminis de retenció legals. Pots exercir els teus drets a l'adreça indicada del responsable o a [email protected].
5+
</div>
6+
</%def>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
## -*- coding: utf-8 -*-
2+
3+
<%namespace file="account_invoice_som/report/nota_carrec/components/capcalera.mako" import="capcalera"/>
4+
<%namespace file="account_invoice_som/report/nota_carrec/components/detall_nota.mako" import="detall_nota"/>
5+
<%namespace file="account_invoice_som/report/nota_carrec/components/dades_nota.mako" import="dades_nota"/>
6+
<%namespace file="account_invoice_som/report/nota_carrec/components/extra_data.mako" import="extra_data"/>
7+
8+
9+
<!DOCTYPE html>
10+
<html>
11+
<head>
12+
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
13+
<title>${_(u"NOTA DE CÀRREC/ABONAMENT")}</title>
14+
<style type="text/css">
15+
@font-face {
16+
font-family: "Roboto";
17+
src: url("${assets_path}/fonts/Roboto/Roboto-Regular.ttf") format('truetype');
18+
font-weight: normal;
19+
}
20+
@font-face {
21+
font-family: "Roboto";
22+
src: url("${assets_path}/fonts/Roboto/Roboto-Bold.ttf") format('truetype');
23+
font-weight: bold;
24+
}
25+
</style>
26+
<link rel="stylesheet" href="${addons_path}/account_invoice_som/report/nota_carrec/style.css"/>
27+
</head>
28+
<body>
29+
%for nota in objects:
30+
<%
31+
issuer = nota['issuer']
32+
recipient = nota['recipient']
33+
linies = nota['line_info']
34+
info = nota['info']
35+
banners = nota['banners']
36+
%>
37+
<div class="a4">
38+
<div class="a4-content">
39+
<div>
40+
${capcalera(issuer, recipient, banners)}
41+
</div>
42+
<div>
43+
${dades_nota(info)}
44+
</div>
45+
<div>
46+
${detall_nota(linies, info)}
47+
</div>
48+
<div>
49+
${extra_data()}
50+
</div>
51+
</div>
52+
</div>
53+
%endfor
54+
</body>
55+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from __future__ import absolute_import
2+
3+
from report_puppeteer.report_puppeteer import PuppeteerParser
4+
5+
PuppeteerParser(
6+
'report.nota.carrec',
7+
'report.backend.account.invoice.nota.carrec',
8+
'account_invoice_som/report/nota_carrec/index.mako',
9+
params={}
10+
)

0 commit comments

Comments
 (0)