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

[14.0][BKP] UX Improvements #2242

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 24 additions & 2 deletions l10n_es_vat_book/models/l10n_es_vat_book.py
Expand Up @@ -3,12 +3,13 @@
# Copyright 2017 ForgeFlow, S.L. <contact@forgeflow.com>
# Copyright 2018 Luis M. Ontalba <luismaront@gmail.com>
# Copyright 2019 Tecnativa - Carlos Dauden
# Copyright 2022 Moduon Team - Eduardo de Miguel <edu@moduon.team>
# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0
import datetime
import re

from odoo import _, api, fields, models
from odoo.exceptions import Warning as UserError
from odoo.exceptions import UserError
from odoo.tools import ormcache


Expand Down Expand Up @@ -117,6 +118,25 @@ class L10nEsVatBook(models.Model):
"Auto renumber invoices received", states={"draft": [("readonly", False)]}
)

error_count = fields.Integer(
compute="_compute_error_count",
)

def _compute_error_count(self):
vat_book_exception_group = self.env["l10n.es.vat.book.line"].read_group(
domain=[("exception_text", "!=", False), ("vat_book_id", "in", self.ids)],
fields=["vat_book_id"],
groupby=["vat_book_id"],
)
vat_book_exception_dict = {
vbe["vat_book_id"][0]: vbe["vat_book_id_count"]
for vbe in vat_book_exception_group
}
for vat_book_report in self:
vat_book_report.error_count = vat_book_exception_dict.get(
vat_book_report.id, 0
)

@api.model
def _prepare_vat_book_tax_summary(self, tax_lines, book_type):
tax_summary_data_recs = {}
Expand Down Expand Up @@ -364,7 +384,9 @@ def _set_line_type(self, line_vals, line_type):
line_vals["line_type"] = "rectification_{}".format(line_type)

def _check_exceptions(self, line_vals):
if (
if not line_vals["partner_id"]:
line_vals["exception_text"] = _("Without Partner")
elif (
not line_vals["vat_number"]
and line_vals["partner_id"] not in self.get_pos_partner_ids()
):
Expand Down
6 changes: 3 additions & 3 deletions l10n_es_vat_book/report/vat_book_xlsx.py
Expand Up @@ -163,7 +163,7 @@ def fill_issued_row_data(
):
sheet.write("I" + str(row), "Venta anónima")
else:
sheet.write("I" + str(row), line.partner_id.name[:40])
sheet.write("I" + str(row), (line.partner_id.name or "")[:40])
# TODO: Substitute Invoice
# sheet.write('J' + str(row),
# line.invoice_id.refund_invoice_id.number or '')
Expand Down Expand Up @@ -308,15 +308,15 @@ def fill_received_row_data(
sheet.write("A" + str(row), self.format_boe_date(line.invoice_date))
if date_invoice and date_invoice != line.invoice_date:
sheet.write("B" + str(row), self.format_boe_date(date_invoice))
sheet.write("C" + str(row), line.external_ref and line.external_ref[:40] or "")
sheet.write("C" + str(row), (line.external_ref or "")[:40])
sheet.write("D" + str(row), "")
sheet.write("E" + str(row), line.ref[:20])
sheet.write("F" + str(row), "")
sheet.write("G" + str(row), identifier_type)
if country_code != "ES":
sheet.write("H" + str(row), country_code)
sheet.write("I" + str(row), vat_number)
sheet.write("J" + str(row), line.partner_id.name[:40])
sheet.write("J" + str(row), (line.partner_id.name or "")[:40])
# TODO: Substitute Invoice
# sheet.write('K' + str(row),
# line.invoice_id.refund_invoice_id.number or '')
Expand Down
70 changes: 40 additions & 30 deletions l10n_es_vat_book/views/l10n_es_vat_book.xml
Expand Up @@ -11,6 +11,20 @@
>
<attribute name="invisible">True</attribute>
</button>
<header position="after">
<div
class="alert alert-warning text-center"
attrs="{'invisible': [('error_count', '=', 0)]}"
>
<span>
You have <strong class="text-danger"><field
name="error_count"
/> errors</strong> in this report.
You will not be able to <strong
>confirm and submit</strong> it until they are resolved.
</span>
</div>
</header>
<header position="inside">
<button
name="view_issued_invoices"
Expand Down Expand Up @@ -48,40 +62,36 @@
<xpath expr="//group[@name='group_declaration']" position="after">
<notebook>
<page string="Summary" name="summary">
<group string="Issued Tax Summary" name="issued_tax_summary">
<field name="issued_tax_summary_ids" nolabel="1" />
</group>
<group
string="Received Tax Summary"
name="received_tax_summary"
>
<field name="received_tax_summary_ids" nolabel="1" />
</group>
<group string="Total" name="total_summary">
<field name="summary_ids" nolabel="1" />
</group>
<separator string="Issued Tax Summary" />
<field name="issued_tax_summary_ids" nolabel="1" colspan="2" />
<separator string="Received Tax Summary" />
<field
name="received_tax_summary_ids"
nolabel="1"
colspan="2"
/>
<separator string="Total" />
<field name="summary_ids" nolabel="1" colspan="2" />
</page>
<page string="Issued Invoices" name="invoices_issued">
<group string="Issued Invoices" name="issued_invoices">
<field name="issued_line_ids" nolabel="1" />
</group>
<group
string="Issued Refund Invoices"
name="issued_rectification_invoices"
>
<field name="rectification_issued_line_ids" nolabel="1" />
</group>
<separator string="Issued Invoices" />
<field name="issued_line_ids" nolabel="1" colspan="2" />
<separator string="Issued Refund Invoices" />
<field
name="rectification_issued_line_ids"
nolabel="1"
colspan="2"
/>
</page>
<page string="Received Invoices" name="received_invoices">
<group string="Received Invoices" name="received_invoices">
<field name="received_line_ids" nolabel="1" />
</group>
<group
string="Received Refund Invoices"
name="received_rectification_invoices"
>
<field name="rectification_received_line_ids" nolabel="1" />
</group>
<separator string="Received Invoices" />
<field name="received_line_ids" nolabel="1" colspan="2" />
<separator string="Received Refund Invoices" />
<field
name="rectification_received_line_ids"
nolabel="1"
colspan="2"
/>
</page>
</notebook>
</xpath>
Expand Down