Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NFCe alterado layout da impressão. #138

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions report_cupom_nfce/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
40 changes: 40 additions & 0 deletions report_cupom_nfce/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2010-Today OpenERP S.A. (<http://www.openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

{
'name': 'Cupom NFC-e',
'version': '1.0',
'category': 'Others',
'sequence': 2,
'summary': 'relatorios personalizados',
'description': """
""",
'author': 'ATS Soluções',
'website': '',
'depends': ['l10n_br_nfe'],
'data': [
'report/report_cupom_nfce.xml',
# 'report/report_paper_format_lk.xml',

],
'installable': True,
'application': False,
}
1 change: 1 addition & 0 deletions report_cupom_nfce/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import document
61 changes: 61 additions & 0 deletions report_cupom_nfce/models/document.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class FiscalDocumentTransp(models.Model):
_inherit = "l10n_br_fiscal.document"

def _prepare_nfce_danfe_line_values(self):
lines_list = []
lines = self.fiscal_line_ids.filtered(lambda line: line.product_id)
for index, line in enumerate(lines):
product_id = line.product_id
lines_list.append(
{
"product_index": index + 1,
"product_default_code": product_id.default_code,
"product_name": product_id.name,
"product_quantity": line.quantity,
"product_uom": product_id.uom_name,
"product_unit_value": line.price_unit,
"product_unit_total": line.quantity * line.price_unit,
}
)
return lines_list

def _prepare_nfce_danfe_values(self):
return {
"company_ie": self.company_id.inscr_est,
"company_cnpj": self.company_id.cnpj_cpf,
"company_legal_name": self.company_id.legal_name,
"company_name": self.company_id.name,
"company_street": self.company_id.street,
"company_number": self.company_id.street_number,
"company_district": self.company_id.district,
"company_city": self.company_id.city_id.display_name,
"company_state": self.company_id.state_id.name,
"lines": self._prepare_nfce_danfe_line_values(),
"total_product_quantity": len(
self.fiscal_line_ids.filtered(lambda line: line.product_id)
),
"amount_total": self.amount_total,
"amount_discount_value": self.amount_discount_value,
"amount_freight_value": self.amount_freight_value,
"payments": self._prepare_nfce_danfe_payment_values(),
"amount_change": self.nfe40_vTroco,
"nfce_url": self.get_nfce_qrcode_url(),
"document_key": self.document_key,
"document_number": self.document_number,
"document_serie": self.document_serie,
"document_date": self.document_date.astimezone().strftime(
"%d/%m/%y %H:%M:%S"
),
"authorization_protocol": self.authorization_protocol,
"document_qrcode": self.get_nfce_qrcode(),
"system_env": self.nfe40_tpAmb,
"unformatted_amount_freight_value": self.amount_freight_value,
"unformatted_amount_discount_value": self.amount_discount_value,
"contingency": self.nfe_transmission != "1",
"homologation_environment": self.nfe_environment == "2",
}
177 changes: 177 additions & 0 deletions report_cupom_nfce/report/report_cupom_nfce.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_cupom_nfce_document" inherit_id="l10n_br_nfe.report_danfe_nfce">
<xpath expr="//t[@t-call='web.html_container']" position="replace">
<t t-call="web.html_container">
<div style="font-size: 12px; max-width: 90mm; margin-top: 2mm;">
<div style="text-align: center; margin: 0 auto">
<h2 style="text-transform: uppercase; font-size: 18px; font-weight: bold;"><t t-esc="company_name"/></h2>
<div style="max-width: 20.5em; text-align: center; margin: 0 auto;">
<p style="margin-bottom: 0;"><t t-esc="company_legal_name"/></p>
<p style="margin-bottom: 0;"><t t-esc="company_street"/>, <t t-esc="company_district"/>, <t t-esc="company_city"/> - <t t-esc="company_state"/></p>
</div>
<div style="display: flex; justify-content: space-between; max-width: 20em; margin: 0 auto;">
<p style="margin-bottom: 0; padding: 0;">CNPJ: <t t-esc="company_cnpj"/></p>
<p style="margin-bottom: 0; padding: 0;">IE: <t t-esc="company_ie"/></p>
</div>
<div>
<p class="text-transform: uppercase; margin-bottom: 0;">Documento Auxiliar da Nota Fiscal do Consumidor Eletrônica</p>
</div>
<t t-if="contingency">
<hr/>
<div>
<p style="margin-bottom: 0;">Emitida em Contingência</p>
<p style="margin-bottom: 0;">Pendente de Autorização</p>
</div>
</t>
<hr/>
<t t-if="homologation_environment">
<div style="text-transform: uppercase; ">
<p style="margin-bottom: 0; font-size: 14px;">EMITIDA EM AMBIENTE DE HOMOLOGAÇÃO - SEM VALOR FISCAL</p>
</div>
<hr/>
</t>
</div>
<div>
<table style="border: 0px solid; border-collapse: collapse; width:100%">
<tr>
<td style="font-size: 11px; text-align:left">
<b> COD </b>
</td>
<td style="font-size: 11px; text-align:left">
<b> DESCRICAO </b>
</td>
<td style="font-size: 11px; text-align:right">
<b> QTD </b>
</td>
<td style="font-size: 11px; text-align:center">
<b> UN </b>
</td>
<td style="font-size: 11px; text-align:right">
<b> VL UNIT </b>
</td>
<td style="font-size: 11px; text-align:right">
<b> VL TOTAL </b>
</td>
</tr>
<t t-foreach="lines" t-as="line" t-key="line.id">
<tr>
<td style="font-size: 10px; text-align:center">
<span> <t t-esc="line['product_index']"/> </span>
</td>
<td style="font-size: 10px; text-align:left">
<span> <t t-esc="line['product_name']"/> </span>
</td>
<td style="font-size: 10px; text-align:right">
<span> <t t-esc="line['product_quantity']"/> </span>
</td>
<td style="font-size: 10px; text-align:center">
<span> <t t-esc="line['product_uom']"/> </span>
</td>
<td style="font-size: 10px; text-align:right">
<span> <t t-esc="line['product_unit_value']" t-options='{"widget": "float", "precision": 2}'/> </span>
</td>
<td style="font-size: 10px; text-align:right">
<span> <t t-esc="line['product_unit_total']" t-options='{"widget": "float", "precision": 2}' /> </span>
</td>
</tr>
</t>
</table>

</div>
<hr/>
<div>
<table style="border: 0px solid; border-collapse: collapse; width:40%; float: right">
<tr>
<td style="font-size: 11px; text-align:left">
<div style="display: flex; justify-content: space-between; align-items: center;">
<p style="margin-bottom: 0;">Qtd total itens:</p>
<p style="margin-bottom: 0;"><t t-esc="total_product_quantity"/></p>
</div>
</td>
</tr>
<tr>
<td style="font-size: 11px; text-align:left">
<t t-if="unformatted_amount_discount_value">
<div style="display: flex; justify-content: space-between; align-items: center;">
<p style="margin-bottom: 0;">Desconto:</p>
<p style="margin-bottom: 0;"><t t-esc="unformatted_amount_discount_value"/></p>
</div>
</t>
</td>
</tr>
<tr>
<td style="font-size: 11px; text-align:left">
<div style="display: flex; justify-content: space-between; align-items: center;">
<p style="text-transform: uppercase; font-weight: bold; margin-bottom: 0">Valor total:</p>
<p style="margin-bottom: 0;"><t t-esc="amount_total" t-options='{"widget": "float", "precision": 2}'/></p>
</div>
</td>
</tr>
</table>
</div>
<div style="display: flex; justify-content: space-between; align-items: center;">
<table style="border: 0px solid; border-collapse: collapse; width:50%;">
<t t-foreach="payments" t-as="payment">
<tr>
<td style="font-size: 11px; text-align:left">
<p style="margin-bottom: 0;"><t t-esc="payment['method']"/></p>
</td>
<td style="font-size: 11px; text-align:left">
<p style="margin-bottom: 0;"><t t-esc="payment['value']" t-options='{"widget": "float", "precision": 2}'/></p>
</td>
</tr>
<t t-if="amount_change">
<tr>
<td style="font-size: 11px; text-align:left">
<div style="display: flex; justify-content: space-between; align-items: center;">
<p style="margin-bottom: 0;">Troco:</p>
<p style="margin-bottom: 0;"><t t-esc="amount_change"/></p>
</div>
</td>
</tr>
</t>
</t>
</table>
</div>
<hr/>
<div style="text-align: center;">
<p style="margin-bottom: 0;">Consulte pela chave de acesso em:</p>
<p style="margin-bottom: 0;"><t t-esc="nfce_url"/></p>
<p style="font-size: 13px; margin-bottom: 0;"><t t-esc="document_key"/></p>
</div>
<div style="display: flex; flex-direction: row-reverse; align-items: center; justify-content: space-between; margin: 10px 0;">
<div>
<div>
<!-- TODO: Quando o consumidor for identificado deve haver o CPF ou CNPJ-->
<p style="text-transform: uppercase; text-align: left; fonti-size: 18px; margin: 2px auto;">Consumidor Nao Identificado</p>
</div>

<div>
<p style="margin-bottom: 0;">Numero: <t t-esc="document_number"/></p>
<p style="margin-bottom: 0;">Serie: <t t-esc="document_serie"/></p>
<p style="margin-bottom: 0;">Emissao: <t t-esc="document_date"/></p>
</div>

<div>
<t t-if="contingency">
<p style="margin-bottom: 0;">Emitida em Contingencia</p>
<p style="margin-bottom: 0;">Pendente de Autorizacao</p>
</t>
<t t-else="">
<p style="margin-bottom: 0;">Protocolo: <t t-esc="authorization_protocol"/></p>
<p style="margin-bottom: 0;">Autorizacao: <t t-esc="document_date"/></p>
</t>
</div>
</div>

<div>
<t t-set="qr_code" t-value="document_qrcode"/>
<img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s'%('QR', qr_code, 150, 150)"/>
</div>
</div>
</div>
</t>
</xpath>
</template>
</odoo>
42 changes: 42 additions & 0 deletions report_cupom_nfce/report/report_paper_format_lk.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<report
id="report_delivery_document_lk_id"
string="Cupom"
model="account.move"
report_type="qweb-pdf"
name="report_lk.report_delivery_document_lk"
file="report_lk.report_delivery_document_lk"
/>
<record id="cupom_paperformat_id" model="report.paperformat">
<field name="name">Impressora Cupom</field>
<field name="default" eval="True"/>
<field name="format">custom</field>
<field name="page_height">200</field>
<field name="page_width">70</field>
<field name="orientation">Portrait</field>
<field name="margin_top">2</field>
<field name="margin_bottom">10</field>
<field name="margin_left">0</field>
<field name="margin_right">2</field>
<field name="header_line" eval="False"/>
<field name="header_spacing">50</field>
<field name="dpi">130</field>
</record>
<record id="report_lk.report_delivery_document_lk_id" model="ir.actions.report">
<field name="paperformat_id" ref="report_lk.cupom_paperformat_id" />
</record>
<!-- <record id="account_invoices" model="ir.actions.report">
<field name="name">Invoices</field>
<field name="model">account.move</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">account.report_invoice_with_payments</field>
<field name="report_file">account.report_invoice_with_payments</field>
<field name="print_report_name">(object._get_report_base_filename())</field>
<field name="attachment">(object.state == 'posted') and ((object.name or 'INV').replace('/','_')+'.pdf')</field>
<field name="binding_model_id" ref="model_account_move"/>
<field name="binding_type">report</field>
<field name="groups_id" eval="[(4, ref('account.group_account_invoice')),
(4, ref('account.group_account_readonly'))]"/>
</record> -->
</odoo>