From 698a5c2c64c2f82101b1ef8aba281ab5bb0bfad0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?=
Date: Sun, 26 Nov 2023 21:58:13 -0300
Subject: [PATCH] [MIG] l10n_br_account: Migration to 15.0
[TMP] use temporary l10n_br_fiscal MIG PR
---
l10n_br_account/README.rst | 12 +++---
l10n_br_account/__manifest__.py | 2 +-
.../migrations/14.0.9.0.0/post-migration.py | 42 -------------------
l10n_br_account/models/account_move.py | 8 ++--
l10n_br_account/models/account_tax.py | 2 +
.../models/account_tax_template.py | 4 +-
l10n_br_account/models/fiscal_document.py | 10 +++++
.../models/fiscal_document_line.py | 10 +++++
l10n_br_account/static/description/index.html | 8 ++--
l10n_br_account/tests/test_account_move_lc.py | 22 ----------
l10n_br_account/tests/test_account_move_sn.py | 3 --
l10n_br_account/tests/test_account_taxes.py | 4 +-
l10n_br_account/tests/test_document_date.py | 4 +-
l10n_br_account/tests/test_invoice_refund.py | 4 +-
.../tests/test_multi_localizations_invoice.py | 3 --
l10n_br_account/tests/test_non_fiscal_move.py | 4 +-
.../views/account_invoice_view.xml | 5 +--
17 files changed, 48 insertions(+), 99 deletions(-)
delete mode 100644 l10n_br_account/migrations/14.0.9.0.0/post-migration.py
diff --git a/l10n_br_account/README.rst b/l10n_br_account/README.rst
index 8e63d2397adf..735c45b1be44 100644
--- a/l10n_br_account/README.rst
+++ b/l10n_br_account/README.rst
@@ -7,7 +7,7 @@ Brazilian Localization Account
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- !! source digest: sha256:745c93e6a5e49fe5d8d1f7960a8cf28dfa0ee349c96eaa1d802e6767b8df8164
+ !! source digest: sha256:14a6f5c1a28387de33b045146f1d6960b79bf51fae3a0c6674ec20c8d0109dd3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -17,13 +17,13 @@ Brazilian Localization Account
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--brazil-lightgray.png?logo=github
- :target: https://github.com/OCA/l10n-brazil/tree/14.0/l10n_br_account
+ :target: https://github.com/OCA/l10n-brazil/tree/15.0/l10n_br_account
:alt: OCA/l10n-brazil
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/l10n-brazil-14-0/l10n-brazil-14-0-l10n_br_account
+ :target: https://translation.odoo-community.org/projects/l10n-brazil-15-0/l10n-brazil-15-0-l10n_br_account
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
- :target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-brazil&target_branch=14.0
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-brazil&target_branch=15.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -63,7 +63,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues `_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -120,6 +120,6 @@ Current `maintainers `__:
|maintainer-renatonlima| |maintainer-rvalyi|
-This module is part of the `OCA/l10n-brazil `_ project on GitHub.
+This module is part of the `OCA/l10n-brazil `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/l10n_br_account/__manifest__.py b/l10n_br_account/__manifest__.py
index 837f2ec2ff0b..723686da3f42 100644
--- a/l10n_br_account/__manifest__.py
+++ b/l10n_br_account/__manifest__.py
@@ -7,7 +7,7 @@
"license": "AGPL-3",
"author": "Akretion, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-brazil",
- "version": "14.0.10.1.0",
+ "version": "15.0.1.0.0",
"development_status": "Beta",
"maintainers": ["renatonlima", "rvalyi"],
"depends": [
diff --git a/l10n_br_account/migrations/14.0.9.0.0/post-migration.py b/l10n_br_account/migrations/14.0.9.0.0/post-migration.py
deleted file mode 100644
index 335301a1d5e9..000000000000
--- a/l10n_br_account/migrations/14.0.9.0.0/post-migration.py
+++ /dev/null
@@ -1,42 +0,0 @@
-from openupgradelib import openupgrade
-
-
-def migrate(cr, version):
- openupgrade.logged_query(
- cr,
- """
- ALTER TABLE account_move_line
- ALTER COLUMN fiscal_document_line_id DROP NOT NULL
- """,
- )
- openupgrade.logged_query(
- cr,
- """
- ALTER TABLE account_move
- ALTER COLUMN fiscal_document_id DROP NOT NULL
- """,
- )
- openupgrade.logged_query(
- cr,
- """
- UPDATE account_move_line
- SET fiscal_document_line_id = NULL
- WHERE move_id IN (
- SELECT am.id
- FROM account_move am
- INNER JOIN l10n_br_fiscal_document fd ON am.fiscal_document_id = fd.id
- WHERE fd.document_type_id IS NULL
- )
- OR exclude_from_invoice_tab = true
- """,
- )
- openupgrade.logged_query(
- cr,
- """
- UPDATE account_move am
- SET fiscal_document_id = NULL
- FROM l10n_br_fiscal_document fd
- WHERE am.fiscal_document_id = fd.id
- AND fd.document_type_id IS NULL
- """,
- )
diff --git a/l10n_br_account/models/account_move.py b/l10n_br_account/models/account_move.py
index 3b19c3421be1..76456310dcdf 100644
--- a/l10n_br_account/models/account_move.py
+++ b/l10n_br_account/models/account_move.py
@@ -170,7 +170,7 @@ def fields_view_get(
sub_form_view
)
sub_arch, sub_fields = view.postprocess_and_fields(
- sub_form_node, "account.move.line", False
+ sub_form_node, "account.move.line"
)
line_field_name = "invoice_line_ids"
invoice_view["fields"][line_field_name]["views"]["form"] = {
@@ -188,7 +188,7 @@ def fields_view_get(
sub_form_view
)
sub_arch, sub_fields = view.postprocess_and_fields(
- sub_form_node, "account.move.line", False
+ sub_form_node, "account.move.line"
)
line_field_name = "invoice_line_ids"
invoice_view["fields"][line_field_name]["views"]["form"] = {
@@ -207,7 +207,7 @@ def fields_view_get(
sub_form_view
)
sub_arch, sub_fields = view.postprocess_and_fields(
- sub_form_node, "account.move.line", False
+ sub_form_node, "account.move.line"
)
line_field_name = "line_ids"
invoice_view["fields"][line_field_name]["views"]["tree"] = {
@@ -241,7 +241,7 @@ def _compute_amount(self):
move.is_invoice(include_receipts=True)
and not line.exclude_from_invoice_tab
):
- line._update_taxes()
+ line._update_fiscal_taxes()
result = super()._compute_amount()
for move in self.filtered(lambda m: m.company_id.country_id.code == "BR"):
diff --git a/l10n_br_account/models/account_tax.py b/l10n_br_account/models/account_tax.py
index 599200edf851..99bbe11026d1 100644
--- a/l10n_br_account/models/account_tax.py
+++ b/l10n_br_account/models/account_tax.py
@@ -26,6 +26,7 @@ def compute_all(
partner=None,
is_refund=False,
handle_price_include=True,
+ include_caba_tags=False,
fiscal_taxes=None,
operation_line=False,
ncm=None,
@@ -74,6 +75,7 @@ def compute_all(
partner,
is_refund,
handle_price_include,
+ include_caba_tags,
)
if not fiscal_taxes:
diff --git a/l10n_br_account/models/account_tax_template.py b/l10n_br_account/models/account_tax_template.py
index 0fd056ca5518..090f352d1c41 100644
--- a/l10n_br_account/models/account_tax_template.py
+++ b/l10n_br_account/models/account_tax_template.py
@@ -17,12 +17,12 @@ class AccountTaxTemplate(models.Model):
def _generate_tax(self, company):
mapping = super()._generate_tax(company)
- taxes_template = self.browse(mapping.get("tax_template_to_tax").keys())
+ taxes_template = mapping.get("tax_template_to_tax").keys()
for tax_template in taxes_template:
tax_id = mapping.get("tax_template_to_tax").get(tax_template.id)
self.env["account.tax"].browse(tax_id).write(
- {"fiscal_tax_ids": [(6, False, tax_template.fiscal_tax_ids.ids)]}
+ {"fiscal_tax_ids": [(6, 0, tax_template.fiscal_tax_ids.ids)]}
)
return mapping
diff --git a/l10n_br_account/models/fiscal_document.py b/l10n_br_account/models/fiscal_document.py
index 002c99467edd..0bb4f764ba3f 100644
--- a/l10n_br_account/models/fiscal_document.py
+++ b/l10n_br_account/models/fiscal_document.py
@@ -140,3 +140,13 @@ def create(self, vals_list):
return super().create(filtered_vals_list)
else:
return super().create(vals_list)
+
+ def _update_cache(self, values, validate=True):
+ """
+ Overriden to avoid raising error with ensure_one() in super()
+ when called from some account.move onchange
+ as we allow empty fiscal document in account.move.
+ """
+ if len(self) == 0:
+ return
+ return super()._update_cache(values, validate)
diff --git a/l10n_br_account/models/fiscal_document_line.py b/l10n_br_account/models/fiscal_document_line.py
index b04a16ba107b..7b30184204ad 100644
--- a/l10n_br_account/models/fiscal_document_line.py
+++ b/l10n_br_account/models/fiscal_document_line.py
@@ -54,3 +54,13 @@ def create(self, vals_list):
return []
return super().create(vals_list)
+
+ def _update_cache(self, values, validate=True):
+ """
+ Overriden to avoid raising error with ensure_one() in super()
+ when called from some account.move.line onchange
+ as we allow empty fiscal document line in account.move.line.
+ """
+ if len(self) == 0:
+ return
+ return super()._update_cache(values, validate)
diff --git a/l10n_br_account/static/description/index.html b/l10n_br_account/static/description/index.html
index 3f11189de26d..f0779dbb0bb8 100644
--- a/l10n_br_account/static/description/index.html
+++ b/l10n_br_account/static/description/index.html
@@ -367,9 +367,9 @@ Brazilian Localization Account
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!! source digest: sha256:745c93e6a5e49fe5d8d1f7960a8cf28dfa0ee349c96eaa1d802e6767b8df8164
+!! source digest: sha256:14a6f5c1a28387de33b045146f1d6960b79bf51fae3a0c6674ec20c8d0109dd3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
This module was written to extend the functionality of … to support …
and allow you to …
Table of contents
@@ -413,7 +413,7 @@
Bugs are tracked on GitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
-feedback.
+feedback.
Do not contact contributors directly about support or help with technical issues.
diff --git a/l10n_br_account/tests/test_account_move_lc.py b/l10n_br_account/tests/test_account_move_lc.py
index f570c3ead27e..d2630e7babd3 100644
--- a/l10n_br_account/tests/test_account_move_lc.py
+++ b/l10n_br_account/tests/test_account_move_lc.py
@@ -135,7 +135,6 @@ def test_venda(self):
"debit": 0.0,
"credit": 843.5,
"date_maturity": False,
- "tax_exigible": True,
}
tax_line_vals_cofins = {
@@ -160,7 +159,6 @@ def test_venda(self):
"debit": 0.0,
"credit": 30.0,
"date_maturity": False,
- "tax_exigible": True,
}
tax_line_vals_icms = {
@@ -185,7 +183,6 @@ def test_venda(self):
"debit": 0.0,
"credit": 120.0,
"date_maturity": False,
- "tax_exigible": True,
}
tax_line_vals_ipi = {
@@ -217,7 +214,6 @@ def test_venda(self):
"debit": 0.0,
"credit": 50.0,
"date_maturity": False,
- "tax_exigible": True,
}
tax_line_vals_pis = {
@@ -242,7 +238,6 @@ def test_venda(self):
"debit": 0.0,
"credit": 6.5,
"date_maturity": False,
- "tax_exigible": True,
}
term_line_vals_1 = {
@@ -263,7 +258,6 @@ def test_venda(self):
"debit": 1050.0,
"credit": 0.0,
"date_maturity": fields.Date.from_string("2019-01-01"),
- "tax_exigible": True,
}
move_vals = {
@@ -310,7 +304,6 @@ def test_simples_remessa(self):
"debit": 0.0,
"credit": 0.0,
"date_maturity": False,
- "tax_exigible": True,
}
tax_line_vals_cofins = {
@@ -335,7 +328,6 @@ def test_simples_remessa(self):
"debit": 0.0,
"credit": 30.0,
"date_maturity": False,
- "tax_exigible": True,
}
tax_line_vals_icms = {
@@ -360,7 +352,6 @@ def test_simples_remessa(self):
"debit": 0.0,
"credit": 120.0,
"date_maturity": False,
- "tax_exigible": True,
}
tax_line_vals_ipi = {
@@ -392,7 +383,6 @@ def test_simples_remessa(self):
"debit": 0.0,
"credit": 50.0,
"date_maturity": False,
- "tax_exigible": True,
}
tax_line_vals_pis = {
@@ -417,7 +407,6 @@ def test_simples_remessa(self):
"debit": 0.0,
"credit": 6.5,
"date_maturity": False,
- "tax_exigible": True,
}
term_line_vals_1 = {
@@ -438,7 +427,6 @@ def test_simples_remessa(self):
"debit": 206.5,
"credit": 0.0,
"date_maturity": fields.Date.from_string("2019-01-01"),
- "tax_exigible": True,
}
move_vals = {
@@ -488,7 +476,6 @@ def test_compra_para_revenda(self):
"debit": 1050.0,
"credit": 0.0,
"date_maturity": False,
- "tax_exigible": True,
}
tax_line_vals_cofins = {
@@ -513,7 +500,6 @@ def test_compra_para_revenda(self):
"debit": 30.0,
"credit": 0.0,
"date_maturity": False,
- "tax_exigible": True,
}
tax_line_vals_cofins_comp = {
@@ -540,7 +526,6 @@ def test_compra_para_revenda(self):
"debit": 0.0,
"credit": 30.0,
"date_maturity": False,
- "tax_exigible": True,
}
tax_line_vals_icms = {
@@ -565,7 +550,6 @@ def test_compra_para_revenda(self):
"debit": 120.0,
"credit": 0.0,
"date_maturity": False,
- "tax_exigible": True,
}
tax_line_vals_icms_comp = {
@@ -590,7 +574,6 @@ def test_compra_para_revenda(self):
"debit": 0.0,
"credit": 120.0,
"date_maturity": False,
- "tax_exigible": True,
}
tax_line_vals_ipi = {
@@ -615,7 +598,6 @@ def test_compra_para_revenda(self):
"debit": 50.0,
"credit": 0.0,
"date_maturity": False,
- "tax_exigible": True,
}
tax_line_vals_ipi_comp = {
@@ -640,7 +622,6 @@ def test_compra_para_revenda(self):
"debit": 0.0,
"credit": 50.0,
"date_maturity": False,
- "tax_exigible": True,
}
tax_line_vals_pis = {
@@ -665,7 +646,6 @@ def test_compra_para_revenda(self):
"debit": 6.5,
"credit": 0.0,
"date_maturity": False,
- "tax_exigible": True,
}
tax_line_vals_pis_comp = {
@@ -690,7 +670,6 @@ def test_compra_para_revenda(self):
"debit": 0.0,
"credit": 6.5,
"date_maturity": False,
- "tax_exigible": True,
}
term_line_vals_1 = {
@@ -711,7 +690,6 @@ def test_compra_para_revenda(self):
"debit": 0.0,
"credit": 1050.0,
"date_maturity": fields.Date.from_string("2019-01-01"),
- "tax_exigible": True,
}
move_vals = {
diff --git a/l10n_br_account/tests/test_account_move_sn.py b/l10n_br_account/tests/test_account_move_sn.py
index 1de1410593f2..3a3a65f4f8f7 100644
--- a/l10n_br_account/tests/test_account_move_sn.py
+++ b/l10n_br_account/tests/test_account_move_sn.py
@@ -118,7 +118,6 @@ def test_revenda(self):
"debit": 0.0,
"credit": 973.0,
"date_maturity": False,
- "tax_exigible": True,
}
tax_line_vals_icms = {
@@ -143,7 +142,6 @@ def test_revenda(self):
"debit": 0.0,
"credit": 27.0,
"date_maturity": False,
- "tax_exigible": True,
}
term_line_vals_1 = {
@@ -164,7 +162,6 @@ def test_revenda(self):
"debit": 1000.0,
"credit": 0.0,
"date_maturity": fields.Date.from_string("2019-01-01"),
- "tax_exigible": True,
}
move_vals = {
diff --git a/l10n_br_account/tests/test_account_taxes.py b/l10n_br_account/tests/test_account_taxes.py
index 08eacac80927..619e41ed0934 100644
--- a/l10n_br_account/tests/test_account_taxes.py
+++ b/l10n_br_account/tests/test_account_taxes.py
@@ -1,10 +1,10 @@
# Copyright (C) 2020 Renato Lima - Akretion
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
-from odoo.tests import SavepointCase
+from odoo.tests import TransactionCase
-class TestAccountTaxes(SavepointCase):
+class TestAccountTaxes(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
diff --git a/l10n_br_account/tests/test_document_date.py b/l10n_br_account/tests/test_document_date.py
index dd30110f19af..74943cadc522 100644
--- a/l10n_br_account/tests/test_document_date.py
+++ b/l10n_br_account/tests/test_document_date.py
@@ -5,12 +5,12 @@
from pytz import UTC, timezone
-from odoo.tests import SavepointCase
+from odoo.tests import TransactionCase
from odoo.addons.l10n_br_fiscal.constants.fiscal import DOCUMENT_ISSUER_PARTNER
-class TestInvoiceDiscount(SavepointCase):
+class TestInvoiceDiscount(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
diff --git a/l10n_br_account/tests/test_invoice_refund.py b/l10n_br_account/tests/test_invoice_refund.py
index 3f2ed7df2754..6336d9b0e68f 100644
--- a/l10n_br_account/tests/test_invoice_refund.py
+++ b/l10n_br_account/tests/test_invoice_refund.py
@@ -3,10 +3,10 @@
from odoo import fields
from odoo.exceptions import UserError
-from odoo.tests import SavepointCase
+from odoo.tests import TransactionCase
-class TestInvoiceRefund(SavepointCase):
+class TestInvoiceRefund(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
diff --git a/l10n_br_account/tests/test_multi_localizations_invoice.py b/l10n_br_account/tests/test_multi_localizations_invoice.py
index 7e04e456f62c..b2962ad246bc 100644
--- a/l10n_br_account/tests/test_multi_localizations_invoice.py
+++ b/l10n_br_account/tests/test_multi_localizations_invoice.py
@@ -184,9 +184,6 @@ def test_force_out_invoice_multiple_switch_payment_terms(self):
def test_force_out_invoice_copy_custom_date(self):
return super().test_out_invoice_copy_custom_date()
- def test_force_select_specific_product_account(self):
- return super().test_select_specific_product_account()
-
def test_force_out_invoice_note_and_tax_partner_is_set(self):
return super().test_out_invoice_note_and_tax_partner_is_set()
diff --git a/l10n_br_account/tests/test_non_fiscal_move.py b/l10n_br_account/tests/test_non_fiscal_move.py
index 9473a9f48300..c5c39d6a79eb 100644
--- a/l10n_br_account/tests/test_non_fiscal_move.py
+++ b/l10n_br_account/tests/test_non_fiscal_move.py
@@ -2,10 +2,10 @@
# Copyright (C) 2023 - TODAY Raphaël Valyi - Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo.tests import SavepointCase
+from odoo.tests import TransactionCase
-class TestCustomerInvoice(SavepointCase):
+class TestCustomerInvoice(TransactionCase):
"""
This is a simple test for ensuring non fiscal account.move
doesn't create fiscal document(.line).
diff --git a/l10n_br_account/views/account_invoice_view.xml b/l10n_br_account/views/account_invoice_view.xml
index f83be23701e5..143b30494f27 100644
--- a/l10n_br_account/views/account_invoice_view.xml
+++ b/l10n_br_account/views/account_invoice_view.xml
@@ -118,10 +118,8 @@
attrs="{'invisible': [('document_electronic', '=', False)], 'readonly': ['|', ('issuer', '=', 'company'), ('state', '!=', 'draft')]}"
/>
-
+
-
-
@@ -296,7 +294,6 @@
-